{
  "category": "Math and trigonometry functions",
  "display_name": "COT",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COT",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131",
        "20430",
        "?"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 2130,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 2130,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 2,130 in the answer bank and 3 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 2,133 recorded answers",
    "workbook_corpus": {
      "cells": 3,
      "matched": 3
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L66-L66",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/cot.rs#L4-L13"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/math::unary",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::tan_with",
        "ported/excel_numeric::excel_tan",
        "ported/excel_numeric::excel_x87_recip",
        "ported/excel_numeric/soft87::pack_raw",
        "ported/excel_numeric/soft87::zero",
        "ported/excel_numeric/soft87::inf",
        "ported/excel_numeric/soft87::pack",
        "ported/excel_numeric/soft87::ext_pi",
        "ported/excel_numeric/soft87::ext_one",
        "ported/excel_numeric/soft87::ext_chs",
        "ported/excel_numeric/x87::recip"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L66-L66",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 2,133 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COT.json",
  "name": "COT",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n- **`TAN`** — the reciprocal, and the surface `COT` is built from. `EV-MATH-0004` records that\n  the three reciprocal surfaces are formed as `excel_x87_recip` of the *published* primaries;\n  for `COT` the primary is the tangent chain (`FPTAN`). That construction is the single most\n  useful implementation fact on this page.\n- **[COS](FUNC.COS.md), `SIN`** — the ratio definition. Note that `COS(x)/SIN(x)` and\n  `1/TAN(x)` are **different computations** with different error, even though they are the same\n  function: the first divides two rounded values, the second inverts one.\n- **`ACOT`** — the inverse, principal range `(0, π)`. Note that `ACOT` in Excel returns a value\n  in `(0, π)` rather than `(-π/2, π/2)`, so `ACOT(COT(x))` folds into `(0, π)`.\n- **[CSC](FUNC.CSC.md), `SEC`** — the other two reciprocals introduced alongside `COT`, sharing\n  its documentation template and its constraint.\n- **`IMCOT`** — the complex-argument version.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nCotangent inherits every difficulty of the tangent and adds one of its own.\n\n**The reduction problem, inherited.** As on [COS](FUNC.COS.md), evaluating a circular function\nat a large argument requires reducing modulo `π/2` against a sufficiently precise `π`. `COT`'s\ndocumented `2^27` bound is a declaration of exactly where the implementation's reduction gives\nup. `EV-MATH-0004` identifies the substrate as the x87 `FSIN`/`FPTAN` chain with\n`FPREM1` reduction against the 64-bit ROM `π`, with the reciprocal surfaces formed from the\npublished primaries, and it rules out Cody–Waite reduction against extended `π`. All six\ncircular surfaces in that record inherit a host-CPU microcode caveat, so the last bits here are\nplatform-scoped by construction. The record's figures render in the evidence layer beside this\npage.\n\n**The conditioning problem, its own.** The relative condition number of `cot` is\n`|x / (sin x cos x)| · |cos x / sin x|^{-1}`… stated more usefully: near a pole `kπ`,\n`cot x ≈ 1/(x - kπ)`, so a relative error `ε` in the *reduced* argument becomes a relative\nerror of about `ε · |x| / |x - kπ|` in the result. Close to a pole this amplification is\nunbounded. This is not a fixable defect; it is the function. It does mean that \"how accurate is\n`COT`?\" has no single answer — accuracy has to be quoted as a function of distance to the\nnearest pole.\n\n**The double-rounding problem, structural.** Building `COT` as `1/TAN(x)` where `TAN(x)` is the\n*published* binary64 tangent means the tangent's own rounding error is inverted along with the\nvalue. The result is a correctly-rounded reciprocal of an incorrectly-rounded tangent — which\nis a different function from a correctly-rounded cotangent, and differs from it by up to about\none ulp more than the tangent already did. A `natural-best` implementation would instead\nevaluate `cos r / sin r` from a single reduction, sharing the reduced argument between\nnumerator and denominator so the pole locations agree exactly.\n\n**Near zero.** For small `|x|`, `1/TAN(x)` is fine — `tan x → x` with no cancellation — but the\nLaurent form `1/x - x/3 - x³/45` (A&S 4.3.70) is cheaper and more accurate, and it is the\nstandard choice below about `2^-13`.\n\nMuller's treatment is the reference for why the tangent family is the hardest of the circular\nset to round correctly: the worst cases require more extra precision than sine or cosine do,\nbecause the function is unbounded and its hardest-to-round arguments cluster near the poles.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`.\n\n- **`COT(0)`** — `#DIV/0!`, documented explicitly.\n- **Near other poles** — a large finite value, not an error. The magnitude is bounded by\n  roughly `1/ulp(kπ)`, so it grows with `k`.\n- **Sign near a pole** — `cot` changes sign across every pole, so two adjacent doubles either\n  side of `kπ` give large values of opposite sign. Any formula that uses `COT` near a multiple\n  of `π` is sitting on a discontinuity of magnitude `~2/ulp`.\n- **Zeros** — at `π/2 + kπ`, again not representable, so `COT` of a double is essentially never\n  exactly zero.\n- **Beyond `2^27`** — documented `#NUM!`.\n- **Small arguments** — `cot x → 1/x`, so `COT` of a tiny argument is a huge finite number and\n  overflows only for `|x|` below about `5.6 × 10^-309`, i.e. in the subnormal range.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `COT` page:\n\n| Error | Condition |\n|---|---|\n| `#DIV/0!` | `number` is 0 |\n| `#NUM!` | `ABS(number)` is not less than `2^27` |\n| `#VALUE!` | `number` is non-numeric |\n\n`COT` is the only member of its trio whose page states the zero case. [CSC](FUNC.CSC.md)'s page\ndefines `CSC(n)` as `1/SIN(n)` — which makes `CSC(0)` a division by zero — but does not state\nthe resulting error; `SEC` has no zero-pole at all. That asymmetry is in Microsoft's\ndocumentation, not in the mathematics.\n\n\n",
    "sources": "- Handbook evidence record `EV-MATH-0004` — the six-surface circular identification, the\n  `FPREM1`-against-ROM-`π` substrate, the reciprocal construction of `COT`/`CSC`/`SEC` from the\n  published primaries, the ruled-out Cody–Waite reduction, and the host-CPU microcode caveat.\n  Read its reader warning.\n- Abramowitz & Stegun, chapter 4.3, in particular 4.3.70 — the cotangent expansion.\n- Payne & Hanek (1983) — infinite-precision radian reduction.\n- Muller, *Elementary Functions: Algorithms and Implementation* — tangent-family worst cases.\n- Handbook, [COS](FUNC.COS.md) — the shared reduction discussion;\n  [Coercion and lifting](../model/02-coercion-and-lifting.md).\n- Handbook projections `data/functions/FUNC.COT.json` (the\n  `arg_domain_guard=circular_trig_overflow` and `non_finite=num` axis values) and\n  `data/presence/FUNC.COT.json`.\n\n",
    "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.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 19929 | Windows, bitness not recorded, CPU not recorded | 31 |\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 906 |\n| 20430 | Windows, 64-bit, CPU not recorded | 1,224 |\n\n- 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.\n- 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.\n\nAgreement on these compared inputs does not establish agreement on unmeasured inputs.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COT.json).",
    "what-it-does": "\n`COT(number)` returns the cotangent of an angle in radians. Microsoft's page describes it as\nthe cotangent of an angle specified in radians.\n\n    cot x = cos x / sin x = 1 / tan x = tan(π/2 - x)\n\n| Property | Statement |\n|---|---|\n| Domain | all real `x` except `x = kπ`, `k ∈ ℤ` |\n| Range | all of `ℝ`; every real value is attained once per period |\n| Parity | odd: `cot(-x) = -cot(x)` |\n| Period | `π` — half the period of `sin` and `cos` |\n| Poles | simple, at `x = kπ`, each with residue 1 |\n| Zeros | `x = π/2 + kπ` |\n| Laurent series at 0 | `cot x = 1/x - x/3 - x³/45 - 2x⁵/945 - …` (A&S 4.3.70) |\n| Derivative | `d/dx cot x = -csc²x = -(1 + cot²x)` |\n| Monotone | strictly decreasing on each interval `(kπ, (k+1)π)` |\n\nThe pole structure is where the reading and the implementation part company. Mathematically\nthere is a pole at every integer multiple of `π`. In binary64 **only one of those poles is\nrepresentable**: `x = 0`. Every other `kπ` is irrational, so no double sits on it, and near\nthose poles `COT` returns a large finite number rather than an error. Microsoft documents\n`COT(0)` as `#DIV/0!` and documents nothing about the others, which is consistent: `0` is the\nonly argument at which the division is exactly by zero.\n\nThe consequence for a reader is worth stating plainly. `COT(PI())` is not an error and is not\ninfinite; it is roughly the reciprocal of the distance between the double `PI()` and the true\n`π`, which is a large number whose value says more about the rounding of `PI()` than about the\ncotangent.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Constraint (as documented) |\n|---|---|---|\n| `number` | The angle in radians. Required. | `ABS(number) < 2^27` |\n\nMicrosoft states the magnitude constraint on this page and states `#NUM!` when it is exceeded.\nThe bound is `2^27 ≈ 1.342 × 10^8`, and it is not arbitrary: it is approximately where a\nreduction against a limited-precision `π` stops producing a reduced argument with any correct\nbits. Documenting the bound rather than returning noise is, from a numerical-analysis point of\nview, the right call, and it is a choice the older surfaces ([COS](FUNC.COS.md), `SIN`, `TAN`)\ndo not make on their own documentation pages.\n\n"
  },
  "signature": {
    "display": "COT(number)",
    "parameters": [
      {
        "description": null,
        "name": "number",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 1,
        "min": 1
      },
      "category": "Math and trigonometry functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "UnaryNumericScalarOrArrayElementwise",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Cotangent of an angle in radians",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the cotangent of an angle",
        "microsoft_url": "https://support.microsoft.com/en-us/office/cot-function-c446f34d-6fe4-40dc-84f8-cf59e5f5e31a"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COT"
        },
        {
          "locale": "bg-BG",
          "name": "COT"
        },
        {
          "locale": "cs-CZ",
          "name": "COT"
        },
        {
          "locale": "da-DK",
          "name": "COT"
        },
        {
          "locale": "de-DE",
          "name": "COT"
        },
        {
          "locale": "el-GR",
          "name": "COT"
        },
        {
          "locale": "en-AU",
          "name": "COT"
        },
        {
          "locale": "en-GB",
          "name": "COT"
        },
        {
          "locale": "en-US",
          "name": "COT"
        },
        {
          "locale": "es-ES",
          "name": "COT"
        },
        {
          "locale": "et-EE",
          "name": "COT"
        },
        {
          "locale": "fi-FI",
          "name": "COT"
        },
        {
          "locale": "fr-FR",
          "name": "COT*"
        },
        {
          "locale": "he-IL",
          "name": "COT"
        },
        {
          "locale": "hr-HR",
          "name": "COT"
        },
        {
          "locale": "hu-HU",
          "name": "COT"
        },
        {
          "locale": "id-ID",
          "name": "COT"
        },
        {
          "locale": "it-IT",
          "name": "COT"
        },
        {
          "locale": "ja-JP",
          "name": "COT"
        },
        {
          "locale": "ko-KR",
          "name": "COT"
        },
        {
          "locale": "lt-LT",
          "name": "COT"
        },
        {
          "locale": "lv-LV",
          "name": "COT"
        },
        {
          "locale": "nb-NO",
          "name": "COT"
        },
        {
          "locale": "nl-NL",
          "name": "COT"
        },
        {
          "locale": "pl-PL",
          "name": "COT"
        },
        {
          "locale": "pt-BR",
          "name": "COT"
        },
        {
          "locale": "pt-PT",
          "name": "COT"
        },
        {
          "locale": "ro-RO",
          "name": "COT"
        },
        {
          "locale": "ru-RU",
          "name": "COT"
        },
        {
          "locale": "sk-SK",
          "name": "COT"
        },
        {
          "locale": "sl-SI",
          "name": "COT"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COT"
        },
        {
          "locale": "sv-SE",
          "name": "COT"
        },
        {
          "locale": "th-TH",
          "name": "COT"
        },
        {
          "locale": "tr-TR",
          "name": "COT"
        },
        {
          "locale": "uk-UA",
          "name": "COT"
        },
        {
          "locale": "vi-VN",
          "name": "COT"
        },
        {
          "locale": "zh-CN",
          "name": "COT"
        },
        {
          "locale": "zh-HK",
          "name": "COT"
        },
        {
          "locale": "zh-TW",
          "name": "COT"
        }
      ],
      "signature": {
        "display": "COT(number)",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "COT",
      "version_marker": null,
      "xlcall": {
        "code": "550",
        "symbol": "xlfCot"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/cot-function-c446f34d-6fe4-40dc-84f8-cf59e5f5e31a"
  },
  "try_it": {
    "formula": "=COT(1)"
  },
  "url": "https://handbook.dnacalc.com/functions/COT.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "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_build": "16.0 build 19929",
      "platform": "Windows, bitness not recorded, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COT.json"
      ]
    },
    {
      "behaviour": "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_build": "16.0 build 20131",
      "platform": "Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COT.json"
      ]
    },
    {
      "behaviour": "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.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.COT.json"
      ]
    }
  ]
}