jiggzson / nerdamer

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

Bug for sqrt(nx) when n is negative. #468

Closed Saikedo closed 5 years ago

Saikedo commented 5 years ago

I just realized that nerdamer encounters numerous bugs when you try to evaluate or build a function for roots such as

sqrt(nx) where n is negative. I understand that sqrt of a negative number can be undefined but sqrt(nx) n < 0 is well defined for all x <= 0.

jiggzson commented 5 years ago

I don't know if I've mentioned before but as with most symbolic packages, all symbolic values are assumed to be positive. This greatly simplifies our assumptions. Your above example addresses negative values for x but what about negative coefficients? What about abc*x where a, b, c, x can have a combination of negative values? See where I'm going with this? This is where issue #350 would be super helpful. You would be able to state all your assumptions at the beginning.