google / mathsteps

Step by step math solutions for everyone
https://socratic.org
Apache License 2.0
2.12k stars 274 forks source link

Factoring support for quadratics #50

Open evykassirer opened 7 years ago

evykassirer commented 7 years ago

We don't have any factoring polynomial support yet, but that's our next big goal!

We want to make another top level module like simplifyExpression and solveEquation that factors an expression (note that factoring is sort of the opposite of simplifying, because simplifying distributes and we would want to "un-distribute")

We should be able to factor quadratics in the following ways:





sangwinc commented 7 years ago

Perhaps you might like to also consider "completing the square" as a method for solving quadratics?

x^2+2*a*x +c = 0,
x*(x+2*a) +c = 0, 
(x+a-a)*(x+a+a)+c = 0, 
(x+a)^2-a^2+c = 0
(x+a)^2 = a^2-c

... etc.

I've only just come across your system (and I'm impressed: email to follow).

Does your system provide more than one solution, or does it always just give "the way" to solve an equation?

evykassirer commented 7 years ago

as far as I remember, completing the square tends to be used for graphing, and isn't as useful for factoring (which is what this particular issue is working on, and would be used for simplifyExpression and solveEquation)

I could totally see another function alongside solveEquation that completes the square for quadratics and/or gives steps for graphing a function. Feel free to open an issue for that if you'd like to see it be worked on :)

Right now we always give one solution, but in the future it might be possible to configure certain settings to get certain kinds of solutions.

evykassirer commented 7 years ago

unassigned, since the initial pull request went through

we still need to add quadratic equation, and also expose factoring to users of the mathsteps module

aelnaiem commented 7 years ago

Thanks for updating this! I will probably pick up exposing factoring in the API. Should it just be around factor() or should it be factorQuadratic? Also, factoring is often one step (currently it always is but it will have more steps once we support the quadratic equation). Finally, should we support factoring for equations as well? In the case that it's x^2 + 3x + 2 = 0, we actually have two results (similar to absolutes), x = -1 and x = -2. So maybe we wait until we have multiple case support before we tackle that?

hmaurer commented 7 years ago

note that factoring is sort of the opposite of simplifying, because simplifying distributes and we would want to "un-distribute"

I am inclined to disagree with that. Take Mathematica as an example, they have two functions: "Expand" and "Factor". "Expand" behaves like simplifyExpression, and "Factor" is an advanced version of what is being discussed in this issue. However the goal of simplifyExpression is not (or is it?) to expand, it is to simplify, aka to make it as clear as possible to the student.

With that in mind, factorisation could very well be used in the simplification process. For example, one might argue that 2x + 2y is a more complex expression than 2 * (x + y). Likewise, x^2 + y^2 + 2*x*y is certainly more complex than (x + y)^2. It is harder to reader, harder to find the roots of, etc. Now of course this depends on how we define "expression complexity", what the student's goal is, etc. The simplification process might also need to start by expanding an expression, cancel out terms, then factor it back to a nice result. This might be particularly

evykassirer commented 7 years ago

I think your message got cut off

that's a good point! it's hard to know what form a student is looking for, but adding factoring at the end is definitely something we can consider doing, or adding as an option parameter or something

aelnaiem commented 7 years ago

There's a new pull request for exposing factoring https://github.com/socraticorg/mathsteps/pull/148