HuntsvilleEngineers mark
HE Reference Shelf — huntsvilleengineers.com
The Reference Shelf · Geometry & Mechanics

Inverse trigonometric functions

The functions that turn a measured ratio back into an angle — and atan2 is the only one of the family that hands the angle back without losing the quadrant.

Also known as: arctan · atan2 · arcsin · arccos

The formula

arcsin x : takes [−1, 1]  → returns [−π/2, +π/2]   (−90° to +90°)
arccos x : takes [−1, 1]  → returns [0, π]          (0° to 180°)
arctan x : takes any real → returns (−π/2, +π/2)    (−90° to +90°)

Reading: each one answers "what angle has this sine / cosine / tangent?" — but since infinitely many angles share the same ratio, each function commits to one agreed-on slice of angles, the principal value [1][2]. Everything that ever bit you about these functions traces back to that slice.

arcsin x + arccos x = π/2

Reading: the two are complements — compute one and the other is a subtraction [1]. Spot-check: asin(0.5) = 30°, acos(0.5) = 60°.

atan2(y, x) = the angle θ in (−π, π] of the point (x, y),
              i.e. cos θ = x/r,  sin θ = y/r,  r = √(x² + y²)

Reading: plain arctan only sees the ratio y/x, so it cannot tell (1, 1) from (−1, −1). atan2 sees both signs and returns the true full-circle bearing [3]:

atan2( 1,  1) = +45°      atan2( 1, −1) = +135°
atan2(−1,  1) = −45°      atan2(−1, −1) = −135°
atan2( 1,  0) = +90°      atan2( 0, −1) = 180°
d/dx arctan x = 1/(1 + x²)
arctan x = x − x³/3 + x⁵/5 − x⁷/7 + …    (|x| ≤ 1)

Reading: arctan is the integral of a plain rational function, which is why it appears in RC step responses and control-loop phase expressions, and why its power series is the oldest route anyone had to π [7].

Where you meet it

  • The impedance bench. You measured a series RLC at 50 Ω resistive and +86.6 Ω reactive; the phase angle is φ = atan(X/R) = atan(86.6/50) = 60.0°. Plain arctan is fine here because a passive series branch keeps R positive — the moment your "R" can go negative (reflected impedances, de-embedded fixtures), switch to atan2(X, R) or your Smith chart lands in the wrong half.
  • The motion test stand. Resolvers and sine/cosine encoders hand you two channels, and shaft angle is θ = atan2(sin_ch, cos_ch) — same story for IMU tilt, θ = atan2(a_x, a_z). A gravity vector splitting 0.5 g and 0.866 g across two axes is a 30° tilt. Divide the channels and feed arctan instead, and the shaft reads correctly for half a revolution, then repeats — a 180°-ambiguous resolver is a classic first-week wound.
  • The trajectory desk. Flat-earth, no-drag range is R = v²·sin(2θ)/g, so recovering launch angle is θ = ½·asin(g·R/v²) — 300 m/s and 8,000 m gives 30.3°. arcsin hands you only the low solution; the lofted shot at 90° − 30.3° = 59.7° hits the same range, and the function will never mention it. Same structure in the oblique-shock θ–β–M relation: weak and strong solutions, and the inverse function silently picks one.
  • The review board, nav software section. Somebody computed the angle between two unit vectors as acos(dot(a,b)) and their attitude-error telemetry is quantized garbage near zero. That one is below, because it fails a design review on numerical grounds, not conceptual ones.

How it works

Sine maps many angles to one ratio, so its inverse has to choose. The standard choices are the ones above, and they are not symmetric: arcsin and arctan are odd functions centered on zero, but arccos runs 0° to 180° because cosine needs that interval to be one-to-one. Consequence one: asin(sin(150°)) returns 30°, not 150° — round-tripping through an inverse trig function only returns your original angle if it already lived inside the principal slice. Consequence two: any measurement chain that reduces geometry to a single ratio before taking the inverse has thrown away quadrant information it can never get back.

atan2 exists because of consequence two. It takes the numerator and denominator separately, so the two sign bits survive, and it covers the full (−π, π] — plus it is perfectly happy at x = 0, where y/x would divide by zero. Three gotchas, each of which bites everyone exactly once:

  1. Argument order. Fortran, C, Python, MATLAB, and most everything else take atan2(y, x) — y first, matching the y/x fraction [3]. Excel takes ATAN2(x_num, y_num) — x first [4]. Mathematica's ArcTan[x, y] also puts x first [3]. Port a spreadsheet sanity check into code (or the reverse) without noticing, and every angle reflects across the 45° line: 30° becomes 60°, 10° becomes 80°. The check that catches it in seconds: feed both implementations the point (x, y) = (1, 2) and confirm you get 63.4°, not 26.6°.
  2. The origin. C and POSIX define every case — atan2(±0, +0) = ±0, atan2(±0, −0) = ±π, no error raised [5]. Excel returns #DIV/0! at (0, 0) [4]. If your data can produce a true zero vector (a stationary target, a centered joystick, a dead resolver), decide what angle that means before the library decides for you.
  3. The wrap. The output is continuous everywhere except the −x axis, where it jumps from +180° to −180°. Average two headings straddling south — 179° and −179° — with plain arithmetic and you get 0°: due north, exactly wrong. Filtering, averaging, or differentiating angles near the wrap needs unwrapping or a sin/cos (vector) average first.

