SEC

Compute the secant (reciprocal of cosine) of an angle in radians.

Category: mathReturns: DOUBLEDialect: Standard

Syntax

SEC(expr)

Description

## Overview Returns the secant of an angle supplied in radians. Secant is the reciprocal of cosine: SEC(x) = 1 / COS(x). It appears most often in relativistic physics, beam bending equations, and map projection formulas (for example, the Mercator projection uses the secant of latitude). The secant function is unbounded and has vertical asymptotes where the cosine is zero. As with the other reciprocal trigonometric functions, evaluating SEC at the exact theoretical singularity returns a very large finite number rather than producing an error. ## Behavior - Accepts any finite DOUBLE value. Mathematically undefined at odd multiples of pi/2. - Returns a DOUBLE. The output domain is (-infinity, -1] union [1, infinity), but floating-point rounding can produce values with absolute value slightly less than 1 for inputs very close to zero. - Returns NULL if the argument is NULL. - Matches 1.0 / COS(x) to within one ULP in the stable range. ## Numeric precision - Computed from COS(x) using the IEEE 754 double-precision intrinsic. - Catastrophic cancellation does not apply, but the denominator COS(x) approaches zero near odd multiples of pi/2, so small input changes produce large output swings. - For arguments above roughly 1e15, argument-reduction error in cosine makes the result effectively meaningless. ## Compatibility - Conforms to the SQL standard definition of SEC as a scalar DOUBLE function. - Matches typical mathematical library implementations.

Parameters

NameTypeDescription
exprSpecifies the angle in radians whose secant is returned. Accepts any finite DOUBLE value except odd multiples of pi/2 (where cosine is zero and secant is undefined).

Examples

-- Basic literal
SELECT SEC(0);
-- Result: 1.0
-- Secant of pi/3 is 2
SELECT SEC(PI() / 3);
-- Result: 1.9999999999999998
-- Secant of pi is -1
SELECT SEC(PI());
-- Result: -1.0
-- Reciprocal identity
SELECT SEC(0.5), 1.0 / COS(0.5);
-- Result: 1.1394939273245491, 1.1394939273245491
-- Near singularity: SEC(PI()/2) returns a very large finite number
SELECT SEC(PI() / 2);
-- Result: 1.633123935319537E16
-- Column use: cable tension correction factor
SELECT rigging_id, load_kg * SEC(RADIANS(angle_deg)) AS tension_kg
FROM engineering.design.cables;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →