Compute the inverse hyperbolic tangent, defined on the open interval (-1, 1).
ATANH(expr)
## Overview Returns the inverse hyperbolic tangent of the input. ATANH is defined on the open interval (-1, 1), asymptotes to +/-infinity at the endpoints, and is equivalent to 0.5 * LN((1 + x) / (1 - x)). It is the inverse of TANH across its entire range. ATANH is central to special relativity (rapidity is the inverse hyperbolic tangent of velocity as a fraction of c), to Fisher's z-transform in statistics (stabilizing variance of correlation coefficients), and to logit-like transforms that map probabilities in (0, 1) to the real line. ## Behavior - Domain: (-1, 1). At +/-1 the result is +/-infinity. Outside the interval the result is NULL. - Range: all real numbers. - Returns NULL if the argument is NULL. - Is anti-symmetric: ATANH(-x) = -ATANH(x). - Is strictly increasing and continuous on its open domain. ## Numeric precision - Uses the IEEE 754 double-precision atanh routine, accurate to within one ULP over most of the domain. - Near the endpoints the derivative diverges, so small input noise produces large output swings. - The naive closed form 0.5 * LN((1 + x) / (1 - x)) loses precision near x = +/-1 because of cancellation; use ATANH directly. ## Compatibility - Conforms to the SQL standard definition of ATANH as a scalar DOUBLE function with domain (-1, 1). - Matches typical mathematical library implementations.
| Name | Type | Description |
|---|---|---|
expr | Specifies the real-valued input in the open interval (-1, 1). At +/-1 the result is +/-infinity; outside the interval the result is NULL. |
-- Basic literal
SELECT ATANH(0);
-- Result: 0.0
-- Inverse hyperbolic tangent of 0.5
SELECT ATANH(0.5);
-- Result: 0.5493061443340549
-- Round trip: ATANH(TANH(x)) = x for small x
SELECT ATANH(TANH(1.0));
-- Result: 1.0
-- Out-of-domain input returns NULL
SELECT ATANH(2);
-- Result: NULL
-- Closed form: ATANH(x) = 0.5 * LN((1 + x) / (1 - x))
SELECT ATANH(0.5), 0.5 * LN((1 + 0.5) / (1 - 0.5));
-- Result: 0.5493061443340549, 0.5493061443340549
-- Column use: recover rapidity from velocity (as fraction of c)
SELECT track_id, ATANH(velocity_over_c) AS rapidity
FROM physics.simulation.tracks
WHERE ABS(velocity_over_c) < 1;