{
  "category": "Math and trigonometry functions",
  "display_name": "COTH",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.COTH",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 56,
      "matched": 40185,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 40241,
      "unread": 0,
      "worst_ulp": 2
    },
    "detail": "Everything else matches (40,241 in the answer bank and 3 workbook cells). Last-bit means a finite number within 16 ULP of Excel's.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "close",
    "state_label": "Close: last-bit deviations remain",
    "summary": "Close: 56 of 40,244 recorded answers differ in the last bits, worst 2 ULP",
    "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#L67-L67",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/coth.rs#L4-L13"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/math::unary",
        "ported/cosh::cosh_kernel",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_expm1_internal",
        "ported/excel_numeric::expm1_internal_graph",
        "ported/excel_numeric::excel_x87_add",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric::excel_x87_recip",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::add",
        "ported/excel_numeric/x87::sub",
        "ported/excel_numeric/x87::div",
        "ported/excel_numeric/x87::recip",
        "ported/excel_numeric/x87_chains::pow2_positive",
        "ported/excel_numeric/x87_chains::pow2",
        "ported/excel_numeric/x87_chains::exp_ext",
        "ported/excel_numeric/x87_chains::exp_with",
        "ported/excel_numeric/x87_chains::excel_exp",
        "ported/excel_numeric/x87_chains::log_with",
        "ported/excel_numeric/x87_chains::excel_log",
        "ported/sinh::sinh_kernel",
        "ported/tanh::tanh_kernel"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L67-L67",
      "state": "close",
      "suite": null,
      "summary": "Close: 56 of 40,244 recorded answers differ in the last bits, worst 2 ULP"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.COTH.json",
  "name": "COTH",
  "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\n- **`TANH`** — the reciprocal, and the numerically well-behaved member of the pair. Any\n  accurate `COTH` is `1/TANH` computed carefully, or the Laurent series near zero.\n- **`SINH`, [COSH](FUNC.COSH.md)** — the ratio the documentation names. Evaluating `COTH` that\n  way is what produces the `Inf/Inf` the saturation exists to catch.\n- **[CSCH](FUNC.CSCH.md)** — the other hyperbolic reciprocal in the same 2013 batch, sharing the\n  pole at zero, the documented constraint, and the `arg_domain_guard=none` axis value. Read the\n  two pages together: they diverge from their documentation in the same way.\n- **`ACOTH`** — not an Excel function. There is no inverse hyperbolic cotangent on the\n  worksheet surface; `ATANH(1/x)` is the standard substitute and inherits `ATANH`'s own\n  accuracy problem near `±1`.\n- **[COT](FUNC.COT.md)** — the circular partner, `coth x = i·cot(ix)`. Same `1/x` leading term,\n  same documented bound, and the only member of the pair whose zero case is documented.\n- **`IMCOT`** — the complex cotangent; there is no `IMCOTH`.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\nThree regimes, and the middle one is the only place a naive route is safe.\n\n**Near zero.** `1/tanh x` is well conditioned as a *value* — `tanh x → x`, so `coth x → 1/x` —\nbut the interesting quantity is often `coth x - 1/x`, which cancels catastrophically. The\nremedy is the Laurent series `1/x + x/3 - x³/45 + …` (A&S 4.5.67), used below roughly `2^-13`,\nwhere it is both cheaper and more accurate than any division.\n\n**Moderate.** `coth x = 1/tanh x`, with `tanh` computed by the standard `expm1` form: for\n`t = expm1(2·ABS(x))`, `tanh(ABS(x)) = t/(t + 2)`, hence `coth(ABS(x)) = (t + 2)/t`, sign\nrestored afterwards. This is fdlibm's `s_tanh.c` inverted, and it never forms `e^{2x}`\ndirectly, so it never overflows on the way to a value near 1. Alternatively\n`coth x = 1 + 2/(e^{2x} - 1)` isolates the deviation from the asymptote — the form to use if\nwhat you want is `coth x - 1`.\n\n**Large.** The mathematically correct answer is exactly `sign(x)` once `2e^{-2ABS(x)}` drops\nbelow half an ulp of 1, which happens around `ABS(x) ≈ 19`. Any branch structure that returns\n`sign(x)` above that threshold is correct, whatever route it took to get there. The\n`cosh/sinh` route, by contrast, produces `Inf/Inf = NaN` at around `ABS(x) ≈ 710` — three\norders of magnitude *past* the point where the answer stopped changing. The recorded\nsaturation is a repair applied at the overflow boundary rather than a branch taken at the\nmathematical one, and both give the same answer; the difference is only visible if you ask what\nhappens in between, which nothing on record does.\n\nThe general lesson, and it is a good one: a reciprocal built from `cosh/sinh` fails not because\nthe values are wrong but because the *representation* fails first. Reformulating in terms of\n`expm1` moves the overflow out of the computation entirely.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number` with absolute value strictly greater than 1.\n\n- **`COTH(0)`** — mathematically a pole. Microsoft's `COTH` page, as fetched, states the\n  magnitude constraint and the non-numeric condition but **does not state what happens at\n  zero**, where [COT](FUNC.COT.md)'s page does state `#DIV/0!`. That asymmetry is in the\n  documentation; the Handbook has not checked what Excel returns.\n- **Large positive `x`** — the correct answer is 1.0 exactly, for every `x` above about 19.\n- **Large negative `x`** — the correct answer is −1.0 exactly, symmetrically.\n- **A subtlety the saturation hides.** Because the true value is already exactly `±1` well\n  before any overflow, saturation and correct evaluation agree on the *value* everywhere the\n  overflow could occur. The saturation is therefore not an approximation — it is the right\n  answer reached by an unusual route. What it does hide is whether the documented `2^27` bound\n  fires at all.\n- **Near zero** — `coth x ≈ 1/x`, so `COTH` of a tiny argument is a huge finite number, and\n  overflows only for `ABS(x)` down in the subnormal range.\n\n\n\n### Errors\n\n\nAs documented on Microsoft's `COTH` page:\n\n| Error | Condition |\n|---|---|\n| `#NUM!` | `ABS(number)` is not less than `2^27` |\n| `#VALUE!` | `number` is non-numeric |\n\nNot documented on that page, and therefore not stated here as behaviour: what `COTH(0)`\nreturns. `1/TANH(0)` and `COSH(0)/SINH(0)` are both divisions by zero, so `#DIV/0!` is the\nexpected outcome by analogy with `COT`, but expectation is not evidence and Microsoft's page\ndoes not say it.\n\n\n",
    "sources": "- Handbook evidence record `EV-MATH-0010` — the single live saturation witness, the `Inf/Inf`\n  mechanism, the `SATURATE_SIGN` substrate, and the explicit statement that no count exists.\n  Read its reader warning.\n- Abramowitz & Stegun, chapter 4.5 — hyperbolic identities and the `coth` expansions.\n- fdlibm `s_tanh.c` and Cephes `tanh.c` — the `expm1`-based route this page recommends.\n- Handbook, [COT](FUNC.COT.md) and [CSCH](FUNC.CSCH.md) — the documentation-template siblings;\n  [Coercion and lifting](../model/02-coercion-and-lifting.md).\n- Handbook projections `data/functions/FUNC.COTH.json` (the `arg_domain_guard=none` and\n  `non_finite=saturate_sign` axis values) and `data/presence/FUNC.COTH.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 | 42 |\n| 20430 | Windows, 64-bit, CPU not recorded | 40,241 |\n\n- XC-COTH-001: build 19929 versus build 20430; 2 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.COTH.json).",
    "what-it-does": "\n`COTH(number)` returns the hyperbolic cotangent. Microsoft's page gives the equation as\n`cosh(x)/sinh(x)` and describes the function as the hyperbolic analogue of the ordinary\ncotangent.\n\n    coth x = cosh x / sinh x = 1 / tanh x = (e^{2x} + 1) / (e^{2x} - 1)\n\n| Property | Statement |\n|---|---|\n| Domain | all real `x` except `x = 0` |\n| Range | `(-∞, -1) ∪ (1, ∞)` — the value 1 is a limit, never attained |\n| Parity | odd: `coth(-x) = -coth(x)` |\n| Pole | one, simple, at `x = 0`, with residue 1 |\n| Laurent series at 0 | `coth x = 1/x + x/3 - x³/45 + 2x⁵/945 - …` (A&S 4.5.67) |\n| Asymptote | `coth x → ±1` as `x → ±∞`, exponentially fast: `coth x = 1 + 2e^{-2x} + …` |\n| Fundamental identity | `coth²x - csch²x = 1` |\n| Derivative | `d/dx coth x = -csch²x = 1 - coth²x` |\n| Relation to circular | `coth x = i·cot(ix)` |\n| Complex structure | poles at every `x = ikπ`; periodic with period `πi` |\n\nThe shape is worth holding in mind: two branches, each strictly decreasing, each hugging the\nline `y = ±1` from outside. Because the approach is exponential, `coth x` becomes\nindistinguishable from `1` in binary64 once `x` is above about 19 — `2e^{-2x}` falls below half\nan ulp of 1 there. **From roughly `x = 19` upward the mathematically correct answer already\n*is* exactly 1.0.** That fact does most of the work in the evidence discussion below.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Constraint (as documented) |\n|---|---|---|\n| `number` | The hyperbolic angle. Required. | `ABS(number) < 2^27` |\n\nThe constraint is also, on its face, unnecessary here in a way it is not for the circular\nfunctions: `coth` needs no argument reduction, and its correct value at `2^27` is exactly 1.0.\nA magnitude bound on a hyperbolic function looks like a documentation template applied\nuniformly across the 2013 trigonometric batch rather than a numerical requirement — but that\nreading is a hypothesis, not a finding, and it is on the probe list.\n\n\n"
  },
  "signature": {
    "display": "COTH(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": "Hyperbolic cotangent",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the hyperbolic cotangent of a number",
        "microsoft_url": "https://support.microsoft.com/en-us/office/coth-function-2e0b4cb6-0ba0-403e-aed4-deaa71b49df5"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "COTH"
        },
        {
          "locale": "bg-BG",
          "name": "COTH"
        },
        {
          "locale": "cs-CZ",
          "name": "COTH"
        },
        {
          "locale": "da-DK",
          "name": "COTH"
        },
        {
          "locale": "de-DE",
          "name": "COTH"
        },
        {
          "locale": "el-GR",
          "name": "COTH"
        },
        {
          "locale": "en-AU",
          "name": "COTH"
        },
        {
          "locale": "en-GB",
          "name": "COTH"
        },
        {
          "locale": "en-US",
          "name": "COTH"
        },
        {
          "locale": "es-ES",
          "name": "COTH"
        },
        {
          "locale": "et-EE",
          "name": "COTH"
        },
        {
          "locale": "fi-FI",
          "name": "COTH"
        },
        {
          "locale": "fr-FR",
          "name": "COTH*"
        },
        {
          "locale": "he-IL",
          "name": "COTH"
        },
        {
          "locale": "hr-HR",
          "name": "COTH"
        },
        {
          "locale": "hu-HU",
          "name": "COTH"
        },
        {
          "locale": "id-ID",
          "name": "COTH"
        },
        {
          "locale": "it-IT",
          "name": "COTH"
        },
        {
          "locale": "ja-JP",
          "name": "COTH"
        },
        {
          "locale": "ko-KR",
          "name": "COTH"
        },
        {
          "locale": "lt-LT",
          "name": "COTH"
        },
        {
          "locale": "lv-LV",
          "name": "COTH"
        },
        {
          "locale": "nb-NO",
          "name": "COTH"
        },
        {
          "locale": "nl-NL",
          "name": "COTH"
        },
        {
          "locale": "pl-PL",
          "name": "COTH"
        },
        {
          "locale": "pt-BR",
          "name": "COTH"
        },
        {
          "locale": "pt-PT",
          "name": "COTH"
        },
        {
          "locale": "ro-RO",
          "name": "COTH"
        },
        {
          "locale": "ru-RU",
          "name": "COTH"
        },
        {
          "locale": "sk-SK",
          "name": "COTH"
        },
        {
          "locale": "sl-SI",
          "name": "COTH"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "COTH"
        },
        {
          "locale": "sv-SE",
          "name": "COTH"
        },
        {
          "locale": "th-TH",
          "name": "COTH"
        },
        {
          "locale": "tr-TR",
          "name": "COTH"
        },
        {
          "locale": "uk-UA",
          "name": "COTH"
        },
        {
          "locale": "vi-VN",
          "name": "COTH"
        },
        {
          "locale": "zh-CN",
          "name": "COTH"
        },
        {
          "locale": "zh-HK",
          "name": "COTH"
        },
        {
          "locale": "zh-TW",
          "name": "COTH"
        }
      ],
      "signature": {
        "display": "COTH(number)",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "COTH",
      "version_marker": null,
      "xlcall": {
        "code": "551",
        "symbol": "xlfCoth"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/coth-function-2e0b4cb6-0ba0-403e-aed4-deaa71b49df5"
  },
  "try_it": {
    "formula": "=COTH(1)"
  },
  "url": "https://handbook.dnacalc.com/functions/COTH.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "42 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.COTH.json"
      ]
    },
    {
      "behaviour": "40,241 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.COTH.json"
      ]
    }
  ]
}