Math and trigonometry functions

SEC

Matches all 2,141 recorded answers

Recorded: 2,138 in the answer bank and 3 workbook cells. How we measure this · See the Rust code

Local names in 40 languages
LanguageName in Excel
ArabicSEC
BulgarianSEC
CzechSEC
DanishSEC
GermanSEC
GreekSEC
English (Australia)SEC
English (United Kingdom)SEC
English (United States)SEC
SpanishSEC
EstonianSEC
FinnishSEK
FrenchSEC
HebrewSEC
CroatianSEC
HungarianSEC
IndonesianSEC
ItalianSEC
JapaneseSEC
KoreanSEC
LithuanianSEC
LatvianSEC
NorwegianSEC
DutchSECONDE
PolishSEC
Portuguese (Brazil)SEC
Portuguese (Portugal)SEC
RomanianSEC
RussianSEC
SlovakSEC
SlovenianSEC
Serbian (Latin)SEC
SwedishSEK
ThaiSEC
TurkishSEC
UkrainianSEC
VietnameseSEC
Chinese (Simplified)SEC
Chinese (Hong Kong)SEC
Chinese (Traditional)SEC

Names from Microsoft's support site.

What it does

SEC(number)

SEC(number) returns the secant of an angle given in radians.

sec x = 1 / cos x

Domain. All real x except the zeros of cosine, x = π/2 + kπ for integer k, where secant has simple poles. Range. |sec x| ≥ 1: the values (−1, 1) are never attained. The function is even, 2π-periodic, and satisfies the Pythagorean identity

sec²x − tan²x = 1

Its derivative is sec x · tan x, and its Maclaurin series is the Euler-number generating function

sec x = Σ_{n≥0} |E_{2n}| x^{2n} / (2n)!  =  1 + x²/2 + 5x⁴/24 + 61x⁶/720 + …

convergent for |x| < π/2 — the radius is exactly the distance to the nearest pole, which is the compact statement of why this function is hard near π/2. (A&S 4.3.68.)

A fact worth stating before the numerics. No binary64 value is exactly π/2 + kπ, because those points are irrational. So SEC never actually divides by zero on a machine: it divides by a very small number and returns a very large one. The pole is unreachable, and everything difficult about the function happens in its neighbourhood rather than at it.

Arguments

ArgumentMeaningDefault
numberThe angle, in radians, whose secant is wanted. Required.—

Degrees must be converted first: SEC(RADIANS(d)). See RADIANS for what that conversion costs, which matters more here than for most consumers because of the amplification described below.

Microsoft's VBA page for this method is three lines long: a one-sentence description, the single argument, the return type. No remarks, no domain restriction, no error condition.

Try it

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

Quirks

Result and edge cases

Returns Number.

  • SEC(0) is exactly 1, and it is one of the few inputs where an exact answer is available.
  • Near a pole the result is enormous and its accuracy is not. As x approaches π/2 the returned value grows without bound; the relative accuracy of that value degrades in proportion to how well the argument's last bits locate x relative to the pole. See the numerical notes.

Errors

ErrorConditionSource
#NUM!|number| ≥ 2²⁷observed live Excel, catalogue XMD-005; not documented
#VALUE!The argument does not convert to a numbershared coercion model
propagatedThe argument is an error valueshared coercion model

Microsoft's documentation states none of these.

How to implement

Numerical notes

The condition number is the whole story. Differentiating, the relative error in sec x produced by a relative error ε in x is

|x · d(sec x)/dx / sec x| · ε  =  |x · tan x| · ε

so the amplification factor is |x tan x|, which is unbounded as x approaches a pole. Near π/2, a last-bit perturbation of the argument moves the result by an arbitrarily large relative amount. This is not an implementation weakness; it is a property of the function, and it means that no implementation can return an accurate secant near a pole from an inexact argument. The honest response is to say so, which most libraries do not.

