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

The recursion is because re() calls as_real_imag on it's argument to get the real part, whereas .as_real_imag() calls expand(complex=True), in particular re()._eval_expand_complex(). So I think the deep=False was intentional to avoid infinite recursion. So if you change that, you have to change something else too to provide a base case for the recursion.

The thing that bothers me is this (from Expr.as_real_imag())

        for term in args:
            coeff = term.as_coefficient(S.ImaginaryUnit)

            if coeff is None:
                re_part.append(term)
            else:
                im_part.append(coeff)

        return (Add(*re_part), Add(*im_part))

As you point out, coeff is None doesn't imply that term is real, it just implies that as_coefficient can't rewrite it as the coefficient of I. It should be written so that if it can't know for sure, it just returns (re(expr), im(expr)) (like how True, False, and None work in the new assumptions). I'm not sure how this can be done, though. Any ideas?

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