Compute the hyperbolic cosine of a real number.
COSH(expr)
## Overview Returns the hyperbolic cosine of the input. Defined by COSH(x) = (e^x + e^-x) / 2, the hyperbolic cosine describes the profile of a hanging chain or cable (the catenary curve), the Lorentz factor of special relativity (gamma = COSH(rapidity)), and the even part of the exponential function in any decomposition into even and odd components. COSH is always greater than or equal to 1 for real inputs, symmetric about zero, and grows exponentially. As with SINH, it overflows for inputs whose absolute value exceeds approximately 710. ## Behavior - Domain: all finite DOUBLE values. - Range: [1, infinity). - Returns NULL if the argument is NULL. - Is an even function: COSH(-x) = COSH(x). - Returns positive infinity for very large magnitudes of input, regardless of sign. ## Numeric precision - Uses the IEEE 754 double-precision cosh routine. - Near zero, the Taylor expansion 1 + x^2/2 + ... keeps one-ULP accuracy; computing (EXP(x) + EXP(-x)) / 2 yourself can accumulate more rounding error. - Overflows to infinity for inputs with absolute value above approximately 710. ## Compatibility - Conforms to the SQL standard definition of COSH as a scalar DOUBLE function. - Matches typical mathematical library implementations.
| Name | Type | Description |
|---|---|---|
expr | Specifies the real-valued input. Accepts any finite DOUBLE value. Extremely large magnitudes produce infinity. |
-- Basic literal
SELECT COSH(0);
-- Result: 1.0
-- Hyperbolic cosine of 1
SELECT COSH(1);
-- Result: 1.5430806348152437
-- Even function: COSH(-x) = COSH(x)
SELECT COSH(-2), COSH(2);
-- Result: 3.7621956910836314, 3.7621956910836314
-- Definition: (e^x + e^-x) / 2
SELECT COSH(1), (EXP(1) + EXP(-1)) / 2;
-- Result: 1.5430806348152437, 1.5430806348152437
-- Catenary profile at x = 2 with parameter a = 1
SELECT COSH(2);
-- Result: 3.7621956910836314
-- Column use: relativistic gamma factor from rapidity
SELECT particle_id, COSH(rapidity) AS gamma
FROM physics.simulation.tracks;