Math & Trig

TANH Formula

TANH returns the hyperbolic tangent of a number, defined as SINH(x)/COSH(x). It produces an S-shaped curve (sigmoid) that maps any real number to the range -1 to 1. TANH is widely used in machine learning as an activation function, in signal processing, and in modeling systems with saturation behavior.

Syntax

TANH(number)
ParameterDescription
number Parameter of the TANH function.
Try TANH in Viztab — free, no signup

Examples

TANH of 0

Formula
=TANH(0)
Returns 0. TANH passes through the origin, with its steepest slope there.

TANH of large number

Formula
=TANH(5)
Returns ~0.99991. TANH quickly approaches 1 for positive inputs and -1 for negative inputs.

Activation function

Formula
=TANH(A1*B1+C1)
Applies a TANH activation to a weighted input (A1×weight + bias). Commonly used in neural network calculations in spreadsheets.

Common Errors

#VALUE!

Non-numeric input returns #VALUE!.

Tips

Output range is -1 to 1

TANH always returns a value between -1 and 1, approaching these limits asymptotically. This makes it a natural normalizing function.

Machine learning connection

TANH is a popular activation function in neural networks. It's a scaled and shifted version of the logistic sigmoid: TANH(x) = 2×sigmoid(2x) - 1.

Rapid saturation

TANH saturates quickly: by x=3, it's already at 0.995. For practical purposes, TANH(x) ≈ 1 when x > 3 and ≈ -1 when x < -3.

Try TANH in Viztab

Import your data and use TANH with 370+ other formulas. No signup required.

Open Viztab

Related Formulas