Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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


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?


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?

share|improve this question
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. – R. M. Oct 23 '13 at 14:55
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


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
share|improve this answer
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

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]]
share|improve this answer

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,


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.

share|improve this answer

Basically the thing i realized is that, as it was pointed out by Timothy:

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

You can try it out with numerical values and you'll see 1!=2==3.

   N[1/(2 \[Pi]) ArcTan[1/2 + I Sqrt[3]/2]]
   N[1/(2 \[Pi]) ArcTan[1/2, Sqrt[3]/2]]
   N[1/(2 \[Pi]) Arg[1/2 + I Sqrt[3]/2]]

and you get

   0.125 + 0.1048 I

Another equivalence, quite obvious:

Arg[Exp[I θ]] == θ

However none of these three simplifications seem to work:

    FullSimplify[Arg[Exp[I \[Theta]]], Assumptions -> \[Theta] \[Element] Reals]
    FullSimplify[Arg[Exp[I \[Theta]]], Assumptions -> \[Theta] > 0] 
    FullSimplify[ComplexExpand[Arg[Exp[I \[Theta]]]], Assumptions -> \[Theta] \[Element] Reals]

which instead of giving θ produce

    Arg[E^(I \[Theta])]

    Arg[E^(I \[Theta])]

    ArcTan[Cos[\[Theta]], Sin[\[Theta]]]
share|improve this answer
Could you expand on how these considerations address the questions raised in the original answer, specifically? – MarcoB Aug 8 '15 at 23:44
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Aug 9 '15 at 0:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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