atan

atan(x)

Try it yourself:

See also:

atan(): Recovering an Angle from a Tangent

atan() returns the principal angle whose tangent equals the input. It reverses tan() on the interval from −π/2 to π/2. atan is common when a slope or a ratio of vertical to horizontal change must be turned into an angle.

Examples and limits

atan(0) is 0; positive inputs return positive angles and negative inputs return negative angles. Every finite real number is valid, but the output approaches ±π/2 as magnitude increases and never reaches those values for finite input. This makes atan useful for smoothly mapping an unbounded quantity into a bounded angular range.

For a slope m, atan(m) gives the angle from the horizontal. However, a slope alone loses quadrant information and cannot represent a vertical line. If you have separate y and x components, use atan2() instead. It handles signs and zero components directly.

Working with other inverse functions

Use asin() for a sine ratio and acos() for a cosine ratio. Verify a result with tan(atan(x)), allowing for normal floating-point precision. Keep values in radians when combining them with sin() or cos().

In numerical code, avoid calculating atan(y/x) when x may be zero or very small. atan2 is designed for that case and communicates the intended geometry more clearly.

All functions