jiggzson / nerdamer

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

Solve with inequalities #251

Open Happypig375 opened 7 years ago

Happypig375 commented 7 years ago

Currently the solve functions (solve, solveFor, solveEquations) only accept equations. I propose redefining the existing comparison operators to creating inequalities and letting the solve functions solce them.

jarble commented 5 years ago

In some cases, inequalities can be written as equations using the sign function. x>0 could be written as sqrt(x^2)/x = 1.

jiggzson commented 5 years ago

@jarble, thanks for the input. Definitely something to consider. Does x<0 then become -sqrt(x)/x = 1? This might be a silly question since I just skimmed the article but would be a rewrite for x>=0? Do you break it up into two equations at this point?

jarble commented 5 years ago

x<0 could be also be written as sqrt(x^2)/x = -1. sqrt(x^2)/x is undefined when x = 0, so x >= 0 would need to be written in another way.

jarble commented 2 years ago

It seems that x != 0 could be written as abs(x)/abs(x) = 1, since this expression is undefined when x=0.