Poly Simplify
import mathy_envs.envs.poly_simplify
Challenge¶
In Poly Simplify, the agent must learn to quickly combine and simplify all the like terms in the generated input expression.
Examples
4x + 2y + 2xmust be simplified to6x + 2y23j + 7 + 12x + 2jmust be simplified to25j + 7 + 12x1.3j + 2j - 7must be simplified to3.3j - 7
Win Conditions¶
Solve problems by combining all like terms in the provided expression.
No Like Terms¶
Terms are like when connected by an addition or subtraction, and both terms share a variable and exponent.
Examples
4x + 2ythere are no like terms becausexandyare different variables2x^2 + 4xthere are no like terms becausex^2andxhave different exponents82x + 14xthe terms are like becausexandxare the same12x + 12ythere are no like terms becausexandydifferent variables
No Complex Terms¶
Complex terms are those that can be restated more simply.
Examples
2 * 4xis complex because it has multiple coefficients which could be simplified to8x4x * y * j^2is not complex despite being verbose because there is only a single coefficient and no matching variables
Example Episode¶
A trained agent learns to combine multiple low-level actions into higher-level ones that combine like terms.
Input¶
1k + 210r + 7z + 11k + 10z
Steps¶
| Step | Text |
|---|---|
| input | 1k + 210r + 7z + 11k + 10z |
| commutative swap | 11k + (1k + 210r + 7z) + 10z |
| distributive factoring | 11k + (1k + 210r) + (7 + 10) * z |
| distributive factoring | (11 + 1) * k + 210r + (7 + 10) * z |
| constant arithmetic | (11 + 1) * k + 210r + 17z |
| constant arithmetic | 12k + 210r + 17z |
| solution | 12k + 210r + 17z |
Solution¶
12k + 210r + 17z
API¶
PolySimplify¶
PolySimplify(self, ops: Optional[List[str]] = None, kwargs: Any)
NOTE: This environment only generates polynomial problems with addition operations. Subtraction, Multiplication and Division operators are excluded. This is a good area for improvement.
problem_fn¶
PolySimplify.problem_fn(
self,
params: mathy_envs.types.MathyEnvProblemArgs,
) -> mathy_envs.types.MathyEnvProblem
f(n, m) = p - (3, 1) = "4x + 2x + 6x" - (6, 4) = "4x + v^3 + y + 5z + 12v^3 + x" - (4, 2) = "3x^3 + 2z + 12x^3 + 7z" transition_fn¶
PolySimplify.transition_fn(
self,
env_state: mathy_envs.state.MathyEnvState,
expression: mathy_core.expressions.MathExpression,
features: mathy_envs.state.MathyObservation,
) -> Optional[mathy_envs.time_step.TimeStep]