🚀The world's best VBA AI has evolved. ExcelMaster is now an autonomous Agent.Read more →
Back to Blog

Excel ATAN & ATAN2 — Inverse Tangent, Arctan & the Angle From X,Y

|

Excel ATAN & ATAN2 — Inverse Tangent, Arctan & the Angle From X,Y

TL;DRASIN, ACOS, ATAN and ATAN2 run trig backwards: give them a ratio (or a pair of coordinates) and they return the angle. They hand that angle back in radians, so wrap them in DEGREES() for a human value — =DEGREES(ATAN(1)) is 45. Use ATAN2 whenever you have x and y, because plain ATAN only sees the ratio and can't tell which quadrant you're in. And mind the trap: Excel's ATAN2(x_num, y_num) puts x first — the reverse of the atan2(y, x) order in every programming language.

=DEGREES(ATAN(1))          ' arctangent of 1, as a degree angle -> 45
=DEGREES(ATAN2(1, 1))      ' angle of the point (1, 1) -> 45
=DEGREES(ATAN2(-1, -1))    ' angle of (-1, -1) — ATAN cannot do this -> -135
=DEGREES(ASIN(0.5))        ' the angle whose sine is 0.5 -> 30

Ask for "inverse tan in Excel" and most pages hand you =ATAN(x) and move on. But the questions that actually bite — why the answer comes out as 0.785 instead of 45, when to use ATAN2 instead of ATAN, and why the argument order feels backwards — are the whole reason this function trips people up. This page leads with those.

What you'll learn

  • The mental model: forward trig consumes angles, inverse trig produces them
  • Why every inverse function returns radians (and needs DEGREES())
  • The core reason ATAN2 exists: ATAN can't see the quadrant
  • The famous gotcha: Excel's ATAN2(x, y) reverses the usual argument order
  • Getting a compass bearing / the angle between two points
  • Why ASIN and ACOS return #NUM! outside the range −1 to 1

The mental model: running trig backwards

SIN, COS and TAN take an angle and give you a ratio. The inverse functions do the exact opposite: they take a ratio and give you back the angle that produced it. SIN(30°) = 0.5, so ASIN(0.5) = 30°. They undo each other.

Two consequences fall straight out of that, and they cause nearly all the confusion:

  1. Since they produce an angle, and Excel's native angle unit is radians, their output is in radians. You almost always want DEGREES() around them.
  2. A single ratio doesn't uniquely identify an angle — several different angles share the same sine, cosine or tangent. So the inverse functions have to pick one, within a defined range, and that limitation is exactly what ATAN2 was invented to work around.

Hold those two ideas and the rest is detail.

They return radians — wrap them in DEGREES

Here's the first thing everyone hits:

=ATAN(1)             ' -> 0.785398163397448   (radians, not 45)
=DEGREES(ATAN(1))    ' -> 45                   (the degree you wanted)

ATAN(1) is correct — 0.785 radians is 45°, expressed in Excel's native unit. It just isn't the number a human reads as an angle. The fix is the mirror image of the forward rule: where SIN/COS/TAN need RADIANS() on the way in, the inverse functions need DEGREES() on the way out.

=DEGREES(ASIN(0.5))    ' angle whose sine is 0.5 -> 30
=DEGREES(ACOS(0.5))    ' angle whose cosine is 0.5 -> 60
=DEGREES(ATAN(1))      ' angle whose tangent is 1 -> 45

The whole degrees/radians dance is covered in the RADIANS & DEGREES guide; the one line to remember here is DEGREES() reads the result of an inverse function.

Why ATAN2 exists: ATAN can't see the quadrant

This is the heart of the topic. ATAN receives a single number — a ratio like y/x. But the same ratio describes two different directions. The point (1, 1) and the point (−1, −1) both have y/x = 1, yet they point in opposite directions (northeast vs southwest, 45° vs −135°). ATAN sees only the 1 and has no way to tell them apart:

=DEGREES(ATAN(1/1))     ' point (1, 1)   -> 45
=DEGREES(ATAN(-1/-1))   ' point (-1,-1)  -> 45   (WRONG — should be -135)

ATAN always answers in the range −90° to 90° (the right half of the plane), because that's all a lone ratio can pin down. ATAN2 fixes this by taking the x and y separately, so it knows which quadrant the point is in and can return the full −180° to 180° range:

=DEGREES(ATAN2(1, 1))     ' -> 45     (northeast)
=DEGREES(ATAN2(-1, -1))   ' -> -135   (southwest — now correct)
=DEGREES(ATAN2(-1, 1))    ' -> 135    (northwest)
=DEGREES(ATAN2(1, -1))    ' -> -45    (southeast)