The numerical trap in the family is arccos near its endpoints. Its slope is −1/√(1 − x²), which is 70.7 at x = 0.9999 and unbounded at 1 — small errors in the ratio become large errors in the angle. The angle-between-vectors case is the worst of it: for two unit vectors 10⁻⁸ radians apart, the dot product is cos(10⁻⁸) = 1 − 5×10⁻¹⁷, which double precision rounds to exactly 1.0, and acos returns an angle of exactly zero. The fix is the identity θ = atan2(|a × b|, a·b), which returns 10⁻⁸ on the nose — arctan's slope is bounded by 1, so it never amplifies input error. Related habit: roundoff routinely pushes a computed ratio to 1.0000000000000002, and asin/acos throw a domain error rather than shrug. Clamp to [−1, 1] before the call, every time, and log when the clamp actually fired — a ratio at 1.02 is not roundoff, it is a bug upstream.

And the boring mistake that outnumbers all of the above: every math library returns radians. The value 0.7854 on a data sheet where you expected 45 is not a mystery, it is a units field nobody filled in.

History

The arctangent series is the oldest piece of what we'd now call calculus, and it wasn't European. Madhava of Sangamagrama, working in Kerala, India around 1400, had the series for arctan (along with sine and cosine) more than two centuries before anyone in Europe [6][7]. His texts are lost; the results survive through his school, quoted in works around 1500–1530 [7]. Europe got there independently — James Gregory in 1671, Leibniz in 1673 [7] — which is why the same series carries three names depending on who's citing it.

Plug x = 1 into the series and you get π/4, which looks like a machine for computing π until you try it: after 100 terms you have two correct digits. John Machin found the workaround. His 1706 identity π/4 = 4·atan(1/5) − atan(1/239) moves the series to small arguments where it converges hard — six terms buys ten digits — and Machin used it to compute π to 100 decimal places, a record, published that year by William Jones [8][9]. Machin-style arctangent identities stayed the standard tool for π records clear into the computer era; Kanada's 1.24-trillion-digit run in 2002 still used two of them [9].

The notation settled later. The arc- prefix came out of 1700s France — Condorcet by 1769, Lagrange by 1772 [10][11]. John Herschel introduced sin⁻¹ in an 1813 paper, with a footnote conceding it could be confused with a reciprocal [10][11]. Both notations survived, which is why calculators still print tan⁻¹ on the key and standards bodies still ask everyone to write arctan. atan2 is younger and pure engineering: it arrived with Fortran in 1961 as a convenience for Cartesian-to-polar conversion [3][12]. The (0, 0) case stayed contested for decades — a Fortran 77 manual flatly called it an error [12] — before C and IEEE-style implementations pinned down defined answers for every signed-zero combination [5]. The quadrant problem it solves is as old as coordinates; the fix is younger than Redstone Arsenal's rocket program.

Related tools

  • /tools/series-rlc-impedance
  • /tools/oblique-shock
  • /tools/projectile-range
  • /tools/friction-force
  • /tools/convert-angle

Sources

  1. https://dlmf.nist.gov/4.23
  2. https://en.wikipedia.org/wiki/Inverse_trigonometric_functions
  3. https://en.wikipedia.org/wiki/Atan2
  4. https://support.microsoft.com/en-us/office/atan2-function-c04592ab-b9e3-4908-b428-c96b3a565033
  5. https://man7.org/linux/man-pages/man3/atan2.3.html
  6. https://mathshistory.st-andrews.ac.uk/Biographies/Madhava/
  7. https://en.wikipedia.org/wiki/Gregory%27s_series
  8. https://mathshistory.st-andrews.ac.uk/Biographies/Machin/
  9. https://en.wikipedia.org/wiki/Machin-like_formula
  10. https://mathshistory.st-andrews.ac.uk/Miller/mathsym/trigonometry/
  11. https://www.themathdoctors.org/inverse-trig-notation-what-do-sin-1-and-arcsin-mean/
  12. https://www.charlespetzold.com/blog/2008/09/180741.html

Written by HE in our own words from the cited sources — engineering judgment included, your stamp still required. All entries →

★ The Reference Shelf

Reading is free. The shelf is for cardholders.

Your library card is an email address: pin it to your shelf, print the card, take the FE/PE quick-reference pack, read the Huntsville history. The shelf remembers what you reach for.

Already on the list? Enter with your subscribed email →