# Im function won't distribute over a sum

When I take the imaginary part of a complex number times a function, I get the answer I was expecting,

Refine[Im[(1+I) Cos[x], Element[x,Reals]]
-> Cos[x]


but if I include a sum,

Refine[Im[(1 + I) Cos[x] + (1 + I) Sin[x]], Element[x, Reals]]
-> Im[(1 + I) Cos[x] + (1 + I) Sin[x]]


It seems that I have to move the Im function inside the sum by hand,

Refine[Map[Im, (1 + I) Cos[x] + (1 + I) Sin[x]], Element[x, Reals]]
-> Cos[x] + Sin[x]


Why is this? I can't think of a situation when this is not the right thing to do. I'm using version 9.0.0.0.

• What is the question? Why doesn't Mathematica do this? Or how do we work round it? Jul 3 '17 at 20:46

Have a look at ComplexExpand

Refine[Im[(1 + I) Cos[x] + (1 + I) Sin[x]], Element[x, Reals]] // ComplexExpand


Cos[x] + Sin[x]

or use Simplify instead of Refine:

Simplify[Im[(1 + I) Cos[x] + (1 + I) Sin[x]], Element[x, Reals]]


Cos[x] + Sin[x]

• Thanks for your answer. I'm still wondering why Mathematica doesn't do this by default. In other words, is there some situation in which doing the Map above gives a wrong answer? Jul 3 '17 at 21:05
• @RodneyPrice. It is probably because doing such transformations by default costs extra processor time, time which is then wasted because the result isn't final and further computations obviate the extra work Jul 3 '17 at 23:37