The rule that follows: the moment you have an x and a y — coordinates, a velocity, a displacement — reach for ATAN2, never ATAN(y/x). Plain ATAN is only safe when you genuinely have a bare slope with no direction attached.

The gotcha: Excel's ATAN2 reverses the argument order

Here's the trap that catches every programmer. In C, Python, JavaScript, Java — essentially every language — the function is atan2(y, x) with y first. Excel does the opposite: it's ATAN2(x_num, y_num) with x first.

=ATAN2(x_num, y_num)     ' Excel: X first, then Y
' atan2(y, x)            ' every programming language: Y first, then X

So a formula ported straight from code — or from a colleague who lives in Python — will have the arguments swapped, and it fails in a nasty way: it doesn't error, it just returns the complementary angle, which can look plausible. If an ATAN2 result is reflected about the 45° line from what you expect, check the argument order first. When in doubt, remember Excel reads it left-to-right as "across, then up" — x, then y.

A real use: bearing / angle between two points

The classic job for ATAN2 is the angle (or compass bearing) from one point to another. Given a start (x1, y1) and an end (x2, y2), the direction is:

=DEGREES(ATAN2(x2-x1, y2-y1))    ' angle of the line from point 1 to point 2
=MOD(DEGREES(ATAN2(x2-x1, y2-y1)), 360)   ' same, normalised to 0-360 degrees

The MOD(..., 360) turns ATAN2's −180…180 output into a friendly 0…360 compass value if that's what you need. This one formula — with ATAN2, not ATAN — is what powers heading calculations, wind directions, and "which way is that from here" across mapping and engineering sheets.

ASIN and ACOS: domain is −1 to 1, or #NUM!

Sine and cosine only ever produce values between −1 and 1, so their inverses can only accept values in that range. Ask for the angle whose sine is 2 and there isn't one — Excel returns #NUM!:

=DEGREES(ASIN(0.5))    ' -> 30
=DEGREES(ACOS(-1))     ' -> 180
=ASIN(2)               ' no angle has a sine of 2 -> #NUM!
=ACOS(1.5)             ' out of range -> #NUM!

A #NUM! from ASIN or ACOS almost always means an upstream value drifted outside −1…1 — often a ratio that should be ≤ 1 but landed at 1.0000001 through floating-point rounding. When that's the cause, clamp it: =ASIN(MIN(1, MAX(-1, ratio))). ATAN and ATAN2, by contrast, accept any input — a tangent can be any real number — so they never throw #NUM! for domain reasons.

How ExcelMaster helps

Inverse trig fails in two quiet ways: an answer in radians that you read as degrees, and an ATAN where an ATAN2 was needed. Ask ExcelMaster "get me the angle from point A to point B" and it builds =DEGREES(ATAN2(x2-x1, y2-y1)) — the right function, the right argument order, the DEGREES() already wrapped. Paste an ATAN2 you ported from Python and it flags the reversed arguments before they produce a mirror-image bearing. Hand it a #NUM! from ASIN and it traces the out-of-range input.

Frequently asked questions

How do I do inverse tan (arctan) in Excel?

Use ATAN for a bare ratio or ATAN2 for x/y coordinates, then convert to degrees: =DEGREES(ATAN(1)) returns 45. ATAN alone returns radians, so the DEGREES() wrapper is what gives you a readable angle.

What's the difference between ATAN and ATAN2 in Excel?

ATAN takes a single ratio and returns an angle from −90° to 90°, so it can't tell which quadrant a point is in. ATAN2 takes x and y separately and returns the full −180° to 180° angle. Whenever you have both coordinates, use ATAN2.

Why does Excel's ATAN2 seem to have the arguments backwards?

Because Excel uses ATAN2(x_num, y_num) with x first, while C, Python, JavaScript and most programming languages use atan2(y, x) with y first. A formula copied from code will have them swapped. Read Excel's order as "across, then up" — x, then y.

Why is ASIN or ACOS giving me a #NUM! error?

Because their input must be between −1 and 1 (the only values a sine or cosine can take). Anything outside that range has no valid angle, so Excel returns #NUM!. It's often a rounding artefact — a value that should be ≤ 1 landing at 1.0000001 — which you can clamp with =ASIN(MIN(1, MAX(-1, x))).

How do I find the angle between two points in Excel?

Use ATAN2 on the coordinate differences and wrap it in DEGREES(): =DEGREES(ATAN2(x2-x1, y2-y1)). Add MOD(..., 360) if you want a 0–360° compass bearing instead of the −180…180 range ATAN2 returns.

Tested in

Tested in: Excel 365 (Windows 11) — last verified 2026-07-24.

Related guides: Excel SIN, COS & TAN · Excel RADIANS & DEGREES · Excel POWER & SQRT · Excel ABS & SIGN · Excel MOD (INT, TRUNC)