%mathpiper,def="ArcTan"

5 # (ArcTan(x_IsConstant))_(IsNegativeNumber(N(Eval(x))))   <-- -ArcTan(-x);

//TODO fix! 4 # ArcTan(Tan(_x))           <-- x;
4 # ArcTan(-Tan(_x))           <-- -ArcTan(Tan(x));
110 # ArcTan(Complex(_r,_i)) <--
     (- I*0.5)*Ln(Complex(1,Complex(r,i))/ Complex(1, - Complex(r,i)));

150 # ArcTan(- _x)_(Not IsConstant(x))             <-- -ArcTan(x);
160 # (ArcTan(x_IsConstant))_(IsNegativeNumber(N(Eval(x)))) <-- -ArcTan(-x);

200 # ArcTan(Sqrt(3)) <-- Pi/3;
200 # ArcTan(-Sqrt(3)) <-- -Pi/3;
200 # ArcTan(1) <-- Pi/4;
200 # ArcTan(0) <-- 0;
200 # ArcTan(_n)_(n = -1) <-- -Pi/4;

200 # ArcTan(Infinity) <-- Pi/2;
200 # ArcTan(-Infinity) <-- -Pi/2;
200 # ArcTan(Undefined) <-- Undefined;

ArcTan(xlist_IsList) <-- MapSingle("ArcTan",xlist);

2 # ArcTan(x_IsNumber)_InNumericMode() <-- ArcTanNum(x);


%/mathpiper



%mathpiper_docs,name="ArcTan",categories="User Functions;Trigonometry (Symbolic)"
*CMD ArcTan --- inverse trigonometric function arc-tangent
*STD
*CALL
	ArcTan(x)

*PARMS

{x} -- argument to the function

*DESC

This function represents the inverse trigonometric function arctangent. For
instance, the value of $ArcTan(x)$ is a number $y$ such that
$Tan(y)$ equals $x$.

Note that the number $y$ is not unique. For instance, $Tan(0)$ and
$Tan(2*Pi)$ both equal 0, so what should $ArcTan(0)$ be? In MathPiper,
it is agreed that the value of $ArcTan(x)$ should be in the interval
[-$Pi$/2,$Pi$/2]. 

Usually, MathPiper leaves this function alone unless it is forced to do
a numerical evaluation by the {N} function. MathPiper will try to simplify
as much as possible while keeping the result exact. If the argument is 
complex,  the expression will be rewritten using the {Ln} function.

This function is threaded, meaning that if the argument {x} is a
list, the function is applied to all entries in the list.

*E.G.

In> ArcTan(1)
Result: Pi/4

In> ArcTan(1/3)
Result: ArcTan(1/3)
In> Tan(ArcTan(1/3))
Result: 1/3

In> x:=N(ArcTan(0.75))
Result: 0.643501108793285592213351264945231378078460693359375
In> N(Tan(x))
Result: 0.75

*SEE Sin, Cos, Tan, N, Pi, Ln, ArcSin, ArcCos
%/mathpiper_docs