Math & trig function

SEC function

Returns the secant of an angle in radians (1 / cosine), e.g. sloping length from a horizontal run.

Available in Excel 2013 and later, Microsoft 365, Excel for the web, Excel for Mac 2016 and later

Excel 2013 and laterWorks in Google Sheets

Syntax

SEC(number)
ArgumentWhat it means
numberRequiredThe angle in radians; |number| must be less than 2^27.

Returns: 1 ÷ cos(number); never between −1 and 1.

How SEC works

The secant is the reciprocal of the cosine: hypotenuse divided by the adjacent side. That makes it the multiplier from a horizontal distance to the sloping distance. A roof rafter that covers a 4.2 m run at a 30° pitch is 4.2*SEC(RADIANS(30)) long, and the same idea gives the length of a sloping pipe, cable or conveyor from a plan drawing.

Before Excel 2013, use 1/COS(x). At 90° the cosine is 0, but because π/2 cannot be represented exactly, Excel returns a very large number instead of an error. Excel's trigonometric functions work in radians, not degrees. Convert an angle with RADIANS (or multiply by PI()/180) before passing it in, and convert results back with DEGREES.

Examples

1Rafter length from run and pitch

D2fx=B2*SEC(RADIANS(C2))
ABCD
1RoofRun (m)Pitch (°)
2Garage4.2304.85

Result: 4.85

4.2 / cos(30°) ≈ 4.85 m of rafter, before any overhang (2 decimals).

2Secant of zero

A1fx=SEC(0)
A
11

Result: 1

cos(0) = 1, so its reciprocal is also 1: a flat roof's rafter equals its run.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!|number| ≥ 2^27.Reduce the angle.
#VALUE!Non-numeric argument.Check the input.

Tips

  • Roofers' "pitch factor" tables are simply SEC of the pitch angle.

Google Sheets

SEC also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

SEC in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
FinnishSEK
SwedishSEK