[ https://issues.apache.org/jira/browse/MATH-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Luc Maisonobe resolved MATH-1289. --------------------------------- Resolution: Invalid The expressions used in the library are correct. With your expressions, computing I^2 would give +1 instead of -1. and multiplication would not be commutative (for example I * 1 would be the opposite of 1 * I). Remember that in the complex class, the imaginary field is a *real* value holding the multiplicative factor to be applied to I (the square root of -1). In other words z = real + I * imaginary. So {noformat} z1 * z2 = (r1 + I * i1) * (r2 + I * i2) = (r1 * r2 + I * r1 * i2 + I * i1 * r2 + I * I * i1 * i2) = (r1 * r2 + I * I * i1 * i1) + I * (r1 * i2 + i1 * r2) = (r1 * r2 - i1 * i2) + I * (r1 * i2 + i1 * r2) {noformat} which is exactly the expression in the library. > Incorrect calculation in org.apache.commons.math3.complex.Complex#multiply > -------------------------------------------------------------------------- > > Key: MATH-1289 > URL: https://issues.apache.org/jira/browse/MATH-1289 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.5 > Environment: Linux 3.16.0-44-generic #59-Ubuntu SMP Tue Jul 7 > 02:07:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux > java version "1.8.0_45" > Java(TM) SE Runtime Environment (build 1.8.0_45-b14) > Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) > Reporter: Detaille Octave > Labels: easyfix > > Hello guys! > If think there is a bug in the > org.apache.commons.math3.complex.Complex#multiply method > Line 536 & 537 below are not correct > {code:title=Complex.java|borderStyle=solid} > return createComplex(real * factor.real - imaginary * factor.imaginary, real > * factor.imaginary + imaginary * factor.real); > {code} > It should be > {code:title=Complex.java|borderStyle=solid} > return createComplex(real * factor.real + imaginary * factor.imaginary, > imaginary * factor.real-real * factor.imaginary); > {code} > Can you confirm that? Or do I miss something? > Thanks a lot (also, for this excellent library). > Best, > Octave -- This message was sent by Atlassian JIRA (v6.3.4#6332)