Tanh
Calculate tanh(x) = (eˣ - e⁻ˣ)/(eˣ + e⁻ˣ) for any real number. Free online hyperbolic tangent calculator with interactive graph and instant results.
About This Calculator
The hyperbolic tangent function, denoted tanh(x), is a fundamental hyperbolic function defined as the ratio of hyperbolic sine to hyperbolic cosine: tanh(x) = sinh(x) / cosh(x) = (e^x - e^(-x)) / (e^x + e^(-x)). It is a smooth, sigmoid-shaped function that maps all real numbers to the range (-1, 1).
Unlike regular tangent which has vertical asymptotes, tanh has horizontal asymptotes at y = +/-1. The function is odd: tanh(-x) = -tanh(x), and passes through the origin with a slope of 1 (the derivative at x = 0 is 1). It approaches its asymptotes exponentially: for large x, 1 - tanh(x) ≈ 2e^(-2x).
Tanh is critically important in machine learning as an activation function in neural networks, preferred over the logistic sigmoid because its outputs are zero-centered, which helps mitigate vanishing gradients. It also appears in physics (relativistic velocity addition), engineering (control theory transfer functions), and fluid dynamics (boundary layer profiles).
Frequently Asked Questions
What is hyperbolic tangent (tanh)?
Hyperbolic tangent (tanh) is a hyperbolic function defined as tanh(x) = sinh(x) / cosh(x) = (e^x - e^(-x)) / (e^x + e^(-x)). It outputs values between -1 and 1, making it a sigmoid-shaped function widely used in machine learning.
How does tanh differ from regular tangent?
Regular tangent (tan) is periodic with period pi and has vertical asymptotes at +/-90 deg, +/-270 deg, etc. Hyperbolic tangent (tanh) is not periodic, has horizontal asymptotes at y = +/-1, and is smooth across all real numbers.
What is the range and domain of tanh?
The domain of tanh is all real numbers (-∞, +∞). The range is (-1, 1). tanh(0) = 0, and as x approaches +∞, tanh(x) approaches 1. As x approaches -∞, tanh(x) approaches -1. Common values: tanh(1) ≈ 0.7616, tanh(2) ≈ 0.964.
Where is tanh used in real life?
Tanh is widely used as an activation function in neural networks and deep learning because its output is zero-centered (unlike sigmoid). It is also used in physics (velocity in special relativity), in control systems engineering, and in fluid dynamics calculations.
What is the formula for tanh?
Tanh can be expressed in multiple forms: tanh(x) = sinh(x) / cosh(x) = (e^x - e^(-x)) / (e^x + e^(-x)) = 1 - 2/(e^(2x) + 1). The derivative is d/dx tanh(x) = sech^2(x) = 1 - tanh^2(x).
Is this tanh calculator free?
Yes, all calculators on Calculy are completely free to use. No registration or download required.