Math & Trig

ATAN2 Formula

ATAN2 returns the arctangent of y/x using the signs of both arguments to determine the correct quadrant, giving angles in the full range -π to π (-180° to 180°). Unlike ATAN which only returns -90° to 90°, ATAN2 correctly handles all four quadrants. Use it for navigation bearings, direction calculations, and converting Cartesian to polar coordinates.

Syntax

ATAN2(x_num, y_num)
ParameterDescription
x_num Parameter of the ATAN2 function.
y_num Parameter of the ATAN2 function.
Try ATAN2 in Viztab — free, no signup

Examples

First quadrant

Formula
=DEGREES(ATAN2(1, 1))
Returns 45. The point (1,1) is at 45° from the positive x-axis.

Second quadrant

Formula
=DEGREES(ATAN2(-1, 1))
Returns 135. The point (-1,1) is in the second quadrant at 135°. ATAN(1/-1) would give -45°, which is wrong.

Navigation bearing

Formula
=MOD(DEGREES(ATAN2(east_displacement, north_displacement)), 360)
Converts x,y displacement to a compass bearing (0-360°). MOD handles the wrap-around from negative angles.

Common Errors

#DIV/0!

=ATAN2(0, 0) returns #DIV/0! because the angle is undefined at the origin.

#VALUE!

Non-numeric arguments return #VALUE!.

Tips

Argument order: x first, then y

In spreadsheets, ATAN2(x, y) has x first, unlike many programming languages where it's atan2(y, x). Double-check the order.

Full 360° range

ATAN2 distinguishes all four quadrants. ATAN(y/x) can't tell (1,1) from (-1,-1) — both give 45°. ATAN2 correctly gives 45° and -135°.

Cartesian to polar

Radius = SQRT(x²+y²), Angle = ATAN2(x, y). This pair converts any (x,y) point to polar coordinates (r, θ).

Try ATAN2 in Viztab

Import your data and use ATAN2 with 370+ other formulas. No signup required.

Open Viztab

Related Formulas