# ArcTan[z] and ArcTan[x,y], Restriction and Conversion

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?

-
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). –  Jost Oct 23 '13 at 13:30
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. –  The Toad Oct 23 '13 at 14:55

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


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


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

-
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. –  Jost Oct 30 '13 at 15:38

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.

-