The Excel ATAN2 Function

Related Functions:
ATAN Function
TAN Function
Arctangent

The Arctangent is the inverse of the tangent.

Therefore, for the simple right-angled triangle below, the arctangent of the opposite side, o, divided by the adjacent side, a, is equal to the angle θ.

Right-Angled Triangle

I.e. for the triangle above,

Arctangent Equation
The Inverse trig. functions are discussed further on the Wikipedia Inverse Trigonometric Functions Page

Function Description

The Excel ATAN2 function calculates the arctangent (i.e. the inverse tangent) of a given set of x and y coordinates, and returns an angle, in radians, between -π/2 and +π/2.

The syntax of the function is:

ATAN2( x_num, y_num )

Where the x_num and y_num arguments are the x- and y- coordinates of the point that you want to calculate the arctangent of.

Note: the angle returned from the Atan2 function may be positive (representing a counterclockwise angle from the x-axis), or negative (representing a clockwise angle from the x-axis). This result is given in radians.

Converting from Radians to Degrees

If you want the angle returned by the Atan2 function to be expressed in degrees, you can convert it, using the Excel Degrees function:

=DEGREES( radians )
An example of this is provided below.

Excel Atan2 Function Examples

Column A of the following spreadsheet shows examples of the Excel Atan2 Function, used to calculate the arctangent of different x- and y- coordinates.

 Formulas:
  A
1 =ATAN2( 1, 1 )
2 =ATAN2( 1, -1 )
3 =ATAN2( 4, 0 )
4 =DEGREES( ATAN2( 1, 1 ) )
 Results:
  A B
1 0.785398163 - Result is π/4 radians
2 -0.785398163 - Result is -π/4 radians
3 0 - Result is 0 radians
4 45 - Result is 45 degrees

Note that in the example in cell A4, the Excel Degrees function is used to convert the calculated angle from radians to degrees.


For further information and examples of the Excel Atan2 function, see the Microsoft Office website.


Atan2 Function Common Errors

If you get an error from the Excel Atan2 Function, this is likely to be one of the following:

Common Errors
#DIV/0! - Occurs if the supplied x_num and y_num arguments are both equal to 0.
#VALUE! - Occurs if one or both of the supplied arguments are non-numeric.