jiggzson / nerdamer

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

HUGE error on solveFor #670

Open Matt0017 opened 2 years ago

Matt0017 commented 2 years ago

a very simple

x*y+y=0

solved for x return two answers: x=-1 (correct) and x=0 (incorrect)

Matt0017 commented 2 years ago

Debugging I found that this was being transformed into

(x+1)*y that first part gives the correct answer -1 but solving y for x returns 0, which may be the problem of a missing pair of parenthesis in Solve.js line 1328 if(eq.group === S || eq.group === CB && eq.contains(solve_for)) in this case eq.group === S is true and eq.contains(solve_for) is false but the whole condition is true