BREAKING NEWS
Atan2

## Summary

atan2(y, x) returns the angle θ between the ray to the point (x, y) and the positive x axis, confined to (−π, π].
Graph of ${\displaystyle \operatorname {atan2} (y,x)}$ over ${\displaystyle y/x}$

The function ${\displaystyle \operatorname {atan2} (y,x)}$ or ${\displaystyle \operatorname {arctan2} (y,x)}$ (from "2-argument arctangent") is defined as the angle in the Euclidean plane, given in radians, between the positive x axis and the ray to the point (x, y) ≠ (0, 0).

The function ${\displaystyle \operatorname {atan2} (y,x)}$ first appeared in the programming language Fortran (in IBM's implementation FORTRAN-IV in 1961). It was originally intended to return a correct and unambiguous value for the angle θ in converting from cartesian coordinates (x, y) to polar coordinates (r, θ).

Equivalently, ${\displaystyle \operatorname {atan2} (y,x)}$ is the argument (also called phase or angle) of the complex number ${\displaystyle x+iy.}$

${\displaystyle \operatorname {atan2} (y,x)}$ returns a single value θ such that π < θπ and, for some r > 0,

{\displaystyle {\begin{aligned}x&=r\cos \theta ,\\y&=r\sin \theta .\end{aligned}}}

While it is true that ${\textstyle r={\sqrt {x^{2}+y^{2}}}}$, the following equivalence does not always hold:

${\displaystyle \theta =\arctan \left({\frac {y}{x}}\right).}$

This only holds when x > 0. When x < 0, the angle apparent from the expression above is pointing in the opposite direction of the correct angle, and a value of π (or 180°) must be either added or subtracted from θ to put the Cartesian point (x, y) into the correct quadrant of the Euclidean plane.[1] This requires knowledge of the signs of x and y separately, which is lost when y is divided by x.

Since any integer multiple of 2π can be added to the angle θ without changing either x or y, implying an ambiguous value for the returned value, the principal value of the angle, in the (left open, right closed) interval (−π, π] is returned. θ is signed, with counterclockwise angles being positive, and clockwise being negative. In other words, ${\displaystyle \operatorname {atan2} (y,x)}$ is in the closed interval [0, π] when y ≥ 0, and in the open interval (−π, 0) when y < 0.

## History and motivation

Graph of the tangent function from −π to +π with the corresponding signs of y/x. The green arrows point to the results of atan2(−1, −1) and atan2(1, 1).

The atan2 function was first introduced in computer programming languages, but now it is also common in other fields of science and engineering. It dates back at least as far as the FORTRAN programming language[2] and is currently found in many modern programming languages. Among these languages are: C's math.h standard library, the Java Math library, .NET's System.Math (usable from C#, VB.NET, etc.), the Python math module, the Ruby Math module, the Go math package[3] and elsewhere. In addition, many scripting languages, such as Perl, include the C-style atan2(y, x) function.

The single-argument arctangent function cannot distinguish between diametrically opposite directions. For example, the anticlockwise angle from the x axis to the vector (1, 1), calculated in the usual way as arctan(1/1), is π/4 (radians), or 45°. However, the angle between the x axis and the vector (−1, −1) appears, by the same method, to be arctan(−1/−1), again π/4, even though one might expect the answers −3π/4 (−135°) or 5π/4 (225°). In addition, an attempt to find the angle between the x axis and the vectors (0, y), y ≠ 0 requires evaluation of arctan(y/0), which fails on division by zero.

The atan2 function calculates one unique arc tangent value from two variables y and x, where the signs of both arguments are used to determine the quadrant of the result, thereby selecting the desired branch of the arc tangent of y/x, e.g., atan2(1, 1) = π/4 and atan2(−1, −1) = −3π/4. Similarly, e.g., atan2(1, 0) = π/2.

When calculations are performed manually, the necessary quadrant corrections and exception handling can be done by inspection, but it is more useful to have a single function that always gives an unambiguous correct result. The atan2 function is useful in many applications involving vectors in Euclidean space, such as finding the direction from one point to another. A principal use is in computer graphics rotations, for converting rotation matrix representations into Euler angles.

Historical remark

In 1966 the FORTRAN people have chosen the sequence of arguments (y,x) although there is no doubt that they address the (x,y)-cartesian plain and although the +x-axis plays the prominent role of the so-called polar axis in that all (x,y)-arguments on it are intended to yield the result 0. Most probably their choice is a reminiscent of the sequence in the quotient y/x, although they could equally well have thought of x−1y.

## Definition and computation

The function atan2 computes the principal value of the argument function applied to the complex number x + yi. That is, atan2(yx) = Pr arg(x + yi) = Arg(x + yi). The argument could be changed by an arbitrary multiple of (corresponding to a complete turn around the origin) without making any difference to the angle, but to define atan2 uniquely one uses the principal value in the range ${\displaystyle (-\pi ,\pi ]}$, that is, π < atan2(yx) ≤ π.

In terms of the standard arctan function, whose range is (−π/2, π/2), it can be expressed as follows:

${\displaystyle \operatorname {atan2} (y,x)={\begin{cases}\arctan({\frac {y}{x}})&{\text{if }}x>0,\\\arctan({\frac {y}{x}})+\pi &{\text{if }}x<0{\text{ and }}y\geq 0,\\\arctan({\frac {y}{x}})-\pi &{\text{if }}x<0{\text{ and }}y<0,\\+{\frac {\pi }{2}}&{\text{if }}x=0{\text{ and }}y>0,\\-{\frac {\pi }{2}}&{\text{if }}x=0{\text{ and }}y<0,\\{\text{undefined}}&{\text{if }}x=0{\text{ and }}y=0.\end{cases}}}$

A compact expression with four overlapping half-planes is

${\displaystyle \operatorname {atan2} (y,x)={\begin{cases}\arctan \left({\frac {y}{x}}\right)&{\text{if }}x>0,\\{\frac {\pi }{2}}-\arctan \left({\frac {x}{y}}\right)&{\text{if }}y>0,\\-{\frac {\pi }{2}}-\arctan \left({\frac {x}{y}}\right)&{\text{if }}y<0,\\\arctan \left({\frac {y}{x}}\right)\pm \pi &{\text{if }}x<0,\\{\text{undefined}}&{\text{if }}x=0{\text{ and }}y=0.\end{cases}}}$

The Iverson bracket notation allows for an even more compact expression:

 ${\displaystyle \operatorname {atan2} (y,x)}$ ${\displaystyle =\arctan \left({\frac {y}{x}}\right)[x\neq 0]+(1-2[y<0])\left(\pi [x<0]+{\frac {\pi }{2}}[x=0]\right)}$ ${\displaystyle +\;{\text{undefined}}\;\![x=0\wedge y=0]}$ [note 1]

Formula without apparent conditional construct:

${\displaystyle \operatorname {atan2} (y,x)=\operatorname {sgn}(x)^{2}\arctan \left({\frac {y}{x}}\right)+{\frac {1-\operatorname {sgn}(x)}{2}}\left(1+\operatorname {sgn}(y)-\operatorname {sgn}(y)^{2}\right)\pi }$

The following expression derived from the tangent half-angle formula can also be used to define atan2:

${\displaystyle \operatorname {atan2} (y,x)={\begin{cases}2\arctan \left({\frac {y}{{\sqrt {x^{2}+y^{2}}}+x}}\right)&{\text{if }}x>0{\text{ or }}y\neq 0,\\\pi &{\text{if }}x<0{\text{ and }}y=0,\\{\text{undefined}}&{\text{if }}x=0{\text{ and }}y=0.\end{cases}}}$

This expression may be more suited for symbolic use than the definition above. However it is unsuitable for general floating-point computational use, as the effect of rounding errors in ${\displaystyle {\sqrt {x^{2}+y^{2}}}}$ expand near the region x < 0, y = 0 (this may even lead to a division of y by zero).

A variant of the last formula that avoids these inflated rounding errors:

${\displaystyle \operatorname {atan2} (y,x)={\begin{cases}2\arctan \left({\frac {y}{{\sqrt {x^{2}+y^{2}}}+x}}\right)&{\text{if }}x>0,\\2\arctan \left({\frac {{\sqrt {x^{2}+y^{2}}}-x}{y}}\right)&{\text{if }}x\leq 0{\text{ and }}y\neq 0,\\\pi &{\text{if }}x<0{\text{ and }}y=0,\\{\text{undefined}}&{\text{if }}x=0{\text{ and }}y=0.\end{cases}}}$
The derivation of the principal value of the argument refers to this figure

Notes:

• This produces results in the range (−π, π].[note 2]
• As mentioned above, the principal value of the argument atan2(yx) can be related to arctan(y/x) by trigonometry. The derivation goes as follows:
If (xy) = (r cos θ, r sin θ), then tan(θ/2) = y / (r + x). It follows that
${\displaystyle {\text{atan2}}(y,x)=\theta =2\,\theta /2=2\arctan {\frac {y}{{\sqrt {x^{2}+y^{2}}}+x}}.}$
Note that x2 + y2 + x ≠ 0 in the domain in question.

## Derivative

As the function atan2 is a function of two variables, it has two partial derivatives. At points where these derivatives exist, atan2 is, except for a constant, equal to arctan(y/x). Hence for x > 0 or y ≠ 0,

{\displaystyle {\begin{aligned}&{\frac {\partial }{\partial x}}\operatorname {atan2} (y,\,x)={\frac {\partial }{\partial x}}\arctan \left({\frac {y}{x}}\right)=-{\frac {y}{x^{2}+y^{2}}},\\[5pt]&{\frac {\partial }{\partial y}}\operatorname {atan2} (y,\,x)={\frac {\partial }{\partial y}}\arctan \left({\frac {y}{x}}\right)={\frac {x}{x^{2}+y^{2}}}.\end{aligned}}}

Thus the gradient of atan2 is given by

${\displaystyle \nabla {\text{atan2}}(y,x)=\left({-y \over x^{2}+y^{2}},\ {x \over x^{2}+y^{2}}\right).}$

Informally representing the function atan2 as the angle function θ(x, y) = atan2(y, x) (which is only defined up to a constant) yields the following formula for the total differential:

{\displaystyle {\begin{aligned}\mathrm {d} \theta &={\frac {\partial }{\partial x}}\operatorname {atan2} (y,\,x)\,\mathrm {d} x+{\frac {\partial }{\partial y}}\operatorname {atan2} (y,\,x)\,\mathrm {d} y\\[5pt]&=-{\frac {y}{x^{2}+y^{2}}}\,\mathrm {d} x+{\frac {x}{x^{2}+y^{2}}}\,\mathrm {d} y.\end{aligned}}}

While the function atan2 is discontinuous along the negative x-axis, reflecting the fact that angle cannot be continuously defined, this derivative is continuously defined except at the origin, reflecting the fact that infinitesimal (and indeed local) changes in angle can be defined everywhere except the origin. Integrating this derivative along a path gives the total change in angle over the path, and integrating over a closed loop gives the winding number.

In the language of differential geometry, this derivative is a one-form, and it is closed (its derivative is zero) but not exact (it is not the derivative of a 0-form, i.e., a function), and in fact it generates the first de Rham cohomology of the punctured plane. This is the most basic example of such a form, and it is fundamental in differential geometry.

The partial derivatives of atan2 do not contain trigonometric functions, making it particularly useful in many applications (e.g. embedded systems) where trigonometric functions can be expensive to evaluate.

## Illustrations

atan2 for selected rays

This figure shows values of atan2 along selected rays from the origin, labelled at the unit circle. The values, in radians, are shown inside the circle. The diagram uses the standard mathematical convention that angles increase counterclockwise from zero along the ray to the right. Note that the order of arguments is reversed; the function atan2(y, x) computes the angle corresponding to the point (x, y).

Comparison of arctan and atan2 functions

This figure shows the values of ${\displaystyle \arctan(\tan(\theta ))}$ along with ${\displaystyle \operatorname {atan2} (\sin(\theta ),\cos(\theta ))}$ for ${\displaystyle 0\leq \theta \leq 2\pi }$. Both functions are odd and periodic with periods ${\displaystyle \pi }$ and ${\displaystyle 2\pi }$, respectively, and thus can easily be supplemented to any region of real values of ${\displaystyle \theta }$. One can clearly see the branch cuts of the ${\displaystyle \operatorname {atan2} }$-function at ${\displaystyle \theta =\pi }$, and of the ${\displaystyle \arctan }$-function at ${\displaystyle \theta \in \{{\tfrac {\pi }{2}},\;{\tfrac {3\pi }{2}}\}}$.[4]

The two figures below show 3D views of respectively atan2(y, x) and arctan(y/x) over a region of the plane. Note that for atan2(y, x), rays in the X/Y-plane emanating from the origin have constant values, but for arctan(y/x) lines in the X/Y-plane passing through the origin have constant values. For x > 0, the two diagrams give identical values.

## Angle sum and difference identity

Sums of ${\displaystyle \operatorname {atan2} }$ may be collapsed into a single operation according to the following identity

${\displaystyle \operatorname {atan2} (y_{1},x_{1})\pm \operatorname {atan2} (y_{2},x_{2})=\operatorname {atan2} (y_{1}x_{2}\pm y_{2}x_{1},x_{1}x_{2}\mp y_{1}y_{2})}$

...provided that ${\displaystyle \operatorname {atan2} (y_{1},x_{1})\pm \operatorname {atan2} (y_{2},x_{2})\in (-\pi ,\pi ]}$.

The proof involves considering two cases, one where ${\displaystyle y_{2}\neq 0}$ or ${\displaystyle x_{2}>0}$ and one where ${\displaystyle y_{2}=0}$ and ${\displaystyle x_{2}<0}$.

We only consider the case where ${\displaystyle y_{2}\neq 0}$ or ${\displaystyle x_{2}>0}$. To start, we make the following observations:

1. ${\displaystyle -\operatorname {atan2} (y,x)=\operatorname {atan2} (-y,x)}$ provided that ${\displaystyle y\neq 0}$ or ${\displaystyle x>0}$.
2. ${\displaystyle \operatorname {Arg} (x+iy)=\operatorname {atan2} (y,x)}$, where ${\displaystyle \operatorname {Arg} }$ is the complex argument function.
3. ${\displaystyle \theta =\operatorname {Arg} e^{i\theta }}$ whenever ${\displaystyle \theta \in (-\pi ,\pi ]}$, a consequence of Euler's formula.
4. ${\displaystyle \operatorname {Arg} (e^{i\operatorname {Arg} \zeta _{1}}e^{i\operatorname {Arg} \zeta _{2}})=\operatorname {Arg} (\zeta _{1}\zeta _{2})}$.

To see (4), we have the identity ${\displaystyle e^{i\operatorname {Arg} \zeta }={\bar {\zeta }}}$ where ${\displaystyle {\bar {\zeta }}=\zeta /\left|\zeta \right|}$, hence ${\displaystyle \operatorname {Arg} (e^{i\operatorname {Arg} \zeta _{1}}e^{i\operatorname {Arg} \zeta _{2}})=\operatorname {Arg} ({\bar {\zeta _{1}}}{\bar {\zeta _{2}}})}$. Furthermore, since ${\displaystyle \operatorname {Arg} \zeta =\operatorname {Arg} a\zeta }$ for any positive real value ${\displaystyle a}$, then if we let ${\displaystyle \zeta =\zeta _{1}\zeta _{2}}$ and ${\displaystyle a={\frac {1}{\left|\zeta _{1}\right|\left|\zeta _{2}\right|}}}$ then we have ${\displaystyle \operatorname {Arg} ({\bar {\zeta _{1}}}{\bar {\zeta _{2}}})=\operatorname {Arg} (\zeta _{1}\zeta _{2})}$.

From these observations have following equivalences:

{\displaystyle {\begin{aligned}\operatorname {atan2} (y_{1},x_{1})\pm \operatorname {atan2} (y_{2},x_{2})&{}=\operatorname {atan2} (y_{1},x_{1})+\operatorname {atan2} (\pm y_{2},x_{2})&{\text{by (1)}}\\&{}=\operatorname {Arg} (x_{1}+iy_{1})+\operatorname {Arg} (x_{2}\pm iy_{2})&{\text{by (2)}}\\&{}=\operatorname {Arg} e^{i(\operatorname {Arg} (x_{1}+iy_{1})+\operatorname {Arg} (x_{2}\pm iy_{2}))}&{\text{by (3)}}\\&{}=\operatorname {Arg} (e^{i\operatorname {Arg} (x_{1}+iy_{1})}e^{i\operatorname {Arg} (x_{2}\pm iy_{2})})\\&{}=\operatorname {Arg} ((x_{1}+iy_{1})(x_{2}\pm iy_{2}))&{\text{by (4)}}\\&{}=\operatorname {Arg} (x_{1}x_{2}\mp y_{1}y_{2}+i(y_{1}x_{2}\pm y_{2}x_{1}))\\&{}=\operatorname {atan2} (y_{1}x_{2}\pm y_{2}x_{1},x_{1}x_{2}\mp y_{1}y_{2})&{\text{by (2)}}\end{aligned}}}

Corollary: if ${\displaystyle (y_{1},x_{1})}$ and ${\displaystyle (y_{2},x_{2})}$ are 2-dimensional vectors, the difference formula is frequently used in practice to compute the angle between those vectors with the help of ${\displaystyle \operatorname {atan2} }$, since the resulting computation behaves benign in the range ${\displaystyle (-\pi ,\pi ]}$ and can thus be used without range checks in many practical situations.

## East-counterclockwise, north-clockwise and south-clockwise conventions, etc.

The ${\displaystyle \mathrm {atan2} }$ function was originally designed for the convention in pure mathematics that can be termed east-counterclockwise. In practical applications, however, the north-clockwise and south-clockwise conventions are often the norm. In atmospheric sciences, for instance, the wind direction can be calculated using the ${\displaystyle \mathrm {atan2} }$ function with the east- and north-components of the wind vector as its arguments;[5] the solar azimuth angle can be calculated similarly with the east- and north-components of the solar vector as its arguments. The wind direction is normally defined in the north-clockwise sense, and the solar azimuth angle uses both the north-clockwise and south-clockwise conventions widely.[6] These different conventions can be realized by swapping the positions and changing the signs of the x- and y-arguments as follows:

• ${\displaystyle \mathrm {atan2} (y,x),\;\;\;\;\;}$ (East-Counterclockwise Convention)
• ${\displaystyle \mathrm {atan2} (x,y),\;\;\;\;\;}$ (North-Clockwise Convention)
• ${\displaystyle \mathrm {atan2} (-x,-y)}$. (South-Clockwise Convention)

As an example, let ${\displaystyle x_{0}={\frac {\sqrt {3}}{2}}}$ and ${\displaystyle y_{0}={\frac {1}{2}}}$, then the east-counterclockwise format gives ${\displaystyle \mathrm {atan2} (y_{0},x_{0})\cdot {\frac {180}{\pi }}=30^{\circ }}$, the north-clockwise format gives ${\displaystyle \mathrm {atan2} (x_{0},y_{0})\cdot {\frac {180}{\pi }}=60^{\circ }}$, and the south-clockwise format gives ${\displaystyle \mathrm {atan2} (-x_{0},-y_{0})\cdot {\frac {180}{\pi }}=-120^{\circ }}$.

Apparently, changing the sign of the x- and/or y-arguments and swapping their positions can create 8 possible variations of the ${\displaystyle \mathrm {atan2} }$ function and they, interestingly, correspond to 8 possible definitions of the angle, namely, clockwise or counterclockwise starting from each of the 4 cardinal directions, north, east, south and west.

## Realizations of the function in common computer languages

The realization of the function differs from one computer language to another:

• The C function atan2, and most other computer implementations, are designed to reduce the effort of transforming cartesian to polar coordinates and so always define atan2(0, 0). On implementations without signed zero, or when given positive zero arguments, it is normally defined as 0. It will always return a value in the range [−π, π] rather than raising an error or returning a NaN (Not a Number).
• In Common Lisp, where optional arguments exist, the atan function allows one to optionally supply the x coordinate: (atan y x).[7]
• In Julia, the situation is similar to Common Lisp: instead of atan2, the language has a one-parameter and a two-parameter form for atan.[8] However, it has many more than two methods, to allow for aggressive optimisation at compile time (see the section "Why don't you compile Matlab/Python/R/… code to Julia?" [9]).
• In Mathematica, the form ArcTan[x, y] is used where the one parameter form supplies the normal arctangent (note that the order of arguments is reversed relative to the convention used in the discussion above). Mathematica classifies ArcTan[0, 0] as an indeterminate expression.
• In Microsoft Excel,[10] OpenOffice.org Calc, LibreOffice Calc,[11] Google Spreadsheets,[12] iWork Numbers,[13] and ANSI SQL:2008 standard,[14] the atan2 function has the two arguments reversed.
• In the Intel Architecture assembler code, atan2 is known as the FPATAN (floating-point partial arctangent) instruction.[15] It can deal with infinities and results lie in the closed interval [−π, π], e.g. atan2(∞, x) = +π/2 for finite x. Particularly, FPATAN is defined when both arguments are zero:
atan2(+0, +0) = +0;
atan2(+0, −0) = +π;
atan2(−0, +0) = −0;
atan2(−0, −0) = −π.
This definition is related to the concept of signed zero.
• On most TI graphing calculators (excluding the TI-85 and TI-86), the equivalent function is called R►Pθ and has the arguments reversed.
• On TI-85 the arg function is called angle(x,y) and although it appears to take two arguments, it really only has one complex argument which is denoted by a pair of numbers: x + yi = (x, y).
• In mathematical writings other than source code, such as in books and articles, the notations Arctan[16] and Tan−1[17] have been utilized; these are capitalized variants of the regular arctan and tan−1. This usage is consistent with the complex argument notation, such that Atan(y, x) = Arg(x + yi).
• On HP calculators, treat the coordinates as a complex number and then take the ARG. Or << C->R ARG >> 'ATAN2' STO.
• On scientific calculators the function can often be calculated as the angle given when (x, y) is converted from rectangular coordinates to polar coordinates.
• Systems supporting symbolic mathematics normally return an undefined value for atan2(0, 0) or otherwise signal that an abnormal condition has arisen.
• For systems implementing signed zero, infinities, or Not a Number (for example, IEEE floating point), it is common to implement reasonable extensions which may extend the range of values produced to include −π and −0. These also may return NaN or raise an exception when given a NaN argument.
• For systems implementing signed zero (for example, IEEE floating point), atan2(−0, x), x < 0 poses the risk of returning the value −π, in the case where the implementation of atan2(y, x) fails to properly handle −0 inputs.
• The free math library FDLIBM (Freely Distributable LIBM) available from netlib has source code showing how it implements atan2 including handling the various IEEE exceptional values.
• For systems without a hardware multiplier the function atan2 can be implemented in a numerically reliable manner by the CORDIC method. Thus implementations of atan(y) will probably choose to compute atan2(y, 1).

## References

1. ^ http://scipp.ucsc.edu/~haber/ph116A/arg_11.pdf
2. ^ Organick, Elliott I. (1966). A FORTRAN IV Primer. Addison-Wesley. p. 42. Some processors also offer the library function called ATAN2, a function of two arguments (opposite and adjacent).
3. ^ "src/math/atan2.go". The Go Programming Language. Retrieved 20 April 2018.
4. ^ "Wolf Jung: Mandel, software for complex dynamics". www.mndynamics.com. Retrieved 20 April 2018.
5. ^ Wind Direction Quick Reference, NCAR UCAR Earth Observing Laboratory. https://www.eol.ucar.edu/content/wind-direction-quick-reference
6. ^ Zhang, Taiping; Stackhouse, Paul W.; MacPherson, Bradley; Mikovitz, J. Colleen (2021). "A solar azimuth formula that renders circumstantial treatment unnecessary without compromising mathematical rigor: Mathematical setup, application and extension of a formula based on the subsolar point and atan2 function". Renewable Energy. 172: 1333–1340. doi:10.1016/j.renene.2021.03.047. S2CID 233631040.
7. ^ "CLHS: Function ASIN, ACOS, ATAN". LispWorks.
8. ^ "Mathematics · The Julia Language". docs.julialang.org.
9. ^ "Frequently Asked Questions · The Julia Language". docs.julialang.org.
10. ^ "Microsoft Excel Atan2 Method". Microsoft.
11. ^ "LibreOffice Calc ATAN2". Libreoffice.org.
12. ^ "Functions and formulas – Docs Editors Help". support.google.com.
13. ^ "Numbers' Trigonometric Function List". Apple.
14. ^ "ANSI SQL:2008 standard". Teradata. Archived from the original on 2015-08-20.
15. ^ IA-32 Intel Architecture Software Developer’s Manual. Volume 2A: Instruction Set Reference, A-M, 2004.
16. ^ Burger, Wilhelm; Burge, Mark J. (7 July 2010). Principles of Digital Image Processing: Fundamental Techniques. Springer Science & Business Media. ISBN 978-1-84800-191-6. Retrieved 20 April 2018 – via Google Books.
17. ^ Glisson, Tildon H. (18 February 2011). Introduction to Circuit Analysis and Design. Springer Science & Business Media. ISBN 9789048194438. Retrieved 20 April 2018 – via Google Books.

• ATAN2 Online calculator
• atan2 at Everything2
• PicBasic Pro solution atan2 for a PIC18F
Other implementations/code for atan2
• Bearing Between Two Points
• Arctan and Polar Coordinates
• What's 'Arccos'?

## Notes

1. ^ Thereby
${\displaystyle {\text{undefined}}\cdot 0=0,}$
${\displaystyle {\text{undefined}}\cdot 1={\text{undefined}}}$   and
${\displaystyle z+{\text{undefined}}={\text{undefined}}}$   for every ${\displaystyle z.}$
2. ^ One can apply the periodicity of the result to map to another desired range, e.g. mapping to [0, 2π) by adding to the negative results.