# How to make denominator of a complex expression real?

I searched around, but couldn't find any, please help. For example, I got this: $$-\frac{i}{2 \pi (-i \gamma +\text{V0}+\Omega )}$$ Which command will yield this result:

$$-\frac{i \gamma +\text{V0}+\Omega }{2 \pi \left(\gamma ^2+(\text{V0}+\Omega )^2\right)}$$

• @Nasser, thanks! Oct 9, 2016 at 17:37

expr = -I/(2 π (-I g + V0 + G)) z = ComplexExpand @ expr w = Together /@ z num = Numerator /@ w
dem = Denominator /@ w[] // Simplify

num/dem Wrap it up in a function:

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


and e.g.

complex[(a + b I)/(c + d I)] • Thanks very much! So unfortunate, I thought there is some built-in commands for this. Oct 9, 2016 at 17:23
• MMA by default assums everything is complex, so one has to explicitly state the assumtpions. And it also by default tends to simplify as much as possible (in its own manner), so it needs some fiddling to display the result in the form the user wants; it's not a typing tool after all. Oct 9, 2016 at 17:26
• @corey979 ComplexExpand assumes all variables are real by default, so you don't need to use Assuming. Oct 9, 2016 at 17:32
• @ChipHurst Indeed, thanks. Oct 9, 2016 at 17:34

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)}$$ • Thanks. I was looking for a way to put both numerator and denominator in the same expression. Oct 9, 2016 at 17:25
• Sure. I've updated my post with an image that does just that Oct 9, 2016 at 17:31
• Great, thanks very much! Oct 9, 2016 at 17:33
• @Engenuity - I did not get why V0 and Omega have different signs in the expression for a but the same sign in the expression for b. Oct 9, 2016 at 18:52
• @FernandoSaldanha my mistake, fixed it Oct 9, 2016 at 22:29

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".

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: 