Math and trigonometry functions

COT

Matches all 2,133 recorded answers

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

Local names in 40 languages
LanguageName in Excel
ArabicCOT
BulgarianCOT
CzechCOT
DanishCOT
GermanCOT
GreekCOT
English (Australia)COT
English (United Kingdom)COT
English (United States)COT
SpanishCOT
EstonianCOT
FinnishCOT
FrenchCOT
HebrewCOT
CroatianCOT
HungarianCOT
IndonesianCOT
ItalianCOT
JapaneseCOT
KoreanCOT
LithuanianCOT
LatvianCOT
NorwegianCOT
DutchCOT
PolishCOT
Portuguese (Brazil)COT
Portuguese (Portugal)COT
RomanianCOT
RussianCOT
SlovakCOT
SlovenianCOT
Serbian (Latin)COT
SwedishCOT
ThaiCOT
TurkishCOT
UkrainianCOT
VietnameseCOT
Chinese (Simplified)COT
Chinese (Hong Kong)COT
Chinese (Traditional)COT

Names from Microsoft's support site.

What it does

COT(number)

COT(number) returns the cotangent of an angle in radians. Microsoft's page describes it as the cotangent of an angle specified in radians.

cot x = cos x / sin x = 1 / tan x = tan(π/2 - x)
PropertyStatement
Domainall real x except x = kπ, k ∈ ℤ
Rangeall of ℝ; every real value is attained once per period
Parityodd: cot(-x) = -cot(x)
Periodπ — half the period of sin and cos
Polessimple, at x = kπ, each with residue 1
Zerosx = π/2 + kπ
Laurent series at 0cot x = 1/x - x/3 - x³/45 - 2x⁵/945 - … (A&S 4.3.70)
Derivatived/dx cot x = -csc²x = -(1 + cot²x)
Monotonestrictly decreasing on each interval (kπ, (k+1)π)

The pole structure is where the reading and the implementation part company. Mathematically there is a pole at every integer multiple of π. In binary64 only one of those poles is representable: x = 0. Every other kπ is irrational, so no double sits on it, and near those poles COT returns a large finite number rather than an error. Microsoft documents COT(0) as #DIV/0! and documents nothing about the others, which is consistent: 0 is the only argument at which the division is exactly by zero.

The consequence for a reader is worth stating plainly. COT(PI()) is not an error and is not infinite; it is roughly the reciprocal of the distance between the double PI() and the true π, which is a large number whose value says more about the rounding of PI() than about the cotangent.

Arguments

ArgumentMeaningConstraint (as documented)
numberThe angle in radians. Required.ABS(number) < 2^27

Microsoft states the magnitude constraint on this page and states #NUM! when it is exceeded. The bound is 2^27 ≈ 1.342 × 10^8, and it is not arbitrary: it is approximately where a reduction against a limited-precision π stops producing a reduced argument with any correct bits. Documenting the bound rather than returning noise is, from a numerical-analysis point of view, the right call, and it is a choice the older surfaces (COS, SIN, TAN) do not make on their own documentation pages.

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.

  • COT(0) — #DIV/0!, documented explicitly.
  • Near other poles — a large finite value, not an error. The magnitude is bounded by roughly 1/ulp(kπ), so it grows with k.
  • Sign near a pole — cot changes sign across every pole, so two adjacent doubles either side of kπ give large values of opposite sign. Any formula that uses COT near a multiple of π is sitting on a discontinuity of magnitude ~2/ulp.
  • Zeros — at π/2 + kπ, again not representable, so COT of a double is essentially never exactly zero.
  • Beyond 2^27 — documented #NUM!.
  • Small arguments — cot x → 1/x, so COT of a tiny argument is a huge finite number and overflows only for |x| below about 5.6 × 10^-309, i.e. in the subnormal range.

Errors

As documented on Microsoft's COT page:

ErrorCondition
#DIV/0!number is 0
#NUM!ABS(number) is not less than 2^27
#VALUE!number is non-numeric

COT is the only member of its trio whose page states the zero case. CSC's page defines CSC(n) as 1/SIN(n) — which makes CSC(0) a division by zero — but does not state the resulting error; SEC has no zero-pole at all. That asymmetry is in Microsoft's documentation, not in the mathematics.

