Powers with negative base and non-integer exponent are NaN

Issue #402 closed
Former user created an issue

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)

  1. Former user Account Deleted

    ``` 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`

  2. Former user 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

  3. Former user 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

  4. Former user Account Deleted
    Fixed in revision 53f3266a
    

    Reported by helder.pereira.correia on 2013-10-22 18:26:47 - Status changed: Fixed

  5. Pol Welter

    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...

  6. Tey'

    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.

  7. Pol Welter

    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:

    1. it does not help the fact that (-a)^b is not defined if b is irrational and a>0. EDIT (this only holds in real mode)

    2. 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.

  8. Log in to comment