7
$\begingroup$

In Mathematica there are two different forms for the arctangent (inverse tangent), namely

ArcTan[x,y]

which gives the arc tangent of $y/x$, taking into account which quadrant the point $(x,y)$ is in, and

ArcTan[z]

which gives the arc tangent $\tan^{-1}(z)$ of the complex number $z$.

I am not sure about the exact conversion rule, but as far as I understand it is not simply

ArcTan[z] == ArcTan[x+I y] == ArcTan[x,y]

How do I restrict Mathematica to use only one of the two forms for ArcTan, or convert between the two?

EDIT

Maybe I should elucidate on the problem at hand. I am trying to solve the equation $$ a \cos(x) + b \sin(x) = c $$ which can be done with the Weierstrass substitution to yield $$ x_{\pm} = 2 \arctan\left[ \frac{b \pm \sqrt{a^2+b^2 - c^2}}{a+c}\right] $$ which is of the type ArcTan[z]. But if instead I use Mathematica

Solve[a Cos[x] + b Sin[x] == c, x]

Then I get an ugly expression of the type ArcTan[x,y]:

$$ \arctan\left[\frac{a c-\sqrt{a^2 b^2+b^4-b^2 c^2}}{a^2+b^2},\frac{\frac{a \sqrt{-b^2 \left(-a^2-b^2+c^2\right)}}{a^2+b^2}-\frac{a^2 c}{a^2+b^2}+c}{b}\right] $$

How do I tell Mathematica to convert this expression into an ArcTan[z] or vice versa?

(I purposely neglected the periodicity of the solutions.)

EDIT 2 I just saw, that Reduce yields an ArcTan[z]. Where is the logic behind this?

$\endgroup$
2
  • $\begingroup$ The conversion to Matlab using ToMatlab seems to be totally off, as ArcTan[x,y] //ToMatlab yields atan(x,y), but should be atan2(y,x). $\endgroup$
    – Jost
    Commented Oct 23, 2013 at 13:30
  • 3
    $\begingroup$ ToMatlab is not a perfect package, and you'll find a lot of other errors, if you use it often enough. Re: "How do I restrict Mathematica to use only one of the two forms" – well, you are the one calling the function, right? Mathematica doesn't accidentally switch from a one argument version to two or vice versa unless you explicitly say so. $\endgroup$
    – rm -rf
    Commented Oct 23, 2013 at 14:55

3 Answers 3

3
$\begingroup$
Solve[a Cos[x] + b Sin[x] == c && t == Tan[x], t, {x}]
% /. (a_ -> b_) -> x -> ArcTan@b

enter image description here

a Cos[x] + b Sin[x] == c /. (f : (Sin | Cos))[x_] :> TrigExpand@f[2 ArcTan[x]]
Solve[%, x]
% /. (_ -> b_) -> x -> 2 ArcTan@b

enter image description here

Or

Solve[{a Cos[x] + b Sin[x] == c}, x, Method -> Reduce,  MaxExtraConditions -> All]
Solve[{a Cos[x] + b Sin[x] == c, a != 0, b != 0, c != 0}, x, 
  Reals, Method -> Reduce] // FullSimplify
$\endgroup$
1
  • $\begingroup$ This is very useful, thank you. However, I consider this only half the solution, because it only addresses the restriction part. What I still like to know is how to convert between the two ArcTan forms. If you could add this, I accept your answer. $\endgroup$
    – Jost
    Commented Oct 30, 2013 at 15:38
3
$\begingroup$

I believe that according to definitions used in Mathematica, for all complex or real $x,y$ the following holds:

ArcTan[x, y] == 2 ArcTan[y/(x + Sqrt[x^2 + y^2])] == -I Log[(x + I y)/Sqrt[x^2 + y^2]]
$\endgroup$
1
  • $\begingroup$ The only issue is that for $\Re(x)<0,\,y=0,$ the expression in the middle 2 ArcTan[y/(x + Sqrt[x^2 + y^2])] evaluates to Indeterminate rather than $\pi$. $\endgroup$ Commented Mar 6, 2022 at 22:46
1
$\begingroup$

Mathematica's documentation usually assumes you know the definitions of the mathematical functions it is implementing...which sometimes means doing research.

The vector from the origin to the point (x,y) makes an angle arctan(y/x) with the positive x axis. In the complex plane, this corresponds to arg(x+iy).

ArcTan[y/x] == ArcTan[y/x+I 0]

ArcTan[x,y] == Arg[x+I y]

ArcTan[z] uses the definition f[z]=Log[(1 + I z)/(1 - I z)]/(2 I) subject to branch cut discontinuities along the imaginary axis extending to infinity from +i or -i. (i.e. no branch cut between +i and -i).

The effect of these branch cuts is:

1)Along the positive imaginary axis beyond +i,

ArcTan[z]==f[z]

2)Along the negative axis beyond -i,

ArcTan[z] == -Re[f[z]] + Im[f[z]].

I came to these conclusions after looking at a plot of Boole[ArcTan[x+I y]==f[x+I y]] which seems to imply agreement everywhere except along the imaginary axis. I then compared the numerical values given at points along the y axis from -10,10 to come up with the effect of the branch cuts.

$\endgroup$

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.