google / mathsteps

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

x * (x - 1) = 1 ===>> throws 'Math error: No term with symbol: x , returning no steps' #234

Open bawarkamalqader opened 6 years ago

bawarkamalqader commented 6 years ago

actually i found two issues after testing the above equation.

1) It wrongly throws that error, it fails to detect the two "x" symbols on the left side of the equation. after a little bit of debugging , i found this happens in the "Symbols.js" file , in the function assigned to "Symbols.getLastSymbolTerm". That function first tries to find a symbol if it is a polyomial node, if not , it checks if the operator of the node is "+", if true, it will recursively try to find a symbol in the nodes. The above equation is not polyomial, and its operator is " ", so the function will return null and fail in detecting the symbol in the above equation. Possible Fix : I think after the check for the "+" operator , another check for " " should be done, to try to find symbols even if it is " * " operator.

2) after fixing the above issue, it will not throw the "No term with symbol: " error. but another issue happens, it will throw 'Unsupported operation: ' error. It looks like it happens in the EquationsOperations.js file (possibly line 113), and the function responsible is EquationOperations.removeSymbolFromRightSide(). the reason is, it takes the (x - 1) part to the other side, so the equation becomes x = 1/(x-1) it looks like the system is not able to handle that equation and take the (x-1) back to the left side. Possible Fix : 1) the system should handle inverting functions and be able to take symbols from the right side to the left side, this is also written in the EquationsOperations.js file ( TODO ; line 70) 2) the system should never try to take symbols to the right side like it does in the above equation

AugustMKraft commented 6 years ago

I'm having a similar issue but with the equation x^2+4x+6=0, and other non-factorable quadratic equations.