Status: Accepted
Owner: renato.c...@gmail.com
Labels: Type-Defect Priority-Medium WrongResult
New issue 1985 by renato.c...@gmail.com: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
In [2]: x = S.Symbol('x')
In [3]: e = (x+x*S.I
Comment #1 on issue 1985 by renato.c...@gmail.com: 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=Fal
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
Comment #3 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Actually, whenever the new assumptions work (or is that now already?), we
could/should just use that. In other words, have re(), im(), and
Comment #4 on issue 1985 by ronan.l...@gmail.com: as_real_imag() gives
wrong answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
The new assumptions don't help. But note that re(e), im(e) gives a correct
result:
In [1]: e = (x+x*I)/(1+I)
In [2]: re(e), im(
Comment #5 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
You usually want the two in pairs, so I think as_real_imag() has its
place. I just do not at all like that code that
assumes "term.as_coeff
Comment #6 on issue 1985 by renato.c...@gmail.com: as_real_imag() gives
wrong answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Playing with it a bit more, looks like ask(expr, Q.real) works well in this
case, and could be used the way Aaron said. I'll writ
Updates:
Labels: NeedsReview
Comment #7 on issue 1985 by renato.c...@gmail.com: as_real_imag() gives
wrong answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Ok, my first (naive) tries were very unsuccessful. It turns out ask() works
for simple cases
Comment #8 on issue 1985 by smichr: as_real_imag() gives wrong answer when
expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
In github/smichr branch t (the one up for review) you will get:
import sympy as S
S.var('x')
x
e = (x+x*S.I)/(1+S.I)
e.as_real_imag()
(re(x),
Comment #9 on issue 1985 by renato.c...@gmail.com: as_real_imag() gives
wrong answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Yes, it works too. It's almost the same thing, using expand(c_mul=True). I
missed that in the docs, and was a bit surprised when
Updates:
Cc: Ronan.Lamy smichr Vinzent.Steinberg
Comment #10 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
So I was so convinced that my solution (refactoring expand(complex=True)
and as_real
Comment #11 on issue 1985 by smichr: as_real_imag() gives wrong answer when
expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Before you consider patching anything consider the radical surgery
accomplished by commit 1725 which adds the hint manager. Most of the
expan
Updates:
Labels: asmeurer renato.coutinho
Comment #12 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
(No comment was entered for this change.)
--
You received this message because you are subsc
Updates:
Status: Fixed
Labels: -NeedsReview -asmeurer PassedReview
Comment #13 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
This was reviewed at http://github.com/sympy/sympy/pull/3 an
Comment #14 on issue 1985 by Vinzent.Steinberg: as_real_imag() gives wrong
answer when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Well, I wish the content of comment 13 was part of some commit message. :)
--
You received this message because you are subscribed to
Updates:
Cc: asmeurer ondrej.certik
Comment #15 on issue 1985 by smichr: as_real_imag() gives wrong answer when
expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
One thing you have to watch out about these core routines is that what the
name says and what the f
Comment #16 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Re 14: Well, it actually is, only maybe in a more contorted way. I wrote
the commit message a while ago. The test itself isn't named in the
Comment #17 on issue 1985 by smichr: as_real_imag() gives wrong answer when
expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
When the original post says that the correct answer should be re(x), im(x)
why is the expression of Out[1] considered to be correct in comment
Comment #18 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
It's based on comment 4. I guess as_real_imag could do simplification,
though I rather think it shouldn't.
The important part is that the a
Comment #19 on issue 1985 by smichr: as_real_imag() gives wrong answer when
expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
re and im are the simplistic functions and as_real_imag the smart one(s) as
it says in the docstring:
'''Performs complex expansion on 'self'
Comment #20 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Well, that isn't true anymore. The way it is after my patch,
as_real_imag() performs complex expansion to obtain the real and imaginary
pa
Comment #21 on issue 1985 by asmeurer: as_real_imag() gives wrong answer
when expanding quotient
http://code.google.com/p/sympy/issues/detail?id=1985
Issue 2067 has been merged into this issue.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group
22 matches
Mail list logo