Calculate the secant of any angle in degrees or radians, with pole detection.
The secant is the reciprocal of cosine: sec(θ) = 1/cos(θ) = hypotenuse/adjacent. It is undefined where cos = 0, i.e. at 90° + k·180°.
Secant definition
sec θ = 1 / cos θ = hypotenuse / adjacent
sec(0°) = 1/cos(0°) = 1/1 = 1.
At 90°, 270°, and all odd multiples of 90° — wherever cosine equals zero.