ATAN2 function

ATAN2 returns the arctangent (inverse tangent) of y/x in radians, accounting for quadrant; use it for angle calculations in coordinate systems.

=ATAN2(x_num, y_num)

Generate a ATAN2 formula

Describe what you need. The generator will reach for ATAN2 where ATAN2 is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How ATAN2 reads its arguments
x_numrequiredy_numrequiredATAN2
ArgumentRequiredDescription
x_numRequiredThe x-coordinate value (denominator in y/x). Can be positive, negative, or zero; when both x_num and y_num are zero, returns #DIV/0!.
y_numRequiredThe y-coordinate value (numerator in y/x). Can be positive, negative, or zero; when both y_num and x_num are zero, returns #DIV/0!.

Returns

A number representing an angle in radians, ranging from -π (−3.14159…) to π (3.14159…).

Availability

Excel: All · Google Sheets: Supported

Worked examples

1. Calculate angle to ingredient storage location

IngredientSupplierUnitQtyExpiryStorage XStorage Y
Olive OilSupplier AL152026-12-3183
TomatoesSupplier Bkg422026-09-25127
BasilSupplier Dbunch242026-09-1852
=ATAN2(2, 5)

Result: 0.3805

For Basil stored at coordinates (5, 2) in the kitchen, ATAN2(2, 5) returns 0.3805 radians (~21.8°). This angle represents the bearing from a central reference point to the Basil's storage bin, helping staff navigate ingredient locations quickly during service.

2. Determine restocking priority based on quantity vs usage rate

IngredientSupplierUnitQtyExpiryDaily Usage
Olive OilSupplier AL152026-12-312
TomatoesSupplier Bkg422026-09-259
BasilSupplier Dbunch242026-09-184
=ATAN2(9, 42)

Result: 0.2107

For Tomatoes with qty=42 and daily usage=9, ATAN2(9, 42) returns 0.2107 radians (~12.1°). This maps inventory into a 2D priority matrix where items with high usage and lower stock produce larger angles (approaching π/2), flagging them for urgent reordering.

3. Calculate compass bearing angle to supplier location

SupplierRegionLatitude OffsetLongitude OffsetDistance (km)
Supplier ALocal Market30457.2
Supplier BRegional Hub156011.3
Supplier DFarm50209.8
=ATAN2(45, 30)

Result: 0.9828

Supplier A's coordinates are (30, 45) relative to the restaurant. ATAN2(45, 30) returns 0.9828 radians (~56.3°), which is the compass bearing to their location. Combined with distance data, this optimizes delivery route planning across multiple suppliers.

Common errors

Which ATAN2 error are you seeing?
ATAN2 returned an error#VALUE!
Reference numeric columns only. Use =ATAN2(D2, C2) where columns C and D contain numbers, not =ATAN2(A2, B2) if columns A and B contain ingredient or supplier names.
#DIV/0!
Add a guard clause: =IF(AND(x_num=0, y_num=0), 'undefined', ATAN2(y_num, x_num)) or ensure your coordinate data includes at least one non-zero value.
#NAME?
Use the exact spelling ATAN2 with two arguments. Note: ATAN is a single-argument function that does not account for quadrant and should not be used here.
ErrorWhy it happensHow to fix it
#VALUE!One or both arguments are text instead of numeric values—for example, passing an ingredient name like 'Basil' or supplier name 'Supplier A' instead of the Qty column.Reference numeric columns only. Use =ATAN2(D2, C2) where columns C and D contain numbers, not =ATAN2(A2, B2) if columns A and B contain ingredient or supplier names.
#DIV/0!Both x_num and y_num equal zero, making the arctangent mathematically undefined (tan θ = 0/0 has no solution).Add a guard clause: =IF(AND(x_num=0, y_num=0), 'undefined', ATAN2(y_num, x_num)) or ensure your coordinate data includes at least one non-zero value.
#NAME?The function name is misspelled (e.g., ATAN, ATAN3, or ATAN2F) instead of the correct ATAN2.Use the exact spelling ATAN2 with two arguments. Note: ATAN is a single-argument function that does not account for quadrant and should not be used here.

Tips and when to use something else

  • ATAN2 returns radians from −π to π; convert to degrees by multiplying by 180/PI()—for example, =ATAN2(45, 30)*180/PI() yields ~56.3° instead of ~0.9828.
  • Use MOD with 2*PI() to normalize results to a standard [0, 2π) range: =MOD(ATAN2(y, x) + 2*PI(), 2*PI()) is useful for continuous angle tracking.
  • Combine ATAN2 with IF/IFS to classify inventory by quadrant for matrix analysis (high qty + high urgency, low qty + low urgency, etc.).
  • ATAN2 is specialized for geometric and navigation problems; most inventory tasks (stock totals, costs, expiry tracking) are better handled by SUMIF, ROUND, and IF.

Frequently asked questions

Why does ATAN2(0, 0) return #DIV/0! instead of a valid result?
The arctangent is undefined when both coordinates are zero because no unique angle satisfies tan(θ) = 0/0. Inspect your data for zero values; if they're legitimate, wrap the formula with IF to provide a fallback (e.g., 0 or 'N/A').
How do I convert ATAN2 results from radians to degrees?
Multiply by 180/PI(). The formula =ATAN2(45, 30)*180/PI() returns approximately 56.3°. Use degrees when presenting angles to non-technical users or integrating with directional compass systems.
Should I use ATAN2 for typical inventory and restaurant management tasks?
No—ATAN2 is specialized for geometric and coordinate-based problems. For standard operations (stock counts, reorder thresholds, cost analysis, expiry tracking), use SUMIF, ROUND, and IF instead. Reserve ATAN2 for navigation, spatial analysis, or bearing calculations.
What is the practical difference between ATAN2 and other angle functions?
ATAN2 takes two arguments (y, x) and automatically determines the correct quadrant by considering the signs of both values. This eliminates ambiguity in geometric calculations where you need the full −π to π range, making it superior for coordinate-based problems.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17