ATAN

Compute the inverse tangent (arctangent) of a value, returning an angle in radians.

Category: mathReturns: DOUBLEDialect: Standard

Syntax

ATAN(expr)

Description

## Overview Returns the inverse tangent of the input, producing an angle in radians whose tangent equals the input. The result lies in the open interval (-pi/2, pi/2). ATAN is the principal-value inverse of TAN and is widely used to recover slope angles from rise/run ratios, to convert magnitude ratios to phase angles, and as a smooth saturating function in feature engineering. Unlike ASIN and ACOS, ATAN has no domain restriction: every finite real is a valid input. For recovering the full two-dimensional angle from (y, x) coordinates, including the correct quadrant, use ATAN2 instead. ## Behavior - Domain: all finite DOUBLE values. - Range: (-pi/2, pi/2) radians. - Returns NULL if the argument is NULL. - Returns +/-pi/2 asymptotically as the input tends to +/-infinity. - Is strictly increasing and smooth on its entire domain. - ATAN(TAN(x)) equals x only for x in (-pi/2, pi/2). ## Numeric precision - Computed using the IEEE 754 double-precision atan routine, accurate to within one ULP. - Near x = 0, ATAN(x) is numerically close to x; the identity ATAN(x) approximately equals x holds for small x. - For very large magnitudes the output saturates near +/-pi/2; use ATAN2(y, x) when both components are available to avoid dividing very large by very large. ## Compatibility - Conforms to the SQL standard definition of ATAN as a scalar DOUBLE function. - Matches typical mathematical library implementations.

Parameters

NameTypeDescription
exprSpecifies the tangent value whose angle is returned. Accepts any finite DOUBLE value; there is no domain restriction.

Examples

-- Basic literal
SELECT ATAN(0);
-- Result: 0.0
-- Arctangent of 1 is pi/4
SELECT ATAN(1);
-- Result: 0.7853981633974483
-- Convert to degrees
SELECT DEGREES(ATAN(1));
-- Result: 45.0
-- Large input approaches pi/2
SELECT ATAN(1000000);
-- Result: 1.5707953267948967
-- Negative input produces negative output
SELECT ATAN(-2.5);
-- Result: -1.1902899496825317
-- Column use: road gradient to inclination angle
SELECT segment_id, DEGREES(ATAN(rise / run)) AS incline_deg
FROM roads.catalog.segments
WHERE run <> 0;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →