8
$\begingroup$

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)} $$

$\endgroup$
1
  • $\begingroup$ @Nasser, thanks! $\endgroup$
    – user2165
    Oct 9, 2016 at 17:37

3 Answers 3

8
$\begingroup$
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

$\endgroup$
4
  • $\begingroup$ Thanks very much! So unfortunate, I thought there is some built-in commands for this. $\endgroup$
    – user2165
    Oct 9, 2016 at 17:23
  • 2
    $\begingroup$ 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. $\endgroup$
    – corey979
    Oct 9, 2016 at 17:26
  • $\begingroup$ @corey979 ComplexExpand assumes all variables are real by default, so you don't need to use Assuming. $\endgroup$
    – Greg Hurst
    Oct 9, 2016 at 17:32
  • $\begingroup$ @ChipHurst Indeed, thanks. $\endgroup$
    – corey979
    Oct 9, 2016 at 17:34
5
$\begingroup$

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

$\endgroup$
5
  • $\begingroup$ Thanks. I was looking for a way to put both numerator and denominator in the same expression. $\endgroup$
    – user2165
    Oct 9, 2016 at 17:25
  • $\begingroup$ Sure. I've updated my post with an image that does just that $\endgroup$
    – Engenuity
    Oct 9, 2016 at 17:31
  • $\begingroup$ Great, thanks very much! $\endgroup$
    – user2165
    Oct 9, 2016 at 17:33
  • $\begingroup$ @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. $\endgroup$
    – Soldalma
    Oct 9, 2016 at 18:52
  • $\begingroup$ @FernandoSaldanha my mistake, fixed it $\endgroup$
    – Engenuity
    Oct 9, 2016 at 22:29
2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.