Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1397

Complex.ZERO.pow(2.0) is NaN

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Won't Do
    • 3.6.1
    • 4.0
    • None
    • Linux, Java1.7/Java1.8

    Description

      ```
      package complextest;

      import org.apache.commons.math3.complex.Complex;

      public class T {
      public static void main(String[] args)

      { System.out.println(Complex.ZERO.pow(2.0)); }

      }
      ```

      This is the code and the readout is `(NaN, NaN)`. This surely isn't right. For one, it should actually be zero (https://www.wolframalpha.com/input/?i=(0%2B0i)%5E2) and second of all, the documentation doesn't state that anything could go wrong from a Complex number that has no NaNs and Infs.

      The other definition states that it doesn't work when the base is Zero, but it surely should. This strange corner case destroys any naive implementation of stuff wrt the mandelbrot set.

      It would be nice to not have to implement this exception myself.

      Attachments

        Issue Links

          Activity

            People

              ericbarnhill Eric Barnhill
              maweki Mario Wenzel
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: