Math and trigonometry functions

TAN

Matches all 2,117 recorded answers

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

Local names in 40 languages

Every language in the source keeps the English name.

LanguageName in Excel
ArabicTAN
BulgarianTAN
CzechTAN
DanishTAN
GermanTAN
GreekTAN
English (Australia)TAN
English (United Kingdom)TAN
English (United States)TAN
SpanishTAN
EstonianTAN
FinnishTAN
FrenchTAN
HebrewTAN
CroatianTAN
HungarianTAN
IndonesianTAN
ItalianTAN
JapaneseTAN
KoreanTAN
LithuanianTAN
LatvianTAN
NorwegianTAN
DutchTAN
PolishTAN
Portuguese (Brazil)TAN
Portuguese (Portugal)TAN
RomanianTAN
RussianTAN
SlovakTAN
SlovenianTAN
Serbian (Latin)TAN
SwedishTAN
ThaiTAN
TurkishTAN
UkrainianTAN
VietnameseTAN
Chinese (Simplified)TAN
Chinese (Hong Kong)TAN
Chinese (Traditional)TAN

Names from Microsoft's support site.

What it does

TAN(number)

TAN(number) is the circular tangent of an angle measured in radians:

tan x  =  sin x / cos x
  • Domain: all reals except the odd multiples of pi/2, where cos x = 0.
  • Range: all of the extended reals — tangent is surjective onto (-infinity, +infinity) on each of its branches.
  • Poles: simple poles at x = (2k+1) * pi/2 for every integer k. The function changes sign across each pole: tan(x) -> +infinity from the left of pi/2 and -infinity from the right. These are genuine poles of the real function, not branch cuts; tangent is meromorphic.
  • Period: pi, not 2*pi. This is the identity most often mis-remembered, and it is why a correct implementation reduces modulo pi/2 and then selects between a tangent and a cotangent kernel.
  • Parity: odd.
  • Series about zero: tan x = x + x^3/3 + 2 x^5/15 + 17 x^7/315 + ..., with radius of convergence pi/2 — the distance to the nearest pole. The coefficients involve the Bernoulli numbers; A&S chapter 4 gives the closed form.
  • Zeros: the integer multiples of pi, same as sine.

The identity that matters for implementation is the half-angle relation tan(x + pi/2) = -1/tan(x) — the reason a tangent kernel and its reciprocal are the same kernel with a branch selector.

Microsoft's page states one remark and it is the calling convention: the argument is in radians; convert degrees by multiplying by PI()/180 or by using RADIANS.

Arguments

ArgumentMeaningDefault
numberThe angle, in radians. Required.—

The misunderstood position, again, is the units. TAN(45) is not one.

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.

The pole is the edge that has no clean answer. No binary64 number is an odd multiple of pi/2, so no representable argument sits exactly on a pole: TAN always has a finite answer to give. What it gives near a pole is enormous and almost entirely determined by how accurately the implementation knows the distance from the argument to the true pole — see Numerical notes. A reader who expects TAN(PI()/2) to be an error or an infinity should expect neither; PI()/2 is a double that differs from the real pi/2, and the tangent of that double is a large finite number.

Errors

Microsoft's page lists no errors for TAN.

How to implement

Numerical notes

TAN inherits every argument-reduction difficulty of SIN (see that page for the three-regime scheme, Cody-Waite and Payne-Hanek) and adds one of its own: conditioning near the poles.

The conditioning statement. The relative condition number of tangent is x / (sin x cos x), which blows up as x approaches a pole. Concretely: if the reduced argument r — the distance from x to the nearest odd multiple of pi/2 — carries a relative error eps, then tan x carries a relative error of roughly eps as well, but r itself is the result of a catastrophic cancellation. For an argument near a pole, almost all the significant digits of r came from the bits of pi used in the reduction. An implementation whose stored pi is short delivers a TAN near the poles whose leading digits are noise.

This is the practical reason the trig family's substrate matters more for TAN than for SIN. Sine is bounded and locally linear at its zeros, so a reduction error shows up as a small absolute error. Tangent multiplies the same reduction error by an unbounded factor.

Do not compute TAN as SIN/COS. Two separately rounded transcendental evaluations, divided, give you both errors plus the division's; worse, near a pole the COS in the denominator is itself the badly conditioned quantity, so the composition compounds exactly the error you most wanted to control. The standard formulations (Cody & Waite; fdlibm's __kernel_tan) evaluate a single rational approximation on the reduced argument and select between t and -1/t from the parity of the reduction quotient, so the reduction is performed once and the reciprocal branch reuses it.

Testing implication. A vector suite for TAN that samples uniformly over a wide interval is testing the easy part. The informative vectors are: arguments within a few ULP of k*pi + pi/2 for a spread of k; arguments within a few ULP of k*pi; and the large-argument witnesses from the reduction literature.

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.

TAN · 3 lines · calc-func/src/catalogue/math.rs on GitHub
20 tan "TAN" (1, 1) [V "number"] |s, a, sv| {
    raw(s, a, ExcelRealPolicy::CIRCULAR_TRIG, k::tan::tan_kernel)
}

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 recorded35
20131Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics890
20430Windows, 64-bit, CPU not recorded1,224
  • 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.
  • 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.

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

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 16.0 build 20131

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

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 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

  • SIN and COS — TAN = SIN/COS mathematically, though a good implementation does not compute it that way (see below).
  • ATAN and ATAN2 — the inverses. ATAN returns the principal branch (-pi/2, pi/2); ATAN2 recovers the quadrant from a coordinate pair and is the function to use when the angle of a vector is wanted.
  • TANH — the hyperbolic sibling, related by tan(ix) = i tanh(x). The contrast is instructive: TANH is bounded and has no real poles, so it is numerically placid where TAN is not.
  • RADIANS / DEGREES / PI — the conversion apparatus.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents