Incorrect negative-based powers

Issue #55 invalid
Former user created an issue

Originally reported on Google Code with ID 55 ``` Hi, -1^(1/3) aka the cube root of one should be -1, but it shows up as NaN. -1*-1=1 1*-1=-1

This happens with any negative number to the power of something less then 2.

-5^(17/9)=NaN when it should equal -20.906... ```

Reported by `lucaslevin` on 2007-06-24 10:39:59

Comments (3)

  1. Former user Account Deleted

    ``` Thank you once again. I've verified this weird behaviour, it's really odd. Marking as accepted and changing the title. ```

    Reported by `helder.pereira.correia` on 2007-06-24 13:02:58 - Status changed: `Accepted` - Labels added: Milestone-0.8

  2. Former user Account Deleted

    ``` Let me guess on the cause of this behavior: Many (if not all) calculators share this problem, because of the approximative way their calculations are done. Unlike mathematicians, you, or some intelligent computer algebra systems, calculators do not operate exactly, so 1/3 is approximated by a value close to 1/3, like 0.3333333333333 for instance. In this first step, the information that the exponent is a fraction is lost. Then, in a second step, the base is raised to this approximate value, using logarithms and exponentiation. While this works out in the positive domain, a negative base is problematic, because the logarithm of a negative number is a true complex value. Speedcrunch, so far, cannot deal with complex numbers, so it presents you a NaN instead. (And if it could, you most probably would not receive what you expect! Because -1 is not the "simplest" 3rd root of -1) Bad luck, there is no simple way around this. This is not a bug, this is a limitation of all approximative calculation.

    Wolf Lammen

    ```

    Reported by `ookami1@gmx.de` on 2007-06-24 23:28:26

  3. Former user Account Deleted

    ``` Yes, Wolf is totally right on this. This issue is not really a bug, but a limitation, like he said.

    lucaslevin: for the record, if the goal was to compute cube roots, SpeedCrunch 0.8 will ship with a "cbrt" function which does not have such a limitation.

    Marking as invalid. ```

    Reported by `helder.pereira.correia` on 2007-06-24 23:50:20 - Status changed: `Invalid`

  4. Log in to comment