# ArcTan[x,y] problems

I need an ArcTan[x,y] function that is continuous in (0,2 π)

For the standard ArcTan function:

Assuming[-π < x <= π, FullSimplify[ArcTan[Cos[x], Sin[x]]]]


yields x, as expected.

MyArcTan[C,S]:=π + ArcTan[-C,-S]


does the job numerically, yielding x when C=Cos[x] and S=Sin[x] for 0 < x < 2 π but:

Assuming[0 < x < 2 π, w = FullSimplify[MyArcTan[Cos[x], Sin[x]]]]


yieldsπ + ArcTan[-Cos[x], -Sin[x]] instead of x.

Is there something simple I am missing? Any ideas on how to do this? Thanks for any help.

• What do you mean by "continuous in (0,2 π)"? – Jens Apr 14 '15 at 2:40

Not sure if I understand you correctly but you can define your own function as follows:

f[0, x_] := Sign[x] Pi/2
f[x_, y_] := ArcTan[x, y]
f[Cos[x_], Sin[x_]] := x

FullSimplify[f[Cos[x], Sin[x]]]
(*x*)


MyArcTan[x_, y_] := ArcTan[-x, -y] + Pi;
MyArcTan[r_.*Cos[x_], r_.*Sin[x_]] := x;

Assuming[0 <= x < 2 Pi, MyArcTan[Cos[x], Sin[x]]]
(*x*)

• To be more clear, for numerical values of real r and x, I want MyArcTan[r Cos[x], r Sin[x]] to return x for {r > 0 , 0 <= x < 2 π}. For example, I want MyArcTan[-5, -5] to yield 5π/4, not π/4 the way Arctan[1] does, or -3π/4 the way ArcTan[-5,-5] does. The function MyArcTan[x_, y_] := ArcTan[-x, -y] + π does this just fine. But I want it to work symbolically as well. I want Assuming[0 <= x < 2 π, MyArcTan[Cos[x], Sin[x]] ] to return x, for example, the way Assuming[0 <= x < π/2, ArcTan[Tan[x]]] and Assuming[0 <= x < π, ArcTan[Cos[x], Sin[x]]] do. – Paul R. Apr 14 '15 at 6:30
• Sorry, I forgot to write FullSimplify[ArcTan[Tan[x]]] and FullSimplify[ArcTan[Cos[x],Sin[x]]] in the above. Simplify works as well. – Paul R. Apr 14 '15 at 6:49
• @PaulR. why don't you then add this definition rule to you function: MyArcTan[r_*Cos[x_], r_*Sin[x_]] := x? – Algohi Apr 14 '15 at 14:47
• Hi Algohi - thanks for your answer. I tried this: MyArcTan[x_, y_] := ArcTan[-x, -y] + [Pi]; MyArcTan[r_*Cos[x_], r_*Sin[x_]] := x; but Assuming[0 <= x < 2 π, MyArcTan[Cos[x], Sin[x]] ] still does not return x. – Paul R. Apr 14 '15 at 19:26
• @PaulR, Please see the update. – Algohi Apr 14 '15 at 21:28

The problem here is with FullSimplify, not your definition.

(First I'll rewrite your definition to be a little more standard.)

myArcTan[c_, s_] := Pi + ArcTan[-c, -s]


Just because Mathematica fails to Simplify this expression

myArcTan[Cos[x], Sin[x]]


to x doesn't mean that they're not equal:

Plot[myArcTan[Cos[x], Sin[x]], {x, 0, 2 Pi}]


In fact, if we make the substitution y = x - Pi before Simplifying:

Simplify[myArcTan[Cos[x], Sin[x]] /. {x -> y + Pi}, -Pi < y < Pi] /. {y -> x - Pi}
(* x *)


We can see that your expression is indeed what you wanted.