How to implement

Numerical notes

Cotangent inherits every difficulty of the tangent and adds one of its own.

The reduction problem, inherited. As on COS, evaluating a circular function at a large argument requires reducing modulo π/2 against a sufficiently precise π. COT's documented 2^27 bound is a declaration of exactly where the implementation's reduction gives up. EV-MATH-0004 identifies the substrate as the x87 FSIN/FPTAN chain with FPREM1 reduction against the 64-bit ROM π, with the reciprocal surfaces formed from the published primaries, and it rules out Cody–Waite reduction against extended π. All six circular surfaces in that record inherit a host-CPU microcode caveat, so the last bits here are platform-scoped by construction. The record's figures render in the evidence layer beside this page.

The conditioning problem, its own. The relative condition number of cot is |x / (sin x cos x)| · |cos x / sin x|^{-1}… stated more usefully: near a pole kπ, cot x ≈ 1/(x - kπ), so a relative error ε in the reduced argument becomes a relative error of about ε · |x| / |x - kπ| in the result. Close to a pole this amplification is unbounded. This is not a fixable defect; it is the function. It does mean that "how accurate is COT?" has no single answer — accuracy has to be quoted as a function of distance to the nearest pole.

The double-rounding problem, structural. Building COT as 1/TAN(x) where TAN(x) is the published binary64 tangent means the tangent's own rounding error is inverted along with the value. The result is a correctly-rounded reciprocal of an incorrectly-rounded tangent — which is a different function from a correctly-rounded cotangent, and differs from it by up to about one ulp more than the tangent already did. A natural-best implementation would instead evaluate cos r / sin r from a single reduction, sharing the reduced argument between numerator and denominator so the pole locations agree exactly.

Near zero. For small |x|, 1/TAN(x) is fine — tan x → x with no cancellation — but the Laurent form 1/x - x/3 - x³/45 (A&S 4.3.70) is cheaper and more accurate, and it is the standard choice below about 2^-13.

Muller's treatment is the reference for why the tangent family is the hardest of the circular set to round correctly: the worst cases require more extra precision than sine or cosine do, because the function is unbounded and its hardest-to-round arguments cluster near the poles.

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.

COT · 1 lines · calc-func/src/catalogue/math.rs on GitHub
12 cot "COT" (1, 1) [V "number"] |s, a, sv| { unary(s, a, k::cot::cot_kernel) }
cot_kernel · 10 lines · calc-func/src/ported/cot.rs on GitHub
pub fn cot_kernel(n: f64) -> Result<f64, WorksheetErrorCode> {
    ExcelRealPolicy::CIRCULAR_TRIG.check_arg(n)?;
    // W109 G4-01: COT = RN53(RN64(1/TAN)) over the published TAN chain
    // (the double-rounded x87 reciprocal, unique surviving staging).
    let tan = crate::ported::excel_numeric::excel_tan(n);
    if tan == 0.0 {
        return Err(WorksheetErrorCode::Div0);
    }
    Ok(crate::ported::excel_numeric::excel_x87_recip(tan))
}

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 recorded31
20131Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics906
20430Windows, 64-bit, CPU not recorded1,224
  • XC-COT-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-COT-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

31 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

906 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

  • TAN — the reciprocal, and the surface COT is built from. EV-MATH-0004 records that the three reciprocal surfaces are formed as excel_x87_recip of the published primaries; for COT the primary is the tangent chain (FPTAN). That construction is the single most useful implementation fact on this page.
  • COS, SIN — the ratio definition. Note that COS(x)/SIN(x) and 1/TAN(x) are different computations with different error, even though they are the same function: the first divides two rounded values, the second inverts one.
  • ACOT — the inverse, principal range (0, π). Note that ACOT in Excel returns a value in (0, π) rather than (-π/2, π/2), so ACOT(COT(x)) folds into (0, π).
  • CSC, SEC — the other two reciprocals introduced alongside COT, sharing its documentation template and its constraint.
  • IMCOT — the complex-argument version.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents