# Real and imaginary parts of complex logarithm

I need to obtain the real and imaginary parts of the below expression with Mathematica:

$$(- i a - m^2) \ln(\frac{i m^2}{2 a})$$,

where $$a$$ and $$m$$ are real.

So we have:

Refine[Re[(-I a - m^2) Log[(I m^2)/(2 a)]], {Element[a, Reals], Element[m, Reals]}]


However, Mathematica returns the command again. How can I proceed?

Use ComplexExpand and then Simplify:

Simplify[ComplexExpand[ReIm[(-I a - m^2) Log[(I m^2)/(2 a)]]], a > 0]
Simplify[ComplexExpand[ReIm[(-I a - m^2) Log[(I m^2)/(2 a)]]], a < 0]


{(a π)/2 - m^2 Log[1/(2 a)] - m^2 Log[m^2], -((m^2 π)/2) - a Log[1/(2 a)] - a Log[m^2]}

{-((a π)/2) - m^2 Log[-(1/(2 a))] - m^2 Log[m^2], (m^2 π)/2 - a Log[-(1/(2 a))] - a Log[m^2]}

An alternative, as Bob Hanlon mentions, is to use ComplexExpand with the option TargetFunctions->{Re, Im}

• Thanks. Why isn't any $a$ in your final solution? – user67794 Oct 8 '19 at 23:53
• @Carl appears to have set a = 2. For arbitrary a use ComplexExpand[ReIm[(-I a - m^2) Log[(I m^2)/(2 a)]], TargetFunctions -> {Re, Im}] – Bob Hanlon Oct 9 '19 at 0:23