Excel 16.0 build 19929
Windows, bitness not recorded, CPU not recorded
42 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.
Math and trigonometry functions
Close: 58 of 39,031 recorded answers differ in the last bits, worst 1 ULP
Everything else matches (39,028 in the answer bank and 3 workbook cells). Last-bit means a finite number within 16 ULP of Excel's. How we measure this · See the Rust code
| Language | Name in Excel |
|---|---|
| Arabic | TANH |
| Bulgarian | TANH |
| Czech | TGH |
| Danish | TANH |
| German | TANH |
| Greek | TANH |
| English (Australia) | TANH |
| English (United Kingdom) | TANH |
| English (United States) | TANH |
| Spanish | TANH |
| Estonian | TANH |
| Finnish | TANH |
| French | TANH |
| Hebrew | TANH |
| Croatian | TANH |
| Hungarian | TANH |
| Indonesian | TANH |
| Italian | TANH |
| Japanese | TANH |
| Korean | TANH |
| Lithuanian | TANH |
| Latvian | TANH |
| Norwegian | TANH |
| Dutch | TANH |
| Polish | TANH |
| Portuguese (Brazil) | TANH |
| Portuguese (Portugal) | TANH |
| Romanian | TANH |
| Russian | TANH |
| Slovak | TANH |
| Slovenian | TANH |
| Serbian (Latin) | TANH |
| Swedish | TANH |
| Thai | TANH |
| Turkish | TANH Denklemi |
| Ukrainian | TANH |
| Vietnamese | TANH |
| Chinese (Simplified) | TANH |
| Chinese (Hong Kong) | TANH |
| Chinese (Traditional) | TANH |
Names from Microsoft's support site.
TANH(number)
TANH(number) is the hyperbolic tangent:
tanh x = sinh x / cosh x = (e^x - e^(-x)) / (e^x + e^(-x)) = (e^(2x) - 1) / (e^(2x) + 1)
tanh is
meromorphic with poles only at odd multiples of i*pi/2 — nowhere on the real line. This is
the sharpest contrast with TAN, which has a pole every pi.(-1, 1). Strictly increasing, hence a bijection from R onto
(-1, 1), which is why ATANH has domain (-1, 1) and blows up at both ends.tanh x -> +1 as x -> +infinity and -> -1 as x -> -infinity, and the
approach is exponential: 1 - tanh x ~ 2 e^(-2x).tanh x = x - x^3/3 + 2 x^5/15 - 17 x^7/315 + ..., radius of
convergence pi/2 (the distance to the nearest complex pole). The coefficients are those of
tan with alternating signs, which is the series form of tanh x = -i tan(ix).1 - tanh^2 x = sech^2 x, the hyperbolic counterpart of the derivative relation
for tan.Microsoft's article gives the signature and states the defining formula. Retrieval of that page for this entry was blocked by the upstream host (HTTP 403), so the documented content is stated here as documented behaviour and should be re-checked against the live article. The mathematics above is from the standard literature, not from the article.
| Argument | Meaning | Default |
|---|---|---|
number | Any real number. Required. | — |
No units. TANH is not an angle function and nothing in the RADIANS/DEGREES apparatus
applies to it.
Returns Number, always in (-1, 1) mathematically — and in floating point, exactly 1 or
-1 for arguments beyond the saturation point, because 1 - 2e^(-2x) rounds to 1 once the
correction falls below half an ULP of 1.
Small arguments round-trip: for |x| small enough that x^3/3 is negligible, the correctly
rounded tanh x is x, so subnormals pass through.
| Error | Condition | Source |
|---|---|---|
#VALUE! | The argument does not convert to a number | Shared coercion rules |
| propagated | An error value in the argument is returned unchanged | Shared coercion rules |
TANH is the well-conditioned member of its family, but there is exactly one way to get it
badly wrong and it is the obvious way.
Do not compute TANH as SINH(x)/COSH(x). Both intermediates overflow at a moderate
argument while their ratio remains a perfectly ordinary number near 1. A naive quotient
produces #NUM!, an infinity, or a NaN — depending on the host's overflow policy — for
arguments where the answer is simply 1. The same objection applies to
(exp(x) - exp(-x))/(exp(x) + exp(-x)).
The standard three-band scheme (Cody & Waite; fdlibm's tanh):
|x|: return x (with the inexact flag raised where the platform cares), because
the correction is below rounding.|x|: use expm1. With t = expm1(2|x|), tanh|x| = t/(t + 2); or
with t = expm1(-2|x|), tanh|x| = -t/(t + 2). The expm1 form is what keeps relative
accuracy near zero, where the direct exponential quotient would cancel 1 against 1.|x|: return 1 (with the sign applied). There is a well-defined threshold above
which the correctly rounded result is exactly 1, and computing anything at all beyond it is
wasted work — and, if done naively, dangerous.Near-zero cancellation, stated precisely. In (e^x - e^(-x))/(e^x + e^(-x)) the numerator
suffers the same total cancellation as in SINH: both exponentials tend to 1 and their
difference is 2x. The denominator is fine. So the relative error of the naive form grows
without bound as x -> 0, exactly where the function is most linear and a user is most likely
to trust it. The expm1 reformulation is not an optimization; it is the difference between a
correct and an incorrect function on a large part of its useful domain.
Symmetry. Odd function: compute on |x|, apply the sign. An implementation that does so
gets exact antisymmetry for free.
Why TANH is easy where TAN is hard. There is no argument reduction. There is no pi.
There is no cancellation in the reduced argument because there is no reduced argument. Every
difficulty TAN has comes from mapping the input into a fundamental domain, and TANH has no
fundamental domain to map into. This is worth stating because the two functions are usually
taught as siblings, and numerically they have almost nothing in common.
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.
TANH · 3 lines · calc-func/src/catalogue/math.rs on GitHub21 tanh "TANH" (1, 1) [V "number"] |s, a, sv| {
raw(s, a, ExcelRealPolicy::SATURATE_SIGN, k::tanh::tanh_kernel)
}
raw catalogue/mathcosh_kernel ported/coshbinary_with ported/excel_numericexcel_expm1_internal ported/excel_numericexpm1_internal_graph ported/excel_numericexcel_x87_add ported/excel_numericexcel_x87_sub ported/excel_numericexcel_x87_mul ported/excel_numericexcel_x87_div ported/excel_numericmul ported/excel_numeric/x87add ported/excel_numeric/x87sub ported/excel_numeric/x87div ported/excel_numeric/x87pow2_positive ported/excel_numeric/x87_chainspow2 ported/excel_numeric/x87_chainsexp_ext ported/excel_numeric/x87_chainsexp_with ported/excel_numeric/x87_chainsexcel_exp ported/excel_numeric/x87_chainslog_with ported/excel_numeric/x87_chainsexcel_log ported/excel_numeric/x87_chainssinh_kernel ported/sinhtanh_kernel ported/tanhNo implementation has been published with a Handbook test suite for this function.
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 build | Platform and CPU | Captured inputs |
|---|---|---|
| 19929 | Windows, bitness not recorded, CPU not recorded | 42 |
| 20430 | Windows, 64-bit, CPU not recorded | 39,028 |
Agreement on these compared inputs does not establish agreement on unmeasured inputs.
Recorded environments and comparison details.
Windows, bitness not recorded, CPU not recorded
42 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.
Windows, 64-bit, CPU not recorded
39,028 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.
SINH and COSH — the numerator and denominator of the defining quotient. Note that
TANH is well behaved precisely where SINH overflows: the two exponentials that overflow
individually cancel in the ratio.ATANH — the inverse, ATANH(y) = ln((1+y)/(1-y))/2, with domain (-1, 1) and poles at
both endpoints. The saturation of TANH and the singularity of ATANH are the same fact seen
from two sides: once TANH has rounded to 1, the round trip through ATANH is lost.TAN — the circular sibling, tanh x = -i tan(ix). Bounded and pole-free versus
unbounded and pole-ridden.SECH — 1 - TANH^2, and the reciprocal of COSH.TAN, by name; and SIGN, by shape, since TANH of a large argument is
a smooth saturating stand-in for the sign function. That resemblance is the reason TANH is
the classical neural-network activation.No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents