commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dieter Roth (JIRA)" <j...@apache.org>
Subject [jira] Updated: (MATH-221) Result of multiplying and equals for complex numbers is wrong
Date Fri, 29 Aug 2008 14:46:46 GMT

     [ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Dieter Roth updated MATH-221:
-----------------------------

    Description: 
Hi.

The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.

mathematic background:  (0,i) * (-1,0i) = (0,-i).

little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
	public static void main(String[] args) {

		ComplexFormat f = new ComplexFormat();
		Complex c1 = new Complex(0,1);
		Complex c2 = new Complex(-1,0);
		
		Complex res = c1.multiply(c2);
		Complex comp = new Complex(0,-1);

		System.out.println("res:  "+f.format(res));
		System.out.println("comp: "+f.format(comp));
		
		System.out.println("res=comp: "+res.equals(comp));
	}
}
-----------------------------------------------------------------------
res:  -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------

I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.

Good Luck
Dieter

  was:
Hi.

The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.

mathematic background:  (0,i) * (-1,0i) = (0,-i).

little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
	public static void main(String[] args) {

		ComplexFormat f = new ComplexFormat();
		Complex c1 = new Complex(0,1);
		Complex c2 = new Complex(-1,0);
	
		Complex res = c1.multiply(c2);
		Complex comp = new Complex(0,-1);

		System.out.println("res:  "+f.format(res));
		System.out.println("comp: "+f.format(comp));

		System.out.println("res=comp: "+res.equals(comp));
	}
}
-----------------------------------------------------------------------
res:  -0 - 1i
comp: 0 - 1i
res=comp: false

-----------------------------------------------------------------------

I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.

Good Luck
Dieter


> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
>                 Key: MATH-221
>                 URL: https://issues.apache.org/jira/browse/MATH-221
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
>            Reporter: Dieter Roth
>            Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background:  (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> import org.apache.commons.math.complex.*;
> public class TestProg {
> 	public static void main(String[] args) {
> 		ComplexFormat f = new ComplexFormat();
> 		Complex c1 = new Complex(0,1);
> 		Complex c2 = new Complex(-1,0);
> 		
> 		Complex res = c1.multiply(c2);
> 		Complex comp = new Complex(0,-1);
> 		System.out.println("res:  "+f.format(res));
> 		System.out.println("comp: "+f.format(comp));
> 		
> 		System.out.println("res=comp: "+res.equals(comp));
> 	}
> }
> -----------------------------------------------------------------------
> res:  -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter

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