jiggzson / nerdamer

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

Add advance root function (nth root and cubic root) #550

Closed MAGNETO903 closed 4 years ago

MAGNETO903 commented 4 years ago

Add function (maybe root(a, b)) that return number c that c^a=b

root(3, 8) // return 2 root(4, 16) // return 4 root(8, 3) // return 1.1472...

And also add cbrt(a) that return number b that b^3=a (cubic root)

cbrt(8) // return 2 cbrt(27) // return 3 cbrt(2) // return 1.2599...

Happypig375 commented 4 years ago

Are you looking for the real root or the principal root? They are different when complex numbers are in the picture.

MAGNETO903 commented 4 years ago

I did not undertstand the difference between the real root and the principal root, but I am looking for a function like nthRoot() in mathjs library nthRoot() function

jiggzson commented 4 years ago

I know that an nthroot function was started at some point but was never completed. I'll look into completing it. Adding a cbrt function might not be a bad idea as well.

jiggzson commented 4 years ago

Done.