New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding (-8)^(2/3) #567

Closed
sonnyk22 opened this Issue Feb 11, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@sonnyk22

sonnyk22 commented Feb 11, 2016

When putting the expression of (-8)^(2/3) into my TI-84 calc, I get a result of 4. Another example is (-8)^(1/3), which should evaluate to -2. However, I am getting a different results on MathJS.

Expression: (-8)^(2/3)
MathJS result: -2 + 3.4641016151378i

Expression: -8^(2/3)
MathJS result: -4 which is correct

When you get a free moment, would you help me with this.

@josdejong josdejong added the question label Feb 12, 2016

@josdejong

This comment has been minimized.

Owner

josdejong commented Feb 12, 2016

Cubic roots always have three answers, and pow returns the principal root, which is not always the real root.

Have a look into cbrt, which allows you to get all three roots:

// (-8)^(1/3)
math.cbrt(-8, true); // [1 + 1.7320508075689i, -2, 1 - 1.7320508075689i]

See #524.

@sonnyk22

This comment has been minimized.

sonnyk22 commented Feb 12, 2016

Great readings. How would you suggest me to apply the .cbrt() function to evaluate the (-8)^(2/3) or (-8)^(-2/3) when to the power of is other than 1/3? The .eval() handles the (8)^(2/3) great, but I've noticed that when negative numbers are included such as (-8)^(2/3) or (-8)^(-2/3) then I get complex answers back.

@ericman314

This comment has been minimized.

Collaborator

ericman314 commented Feb 12, 2016

There's an open pull request #525 to handle this case. There's a little more work I need to do on it but the idea is you would set the config {predictable: true} and then 8 ^ (-2/3) would return -4 instead of a complex result. Let's continue the discussion in #486.

@ericman314 ericman314 closed this Feb 12, 2016

@sonnyk22

This comment has been minimized.

sonnyk22 commented Feb 12, 2016

awesome! thank you

@josdejong

This comment has been minimized.

Owner

josdejong commented Feb 13, 2016

Thanks @ericman314 I almost forgot about the pending #525...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment