serso / android-calculatorpp

Android Calculator
421 stars 201 forks source link

(-8)^(1/3) ≠ -2 and wrong plots for ^(1/3) #201

Open mbartelsm opened 4 years ago

mbartelsm commented 4 years ago

Title. On input (-8)^(1/3) I get 1 + 1.7320508076i but it should be -2, in fact, it shouldn't even have an imaginary part, regardless of the value of the base.

When plotting the function x^(1/3) I get the following plot:

Screenshot_2019-12-16-12-12-57-896_org solovyev android calculator

Which is entirely wrong.

Redmi 4X running Android 7.1.2

shadow00 commented 4 years ago

Yep, I can replicate this issue on a couple of different devices.

I get a warning that says "Complex number computation in non-RAD mode can lead to unexpected results!".
If I click "Close" I get 1.9996659589+0.0365520553i (with angles in degrees); if I click "Fix" (thus setting angles in radians) I get the same result as OP.

MithicSpirit commented 3 years ago

That is the correct result as it is using the principal root instead of the real-valued root. Would be nice to have an option to prioritize the real-valued root though (also would be a more sensible default).