Powers with negative base and non-integer exponent are NaN
Originally reported on Google Code with ID 402
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Reported by alex.erzunov
on 2012-05-14 09:41:07
Comments (16)
-
Account Deleted -
Account Deleted Steps to reproduce: (-27)^(1/3) Expected behavior: -3 Experienced behavior: NaN Product version: 0.10.1 Operating system: Mac OSX 10.7 Additional Information:
Reported by
kristoffersen.jorgen
on 2013-10-16 21:32:34 -
Account Deleted Reported by
helder.pereira.correia
on 2013-10-22 02:49:44 - Labels added: Type-Defect, Priority-High, OpSys-All, Milestone-0.11 -
Account Deleted Fixed in revision 53f3266a
Reported by
helder.pereira.correia
on 2013-10-22 18:26:47 - Status changed:Fixed
-
repo owner - changed component to parser
- changed version to 0.10.1
- changed milestone to 0.11
-
assigned issue to
- edited description
-
repo owner - changed status to closed
-
I suggest to reopen this.
Your workaround is not a solution. Quite the opposite in fact. Just look at
(-1)^0.5 = -1
. I prefer a NaN to an obviously wrong result.I'll see if I can cook something up with rational numbers...
-
repo owner - changed status to open
-
repo owner - changed milestone to 0.12
- removed responsible
-
Isn't it fixed already in pull request #14 (Complex numbers + units)? I haven't test, but the associated functions (CMath::raise/exp/ln) seem to handle those cases, and provide the expected complex results.
-
Not really, and that's why I ran into this.
As shown above, the current implementation in
master
is simply wrong.About the new (complex numbers) system:
-
it does not help the fact thatEDIT (this only holds in real mode)(-a)^b
is not defined ifb
is irrational anda
>0. -
It gives
(-27)^(1/3) = 1.5+2.59807621135331594029j
. This is indeed the correct first cubic root of -27, but when disabling complex numbers one would expect the real result-3
. This is not the case, instead it will still yield the complex root.
-
-
Thanks for the clarifications, I understand the issue better now.
-
I just posted pull request #15 for the newest iteration of the complex+units branch. It should deal with this issue for real :)
-
-
assigned issue to
-
assigned issue to
-
repo owner - changed status to closed
-
Should be fixed as of abdde5c.
- Log in to comment
``` Hi Alex. This is a known limitation of our engine. Please use cbrt(-4/3) instead. ```
Reported by `helder.pereira.correia` on 2012-05-24 04:40:12 - Status changed: `Accepted`