{
  "category": "Math and trigonometry functions",
  "display_name": "TAN",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.TAN",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20131",
        "20430",
        "?"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 2114,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 2114,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 2,114 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,117 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#L78-L80"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/math::raw",
        "ported/excel_numeric::tan_with",
        "ported/excel_numeric::excel_tan",
        "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/tan::tan_kernel"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/math.rs#L78-L80",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 2,117 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.TAN.json",
  "name": "TAN",
  "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- **`SIN` and `COS`** — `TAN = SIN/COS` mathematically, though a good implementation does not\n  compute it that way (see below).\n- **`ATAN` and `ATAN2`** — the inverses. `ATAN` returns the principal branch `(-pi/2, pi/2)`;\n  `ATAN2` recovers the quadrant from a coordinate pair and is the function to use when the\n  angle of a vector is wanted.\n- **`TANH`** — the hyperbolic sibling, related by `tan(ix) = i tanh(x)`. The contrast is\n  instructive: `TANH` is bounded and has no real poles, so it is numerically placid where `TAN`\n  is not.\n- **`RADIANS` / `DEGREES` / `PI`** — the conversion apparatus.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`TAN` inherits every argument-reduction difficulty of `SIN` (see that page for the three-regime\nscheme, Cody-Waite and Payne-Hanek) and adds one of its own: **conditioning near the poles.**\n\n**The conditioning statement.** The relative condition number of tangent is\n`x / (sin x cos x)`, which blows up as `x` approaches a pole. Concretely: if the reduced\nargument `r` — the distance from `x` to the nearest odd multiple of `pi/2` — carries a relative\nerror `eps`, then `tan x` carries a relative error of roughly `eps` as well, but `r` itself is\nthe result of a catastrophic cancellation. For an argument near a pole, almost all the\nsignificant digits of `r` came from the bits of `pi` used in the reduction. An implementation\nwhose stored `pi` is short delivers a `TAN` near the poles whose leading digits are noise.\n\nThis is the practical reason the trig family's substrate matters more for `TAN` than for `SIN`.\nSine is bounded and locally linear at its zeros, so a reduction error shows up as a small\nabsolute error. Tangent multiplies the same reduction error by an unbounded factor.\n\n**Do not compute `TAN` as `SIN/COS`.** Two separately rounded transcendental evaluations,\ndivided, give you both errors plus the division's; worse, near a pole the `COS` in the\ndenominator is itself the badly conditioned quantity, so the composition compounds exactly the\nerror you most wanted to control. The standard formulations (Cody & Waite; `fdlibm`'s\n`__kernel_tan`) evaluate a single rational approximation on the reduced argument and select\nbetween `t` and `-1/t` from the parity of the reduction quotient, so the reduction is performed\nonce and the reciprocal branch reuses it.\n\n**Testing implication.** A vector suite for `TAN` that samples uniformly over a wide interval\nis testing the easy part. The informative vectors are: arguments within a few ULP of\n`k*pi + pi/2` for a spread of `k`; arguments within a few ULP of `k*pi`; and the large-argument\nwitnesses from the reduction literature.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns `Number`.\n\nThe pole is the edge that has no clean answer. **No binary64 number is an odd multiple of\n`pi/2`**, so no representable argument sits exactly on a pole: `TAN` always has a finite answer\nto give. What it gives near a pole is enormous and almost entirely determined by how accurately\nthe implementation knows the distance from the argument to the true pole — see *Numerical\nnotes*. A reader who expects `TAN(PI()/2)` to be an error or an infinity should expect neither;\n`PI()/2` is a double that differs from the real `pi/2`, and the tangent of *that* double is a\nlarge finite number.\n\n\n### Errors\n\nMicrosoft's page lists no errors for `TAN`.\n\n\n",
    "sources": "\n- Microsoft, \"TAN function\" —\n  <https://support.microsoft.com/en-us/office/tan-function-08851a40-179f-4052-b789-d7f699447401>\n  (signature, the radian convention, the degrees-conversion remark; no error conditions are\n  listed there).\n- Abramowitz & Stegun, *Handbook of Mathematical Functions*, chapter 4 section 4.3 — tangent's\n  series, period, poles and identities.\n- Cody & Waite, *Software Manual for the Elementary Functions* — the rational-kernel\n  formulation and the reduction that selects between tangent and cotangent branches.\n- `fdlibm` `__kernel_tan` and `__rem_pio2`; Payne & Hanek (1983) — the reference treatment of\n  reduction and the reciprocal branch.\n- Handbook evidence record `EV-MATH-0004` (subjects include `FUNC.TAN`) — substrate\n  identification for the trig six, with its own reader warning.\n- Handbook projections `data/functions/FUNC.TAN.json` (arity, classification,\n  `real_result_policy` with `arg_domain_guard=circular_trig_overflow` and `non_finite=num`) and\n  `data/presence/FUNC.TAN.json`.\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md).\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 | 35 |\n| 20131 | Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics | 890 |\n| 20430 | Windows, 64-bit, CPU not recorded | 1,224 |\n\n- XC-TAN-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-TAN-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.TAN.json).",
    "what-it-does": "\n`TAN(number)` is the circular tangent of an angle measured in **radians**:\n\n    tan x  =  sin x / cos x\n\n- **Domain**: all reals except the odd multiples of `pi/2`, where `cos x = 0`.\n- **Range**: all of the extended reals — tangent is surjective onto `(-infinity, +infinity)` on\n  each of its branches.\n- **Poles**: simple poles at `x = (2k+1) * pi/2` for every integer `k`. The function changes\n  sign across each pole: `tan(x) -> +infinity` from the left of `pi/2` and `-infinity` from the\n  right. These are genuine poles of the real function, not branch cuts; tangent is meromorphic.\n- **Period**: `pi`, not `2*pi`. This is the identity most often mis-remembered, and it is why a\n  correct implementation reduces modulo `pi/2` and then selects between a tangent and a\n  cotangent kernel.\n- **Parity**: odd.\n- **Series about zero**: `tan x = x + x^3/3 + 2 x^5/15 + 17 x^7/315 + ...`, with radius of\n  convergence `pi/2` — the distance to the nearest pole. The coefficients involve the Bernoulli\n  numbers; A&S chapter 4 gives the closed form.\n- **Zeros**: the integer multiples of `pi`, same as sine.\n\nThe identity that matters for implementation is the half-angle relation\n`tan(x + pi/2) = -1/tan(x)` — the reason a tangent kernel and its reciprocal are the same\nkernel with a branch selector.\n\nMicrosoft's page states one remark and it is the calling convention: the argument is in\nradians; convert degrees by multiplying by `PI()/180` or by using `RADIANS`.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Default |\n|---|---|---|\n| `number` | The angle, in radians. Required. | — |\n\nThe misunderstood position, again, is the units. `TAN(45)` is not one.\n\n\n"
  },
  "signature": {
    "display": "TAN(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": "NumToNum",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Tangent of an angle in radians",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the tangent of a number",
        "microsoft_url": "https://support.microsoft.com/en-us/office/tan-function-08851a40-179f-4052-b789-d7f699447401"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "TAN"
        },
        {
          "locale": "bg-BG",
          "name": "TAN"
        },
        {
          "locale": "cs-CZ",
          "name": "TAN"
        },
        {
          "locale": "da-DK",
          "name": "TAN"
        },
        {
          "locale": "de-DE",
          "name": "TAN"
        },
        {
          "locale": "el-GR",
          "name": "TAN"
        },
        {
          "locale": "en-AU",
          "name": "TAN"
        },
        {
          "locale": "en-GB",
          "name": "TAN"
        },
        {
          "locale": "en-US",
          "name": "TAN"
        },
        {
          "locale": "es-ES",
          "name": "TAN"
        },
        {
          "locale": "et-EE",
          "name": "TAN"
        },
        {
          "locale": "fi-FI",
          "name": "TAN"
        },
        {
          "locale": "fr-FR",
          "name": "TAN"
        },
        {
          "locale": "he-IL",
          "name": "TAN"
        },
        {
          "locale": "hr-HR",
          "name": "TAN"
        },
        {
          "locale": "hu-HU",
          "name": "TAN"
        },
        {
          "locale": "id-ID",
          "name": "TAN"
        },
        {
          "locale": "it-IT",
          "name": "TAN"
        },
        {
          "locale": "ja-JP",
          "name": "TAN"
        },
        {
          "locale": "ko-KR",
          "name": "TAN"
        },
        {
          "locale": "lt-LT",
          "name": "TAN"
        },
        {
          "locale": "lv-LV",
          "name": "TAN"
        },
        {
          "locale": "nb-NO",
          "name": "TAN"
        },
        {
          "locale": "nl-NL",
          "name": "TAN"
        },
        {
          "locale": "pl-PL",
          "name": "TAN"
        },
        {
          "locale": "pt-BR",
          "name": "TAN"
        },
        {
          "locale": "pt-PT",
          "name": "TAN"
        },
        {
          "locale": "ro-RO",
          "name": "TAN"
        },
        {
          "locale": "ru-RU",
          "name": "TAN"
        },
        {
          "locale": "sk-SK",
          "name": "TAN"
        },
        {
          "locale": "sl-SI",
          "name": "TAN"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "TAN"
        },
        {
          "locale": "sv-SE",
          "name": "TAN"
        },
        {
          "locale": "th-TH",
          "name": "TAN"
        },
        {
          "locale": "tr-TR",
          "name": "TAN"
        },
        {
          "locale": "uk-UA",
          "name": "TAN"
        },
        {
          "locale": "vi-VN",
          "name": "TAN"
        },
        {
          "locale": "zh-CN",
          "name": "TAN"
        },
        {
          "locale": "zh-HK",
          "name": "TAN"
        },
        {
          "locale": "zh-TW",
          "name": "TAN"
        }
      ],
      "signature": {
        "display": "TAN(number)",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "TAN",
      "version_marker": null,
      "xlcall": {
        "code": "17",
        "symbol": "xlfTan"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/tan-function-08851a40-179f-4052-b789-d7f699447401"
  },
  "try_it": {
    "formula": "=TAN(45)"
  },
  "url": "https://handbook.dnacalc.com/functions/TAN.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "35 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.TAN.json"
      ]
    },
    {
      "behaviour": "890 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.TAN.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.TAN.json"
      ]
    }
  ]
}