1
$\begingroup$

This question already has an answer here:

Say I enter the following code:

FullSimplify[Im[r*Exp[I*theta]^2 + (s + I*t)*Exp[I*theta]], 
  Element[theta | r | s | t, Reals]]

I expect to get:

2*r*Cos[theta]*Sin[theta] + s*Sin[theta] + t*Cos[theta]

But what Mathematica gives me is:

Im[Exp(I*theta)*(Exp(I*theta)*r + s + I*t)]

What's going on, why isn't Mathematica successfully using the assumptions to compute the imaginary part? When I take out any one of the three terms in the original expression, Mathematica successfully produces the simplified output.

$\endgroup$

marked as duplicate by Kuba Jan 19 '18 at 6:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ The See Also section of the documentation for FullSimplify (as well as that for Simplify) includes a link to ComplexExpand $\endgroup$ – Bob Hanlon Dec 10 '17 at 2:48
2
$\begingroup$

If you use ComplexExpand

Simplify[ComplexExpand[Im[r*Exp[I*theta]^2 + (s + I*t)*Exp[I*theta]]]]

Mathematica graphics

I expect to get:

2*r*Cos[theta]Sin[theta] + sSin[theta] + t*Cos[theta]

It now agrees with what you expected

 FullSimplify[sol-(2*r*Cos[theta]*Sin[theta]+s*Sin[theta]+t*Cos[theta])]
 (* 0 *)

On 11.1.

I think ComplexExpand does a little more than just assumptions on variables being real. It seems to do more special manipulations internally. That is why

Assuming[Element[{theta, r,s,t},Reals],
   FullSimplify[Im[r*Exp[I*theta]^2+(s+I*t)*Exp[I*theta]]]]

did not give same result as ComplexExpand. So when in doubt, use ComplexExpand.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.