Status: Accepted
Owner: smichr
Labels: Type-Defect Priority-Critical

New issue 1556 by smichr: evalf for (a+i*b)*(c+~0i) => ac + ~0i instead of  
ac + ibc
http://code.google.com/p/sympy/issues/detail?id=1556

When a complex number multiplies another number that has an insignificant
complex part, the result also has almost no significant imaginary part.

This snippet...

###
from sympy import *
x1,x2,x0=var('x1 x2 x0');
d={x2: (-1)**(S(6)/7), x1: (-1)**(S(4)/7), x0: (-1)**(S(2)/7)};
eq2=(x0*(1 + x1*(1 + x2)));
print x0.subs(d).evalf(),'*',(1 + x1*(1 + x2)).subs(d).evalf(),'='
print eq2.subs(d).expand().evalf(),'after expansion'
print eq2.subs(d).evalf(chop=True),'with chop=True'
print eq2.subs(d).evalf(),'with just evalf()'
###

generates...

(0.623489801858733 + 0.78183148246803*I) * (0.554958132087371 + .0e-23*I)
= 0.346010735815048 + 0.433883739117558*I after expansion
= 0.346010735815048 + 0.433883739117558*I with chop=True
= 0.346010735815048 + .0e+0*I with just evalf()

I wonder if the evalf.cmul routine which multiplies two complex numbers
should stop looking at the re and im parts of the number (picking the
smallest accuracy for each) and instead only look at the overall
uncertainty of each number, picking the smallest uncertainty *there* and
then assign that to the re and im parts of the result.

I can understand losing significance when finding a difference in two
numbers, but when adding (the cross terms of the complex product) you
shouldn't be losing digits.


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to