Possible Duplicate:
Extract real part of a complex expression better than Re does
I have an expression and I would like to find its real and imaginary parts. As a simplification, suppose the expression is $(a+bi)^2$ with $a,b\in\mathbb{R}.$
Of course
Re[(a + b I)^2]
does not work, since Mathematica doesn't know that $a$ and $b$ are real. So I tried
Assuming[Element[{a, b}, Reals], Re[(a + b I)^2]]
which also fails, even if I hit it with Simplify or FullSimplify. Then I thought that perhaps Re was impermeable to the simplification engine, so I expanded it first:
FullSimplify[Assuming[Element[{a, b}, Reals], Re[Expand[(a + b I)^2]]]]
This gives
Re(a^2-b^2)-2 Im(a b)
as the answer, which is closer but still maddeningly incomplete. (Either Mathematica doesn't know that the reals are closed under multiplication and addition or it doesn't know how to find the real or imaginary part of a real number.)
Is there a way I can better express my intentions to Mathematica?
ComplexExpand– rm -rf Jan 31 '13 at 18:40Re(a^2-b^2)-2 Im(a b). – Charles Jan 31 '13 at 18:42a^2 - b^2. What exactly did you do? – rm -rf Jan 31 '13 at 18:43FullSimplify[ Assuming[Element[{a, b}, Reals], Re[ComplexExpand[(a + b I)^2]]]]– Charles Jan 31 '13 at 18:52ComplexExpand[Re[(a + b I)^2]]. You have Re and ComplexExpand in the wrong order. – Sjoerd C. de Vries Jan 31 '13 at 19:02TraditionalForm. – Charles Jan 31 '13 at 19:25