How to make denominator of a complex expression real?

expr = -I/(2 π (-I g + V0 + G))

enter image description here

z = ComplexExpand @ expr

enter image description here

w = Together /@ z

enter image description here

num = Numerator /@ w
dem = Denominator /@ w[[1]] // Simplify

num/dem

enter image description here


Wrap it up in a function:

complex[expr_] := Block[{w, num, dem},
  w = Together /@ ComplexExpand @ expr;
  num = Numerator /@ w;
  dem = Simplify @ Denominator /@ w[[1]];
  num/dem
  ]

and e.g.

complex[(a + b I)/(c + d I)]

enter image description here


By multiplying both top and bottom by a complex conjugate

$$ {(-i \gamma -(\text{V0}+\Omega ))} $$

(-I \[Gamma] - (V0 + \[CapitalOmega]))

In the numerator, I get $$ {(i \text{V0}-\gamma +i\Omega )} $$

And in the denominator, exactly what you need $$ {-2 \pi(\gamma^2+(\text{V0}+\Omega)^2)} $$

enter image description here


The answer by corey979 has a little problem. The "Numerator" command in "complex[w]" function will be ill-behaved if w have several separated parts after "Together".

Eg. enter image description here

So that, the "Numerator" cannot extract the desired numerator out.

I haven't check the carefully, but when I used a very complicated w, the simplified form after "Together" are a sum of several fractions, which means "Together" doesn't work well, so that the "Numerator" doesn't work.

So, be sure to check is the result after "Together" and "Numerator".

For a corrected version, I suggest using the following one: enter image description here