It seems like Mathematica cannot separate the expression
x / (z + I*y)
into a pure real and imaginary part with the Re[]
and Im[]
functions.
What is the correct way to get the separated parts?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityUse ComplexExpand
.
Assuming that x
, y
and z
are all reals:
ComplexExpand[Im[x/(z + I*y)]]
(* -((x y)/(y^2 + z^2)) *)
Assuming that x
is complex, the rest are real:
ComplexExpand[Im[x/(z + I*y)], {x}]
(* (z Im[x])/(y^2 + z^2) - (y Re[x])/(y^2 + z^2) *)
See the documentation for Im
:
Im[expr] is left unevaluated if expr is not a numeric quantity.
ComplexExpand
to tell Mathematica that variablesx
,y
, andz
are reals. Therefore, to get the imaginary part of theexpr
,ComplexExpand[Im[expr]]
$\endgroup$