Problems simplifying expression including imaginary part

I am trying to simplify this expression

expr = -2 π Im[(a b (b - l) o)/(k l (b^2 + 4 o^2 π^2))] +
a b (b l + 4 o^2 π^2) Re[1/(b^2 k l + 4 k l o^2 π^2)]

Simplify[Re[expr],  Assumptions -> {Element[{o, a, b, k, l}, Reals]}]


which returns

$$a b \left(b l+4 \pi ^2 o^2\right) \Re\left(\frac{1}{b^2 k l+4 \pi ^2 k l o^2}\right)-2 \pi \Im\left(\frac{a b o (b-l)}{k l \left(b^2+4 \pi ^2 o^2\right)}\right).$$

Why is the imaginary part not set to zero, although I have stated that all parameter are real? What am I missing?

• try ComplexExpand?
– kglr
Commented Jul 5, 2018 at 14:00
• Is it easy to understand, why that is necessary? Commented Jul 5, 2018 at 14:06
• Re >> Details says: "Re[expr] is left unevaluated if expr is not a numeric quantity." (same for Im). Since the arguments of Im and Re in your expression are not numeric quantities, Im[a1] and Re[a2] do not evaluate to 0 and a2. ComplexExpand expands expr assuming that all variables are real. (and, it seems, it forces evaluation of Im[...] and Re[...])
– kglr
Commented Jul 5, 2018 at 14:21
• Thank you, that helps. Commented Jul 5, 2018 at 14:31
• AskingQuestions, my pleasure.
– kglr
Commented Jul 5, 2018 at 14:33

2 Answers

ComplexExpand @ Re[expr]


(a b^2 l)/(b^2 k l + 4 k l o^2 π^2) + (4 a b o^2 π^2)/( b^2 k l + 4 k l o^2 π^2)

Simplify[%]


(a b^2 l + 4 a b o^2 π^2)/(b^2 k l + 4 k l o^2 π^2)

% // TeXForm


$\frac{a b^2 l+4 \pi ^2 a b o^2}{b^2 k l+4 \pi ^2 k l o^2}$

Just one remark:

The Simplification you asked for also works without ComplexExpand. Therefor you have to give assumptions, which make Re[] evaluable.

In your case

Simplify[Re[expr],Assumptions -> {Element[{o, a, b, k, l}, Reals], b^2 k l + 4 k l o^2 \[Pi]^2 != 0}]
(*(a b (b l + 4 o^2 \[Pi]^2))/(b^2 k l + 4 k l o^2 \[Pi]^2)*)


you must avoid vanishing Denominator in expr.

• Good point..... Commented Jul 6, 2018 at 9:22