commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joerg Huber (JIRA)" <j...@apache.org>
Subject [jira] Created: (MATH-306) Method 'divide' in class 'Complex' uses a false formula for a special case resulting in erroneous division by zero.
Date Sat, 24 Oct 2009 14:23:59 GMT
Method 'divide' in class 'Complex' uses a false formula for a special case resulting in erroneous
division by zero.
-------------------------------------------------------------------------------------------------------------------

                 Key: MATH-306
                 URL: https://issues.apache.org/jira/browse/MATH-306
             Project: Commons Math
          Issue Type: Bug
         Environment: all
            Reporter: Joerg Huber


The formula that 'divide' wants to implement is

a + bi          ac + bd + (bc - ad)i
----------- = -------------------------
c + di               c<sup>2</sup> + d<sup>2</sup>

as correctly written in the description.

When c == 0.0 this leads to the special case

a + bi          b - a i
----------- = ------------
   di                  d

But the corresponding code is:

if (c == 0.0) {
    return createComplex(imaginary/d, -real/c);
}

The bug is the last division -real/c, which should obviously be -real/d.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message