jiggzson / nerdamer

a symbolic math expression evaluator for javascript
http://www.nerdamer.com
MIT License
518 stars 82 forks source link

Reference error in SolveFor #667

Open Matt0017 opened 2 years ago

Matt0017 commented 2 years ago

> `ReferenceError: i is not defined
>     at eval (eval at build (nerdamer.core.js:11882:1), <anonymous>:3:184)
>     at Object.getPoints (Solve.js:938:1)
>     at solve (Solve.js:1538:1)
>     at Expression.core.Expression.solveFor (Solve.js:257:1)
>     at App.DeterminePOE_Internal (App.js:537:1)
>     at App.DeterminePOE (App.js:474:1)
>     at App.updateXDotExpression (App.js:620:1)
>     at onChange (App.js:735:1)
>     at HTMLUnknownElement.callCallback (react-dom.development.js:4161:1)
>     at Object.invokeGuardedCallbackDev (react-dom.development.js:4210:1)`

Issue occurs when trying to solve for 'y' the following:

(((-abs(-y^2+1/2)-y^2+1/2)^(1/3)+(-y^2+1/2+abs(-y^2+1/2))^(1/3))*((1/2)*i*sqrt(3)+1/2)^2)^3-1+2*((-abs(-y^2+1/2)-y^2+1/2)^(1/3)+(-y^2+1/2+abs(-y^2+1/2))^(1/3))^2*((1/2)*i*sqrt(3)+1/2)^4

which is the result from substituting

x = ((-abs(-y^2+1/2)-y^2+1/2)^(1/3)+(-y^2+1/2+abs(-y^2+1/2))^(1/3))*((1/2)*i*sqrt(3)+1/2)^2 into -1+2*x^2+x^3

Even if this doesn't work, it'd be better to just throw the error, that way I can catch it and do something when this is happening.