Comment #1 on issue 1985 by [email protected]: as_real_imag() gives wrong answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985

A simple workaround is to use expand(complex=True, deep=True). Actually, all as_real_imag() does is expand(complex=True, deep=False), take each term and see if it can be written as a coefficient of I, but

In [5]: e.expand(complex=True, deep=False)
Out[5]: im(x)/2 + I*im(x) + I*(I*im(x) + re(x))/2 - I*re(x)/2 + re(x)

In [6]: _.args
Out[6]: (I*im(x), I*(I*im(x) + re(x))/2, im(x)/2, re(x), -I*re(x)/2)

In [7]: _[1].as_coefficient(S.I)

In [8]:

So that term goes into the real part. I tried using expand(complex=True, deep=True) inside as_real_imag(), but then a lot of tests fail, including one exception with max recursion depth exceeded, and I don't know why.


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