2
$\begingroup$

If I were to have an equation, say something similar to...

(1-Sqrt[x - I y])/(1+Sqrt[x - I y]) = A + I B

Where I = Sqrt[-1], is there a way for Mathematica to give me A = ... and B = ..., i.e. both real and imaginary parts of the equation simultaneously?

$\endgroup$
6
  • $\begingroup$ Hi ! You are not using the correct syntax - are you sure you know your way around Mathematica ? $\endgroup$
    – Sektor
    Jul 28, 2014 at 8:23
  • $\begingroup$ Hi, I'm actually brand new to Mathematica. That equation is just an example I was using to describe my problem, not the one I need to solve (the real one is fairly long). Is there a better way I should be asking my question? $\endgroup$
    – Tait
    Jul 28, 2014 at 8:34
  • $\begingroup$ In that case - I don't think there is :) You can start by looking at Reduce, Solve and ComplexExpand. $\endgroup$
    – Sektor
    Jul 28, 2014 at 8:51
  • $\begingroup$ Ok great, thank you! So for example, if I wanted to use the ComplexExpand command on the above expression, it would look something like this... ComplexExpand[(1-Sqrt[x - I y])/(1+Sqrt[x - I y]) = A + Ib,{A}] for the real part? $\endgroup$
    – Tait
    Jul 28, 2014 at 9:41
  • $\begingroup$ Also, thank you Sjoerd for editing it to the correct format $\endgroup$
    – Tait
    Jul 28, 2014 at 9:43

1 Answer 1

4
$\begingroup$

Something like this:

ComplexExpand[
  Solve[
    {
      Re[(1 - Sqrt[x - I y])/(1 + Sqrt[x - I y])] == A, 
      Im[(1 - Sqrt[x - I y])/(1 + Sqrt[x - I y])] == B
    }, 
    {A, B}
  ],
  TargetFunctions -> {Re, Im}
]

(* {{A -> 1/((1 + (x^2 + y^2)^(1/4)*Cos[(1/2)*ArcTan[x, -y]])^2 + 
              Sqrt[x^2 + y^2]*Sin[(1/2)*ArcTan[x, -y]]^2) - 
         (Sqrt[x^2 + y^2]*Cos[(1/2)*ArcTan[x, -y]]^2)/
           ((1 + (x^2 + y^2)^(1/4)*Cos[(1/2)*ArcTan[x, -y]])^2 + 
              Sqrt[x^2 + y^2]*Sin[(1/2)*ArcTan[x, -y]]^2) - 
         (Sqrt[x^2 + y^2]*Sin[(1/2)*ArcTan[x, -y]]^2)/
           ((1 + (x^2 + y^2)^(1/4)*Cos[(1/2)*ArcTan[x, -y]])^2 + 
              Sqrt[x^2 + y^2]*Sin[(1/2)*ArcTan[x, -y]]^2), 
     B -> -((2*(x^2 + y^2)^(1/4)*Sin[(1/2)*ArcTan[x, -y]])/
            ((1 + (x^2 + y^2)^(1/4)*Cos[(1/2)*ArcTan[x, -y]])^2 + 
               Sqrt[x^2 + y^2]*Sin[(1/2)*ArcTan[x, -y]]^2))}} *)
$\endgroup$
2
  • $\begingroup$ Wow thank you so much! So just so I'm clear, by doing this, it is solving the equation one time only for the real part, A, and then solving it again for the imaginary part, B? $\endgroup$
    – Tait
    Jul 28, 2014 at 13:30
  • $\begingroup$ @tair something like that, but don't forget that the real and imaginary parts may be totally different and are completely independent, so saying that you use the same equation twice is not completely true. $\endgroup$ Jul 31, 2014 at 15:57

Your Answer

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

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