Argument reduction is where the accuracy is won or lost. Evaluating cos x requires x mod 2π, and the modulus must be taken against the real π rather than against fl(π) — every bit by which |x| exceeds π costs a bit of the reduced argument if the reduction uses a rounded constant. The standard remedy is Payne–Hanek reduction against a many-word 2/π, as implemented in fdlibm's __ieee754_rem_pio2; it is exact for every finite double and costs a bounded amount of work.

Excel's recorded behaviour is the alternative policy: refuse. A cutoff at 2²⁷ is approximately where a reduction using a double-precision π begins to lose the low half of the reduced argument, so the threshold reads as the point at which the implementer stopped trusting their own reduction. The Handbook's position is that both are defensible engineering, that only one of them is documented (neither), and that a natural-best implementation should reduce correctly and return a value where Excel returns an error — which is a deliberate, declared divergence, not a compatibility bug. See About implementation options.

Host-CPU dependence. EV-MATH-0004's reader warning records that all six circular surfaces inherit a host-CPU microcode caveat on the x87 FPREM1, FSIN and FPTAN instructions. In plain terms: the value may depend on which processor evaluates it. That is a portable-reproducible concern, and it is the reason a suite for this function would have to name a CPU as well as an Excel build.

Rust code

Show the CalcFunc source of this function

Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.

SEC · 1 lines · calc-func/src/catalogue/math.rs on GitHub
16 sec "SEC" (1, 1) [V "number"] |s, a, sv| { unary(s, a, k::sec::sec_kernel) }
sec_kernel · 9 lines · calc-func/src/ported/sec.rs on GitHub
pub fn sec_kernel(n: f64) -> Result<f64, WorksheetErrorCode> {
    ExcelRealPolicy::CIRCULAR_TRIG.check_arg(n)?;
    // W109 G4-01: SEC = RN53(RN64(1/cos)) over the RAW COS chain (the
    // published-COS small-argument 1.0 shortcut composes identically here:
    // recip-dr of 1-ulp ties back to exactly 1.0).
    Ok(crate::ported::excel_numeric::excel_x87_recip(
        crate::ported::excel_numeric::excel_cos(n),
    ))
}

Kernels shared with other functions

Argument and result plumbing

  • num catalogue/kit
  • out catalogue/kit

No implementation has been published with a Handbook test suite for this function.

Version differences

The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.

Excel 16.0 buildPlatform and CPUCaptured inputs
19929Windows, bitness not recorded, CPU not recorded33
20131Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics914
20430Windows, 64-bit, CPU not recorded1,224
  • XC-SEC-001: build 19929 versus build 20430; 1 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.
  • XC-SEC-002: build 20131 versus build 20430; 1 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.

Agreement on these compared inputs does not establish agreement on unmeasured inputs.

Recorded environments and comparison details.

Excel 16.0 build 19929

Windows, bitness not recorded, CPU not recorded

33 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.

Excel 16.0 build 20131

Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics

914 captured inputs are indexed for this environment. Capture dates: 2026-07-11 to 2026-07-11. This is a reading count, not a comparison with another build.

Excel 16.0 build 20430

Windows, 64-bit, CPU not recorded

1,224 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.

Alternatives

Relationships

  • CSC and COT — the other two reciprocals, of SIN and TAN. All three share the 2²⁷ guard, all three are built on two kernels, and all three carry the same host-CPU caveat.
  • TAN — related by sec²x = 1 + tan²x, which is the numerically preferable route to sec when tan is already available and x is near a pole: computing sqrt(1 + tan²x) avoids the division by a tiny cosine, at the cost of losing the sign, which must be restored from the quadrant.
  • SECH — the hyperbolic namesake, and a completely different function: bounded, pole-free, and with no argument limit. The two are related only through the complex identity sech(x) = sec(ix).
  • ACOS — there is no ASEC. The inverse secant must be written ACOS(1/x), which is defined for |x| ≥ 1 and inherits a division by the argument.
  • RADIANS — the usual upstream converter, and, given the amplification below, a genuine contributor to the error of the result.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents