# Equivalence of ComplexExpand and assuming real arguments

I am wondering why this simplification does not work,

FullSimplify[Im[1/Sin[a]], Assumptions -> Element[a, Reals]]
(*Out[1]= Im(csc(a))*)


while this does:

FullSimplify[ComplexExpand[Im[1/Sin[a]]]]
(*Out[2]= 0*)


I would think the two lines are equivalent? I understand of course that the denominator can become zero, but that does not create an imaginary part... In this particular case I can of course simply use the second version, but I have a problem where ComplexExpand takes very long, so I would like to avoid it. (Mathematica version: 11.1.0.0 for Linux)

• The implicit assumption of real values in ComplexExpand does not carry over to the outside function FullSimplify. Not sure if that answers your question though. – Daniel Lichtblau Mar 8 '18 at 16:58

FullSimplify[Im[1/Sin[a]], Assumptions -> {Element[a, Reals], Sin[a] != 0}]


0

Note that there is a pole in 1/Sin[a], which FullSimplify will not automatically discard. Since the pole is indeterminate, there's no actual guarantee that it doesn't have an imaginary part.

I am not entirely sure why ComplexExpand discards the pole.

• As I said, I understand that there's a pole. I would have thought that the inverse of a real number is real, and ComplexExpand seems to think so, too. Explicitly excluding 0 for the denominator is of course an option, I was hoping for something more general (since there might be many explicit exclusions I'd have to make). – Martin J. Mar 8 '18 at 16:09
• @MartinJ Infinity isn't exactly a real number, so division isn't closed within the reals if the denominator is 0. While it's perfectly reasonable in almost all cases to assume that the division of a real number by a real number is real, it's not actually the case. Add in that division by 0 isn't clear on which infinity it implies (if any), and there's a whole host of issues that result in FullSimplify leaving it alone. ComplexExpand is a little bit looser with its assumptions. – eyorble Mar 8 '18 at 16:15

Mathematica is not so careful with Conjugate, so you could do:

Block[{Im = (#-Conjugate[#])/(2I)&},
FullSimplify[Im[1/Sin[a]], Assumptions->Element[a,Reals]]
]


0

On the other hand, I'm surprised that ComplexExpand is slow, I would have expected the FullSimplify of the ComplexExpand output to be slow.