# Trouble getting Mathematica to assume some parameters are real and simplify the expression [duplicate]

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.

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

If you use ComplexExpand

Simplify[ComplexExpand[Im[r*Exp[I*theta]^2 + (s + I*t)*Exp[I*theta]]]] 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.