Hyperbolic Tangent (tanh)
tanh(x) = sinh(x)/cosh(x) = (e^x - e^(-x))/(e^x + e^(-x)). Range (-1, 1). Used as an activation function in neural networks and in special relativity (v/c = tanh(φ)).
Did our AI summary help? Let us know.
tanh is preferred over sigmoid in neural networks — zero-centered output helps training. v/c = tanh(φ) where φ is rapidity — special relativity expresses velocity via tanh. d/dx[tanh(x)] = 1 - tanh²(x) — the derivative is simple and always positive.
Ready to run the numbers?
Why: tanh is the standard activation function in many neural networks — bounded, zero-centered, and smooth. Also appears in special relativity (velocity = c·tanh(rapidity)).
How: tanh(x) = sinh(x)/cosh(x). As x → ±∞, tanh(x) → ±1. The derivative d/dx[tanh(x)] = sech²(x) = 1 - tanh²(x) — useful for backpropagation.
Run the calculator when you are ready.
Examples — Click to Load
Hyperbolic Value Breakdown
All 6 Hyperbolic Functions
|tanh| vs |sinh| vs cosh
Calculation Breakdown
For educational and informational purposes only. Verify with a qualified professional.
🧮 Fascinating Math Facts
tanh is a popular neural network activation function — bounded and zero-centered.
— Deep Learning textbooks
In special relativity, v/c = tanh(φ) where φ is rapidity. tanh maps rapidity to velocity.
— MIT OCW
Key Takeaways
- • tanh(x) = sinh(x)/cosh(x) = (e^x - e^(-x))/(e^x + e^(-x)) — bounded output
- • Range: (-1, 1). Odd function: tanh(-x) = -tanh(x). As x→∞, tanh→1; as x→-∞, tanh→-1
- • tanh(0) = 0. For small x, tanh(x) ≈ x. S-shaped (sigmoid) curve
- • ML activation function — used in neural networks for bounded, zero-centered output
- • Fluid dynamics — appears in boundary layer theory, viscous flow, and relativistic velocity (v/c = tanh)
Did You Know?
How the Hyperbolic Tangent Works
tanh(x) = sinh(x)/cosh(x) is the ratio of the hyperbolic sine to cosine. Unlike sinh and cosh which grow exponentially, tanh is bounded between -1 and 1 — a sigmoid (S-shaped) function.
Exponential Definition
tanh(x) = (e^x - e^(-x))/(e^x + e^(-x)). For x > 0, the numerator and denominator are both positive; the ratio is < 1 and approaches 1 as x→∞. For x < 0, tanh is negative. The range (-1, 1) is never attained exactly for finite x.
Relation to Regular Trig
tan(ix) = i·tanh(x) and tanh(ix) = i·tan(x). Like tan(θ), tanh has no period — it increases monotonically. The derivative d/dx[tanh(x)] = sech²(x) = 1 - tanh²(x).
Geometric Interpretation & Applications
On the unit hyperbola, tanh(t) gives the slope of the line from the origin to (cosh(t), sinh(t)). In ML, tanh squashes inputs to (-1,1). In relativity, rapidity φ satisfies v = c·tanh(φ).
Expert Tips
Memorize Key Values
tanh(0)=0, tanh(1)≈0.762, tanh(2)≈0.964, tanh(3)≈0.995. For small x, tanh(x)≈x. Use Sinh and Cosh for the components.
ML Activation Function
tanh outputs in (-1,1), zero-centered (unlike sigmoid). Gradient: 1-tanh²(x). Compare with Tangent Calculator — tan is unbounded.
Special Relativity
Velocity v in units of c: v/c = tanh(φ) where φ is rapidity. Rapidity adds: φ₁+φ₂ gives combined velocity. tanh keeps v < c.
Derivative & Identity
d/dx[tanh(x)] = sech²(x) = 1 - tanh²(x). The identity 1 - tanh²(x) = sech²(x) is useful for integration.
Why Use This Calculator vs. Other Tools?
| Feature | This Calculator | Scientific Calculator | Manual Computation |
|---|---|---|---|
| All 6 hyperbolic functions at once | ✅ | ❌ One at a time | ❌ |
| Exponential form (e^x, e^(-x)) | ✅ | ❌ | ✅ Slow |
| Visual charts & breakdown | ✅ | ❌ | ❌ |
| Step-by-step explanation | ✅ | ❌ | ✅ |
| Identity cosh² - sinh² = 1 check | ✅ | ❌ | ⚠️ Manual |
| Copy & share results | ✅ | ❌ | ❌ |
| Screenshot-ready summary | ✅ | ❌ | ❌ |
| Preset examples | ✅ | ❌ | ❌ |
Frequently Asked Questions
What is the range of tanh?
tanh(x) has range (-1, 1) — open interval. tanh never equals exactly 1 or -1 for finite x, but approaches these limits as x→±∞. This bounded range makes it ideal for neural network activations.
Why is tanh used in neural networks?
tanh outputs in (-1,1), is zero-centered (mean ~0), and has smooth gradients. The derivative 1-tanh²(x) is easy to compute. ReLU is now more common in hidden layers, but tanh is still used in RNNs and output layers.
What is the derivative of tanh?
d/dx[tanh(x)] = sech²(x) = 1 - tanh²(x). This follows from the quotient rule: (sinh'cosh - cosh'sinh)/cosh² = (cosh² - sinh²)/cosh² = 1/cosh² = sech².
How does tanh relate to special relativity?
Velocity v (in units of c) satisfies v/c = tanh(φ) where φ is rapidity. Rapidity adds linearly: tanh(φ₁+φ₂) gives the relativistic velocity combination. This keeps v < c.
What is tanh in terms of exponentials?
tanh(x) = (e^x - e^(-x))/(e^x + e^(-x)). Equivalently, tanh(x) = 1 - 2/(e^(2x)+1). The second form shows the sigmoid shape clearly.
Why is tanh called odd?
tanh(-x) = -tanh(x). The graph has rotational symmetry about the origin. This follows from sinh(-x)/cosh(-x) = -sinh(x)/cosh(x).
Where does tanh appear in fluid dynamics?
In boundary layer theory, the velocity profile in laminar flow can involve tanh. The Blasius solution for flow over a flat plate uses functions related to tanh. Viscous flow solutions often involve hyperbolic functions.
What is the inverse of tanh?
artanh(x) = (1/2)ln((1+x)/(1-x)) for |x| < 1. Also written as atanh. The inverse exists because tanh is strictly increasing on (-∞, ∞).
Hyperbolic Tangent by the Numbers
Official & Educational Sources
Disclaimer: This calculator provides results based on standard IEEE 754 floating-point arithmetic. Results are accurate to approximately 15 significant digits. For mission-critical applications (ML training, physics simulations), always verify with certified computational tools. Not a substitute for professional analysis.
Related Calculators
Hyperbolic Cosine (cosh) Calculator
Calculate the hyperbolic cosine cosh(x) = (e^x + e^(-x))/2. Get cosh, sinh, and tanh values with Bar and Doughnut charts, and step-by-step solutions.
MathematicsHyperbolic Sine (sinh) Calculator
Calculate the hyperbolic sine sinh(x) = (e^x - e^(-x))/2. Get sinh, cosh, and tanh values with Bar and Doughnut charts, and step-by-step solutions.
MathematicsArccosecant Calculator
Calculate arccosecant (inverse cosecant) for |x| >= 1. arccsc(x) = arcsin(1/x). Get angle in degrees or radians with domain check, Bar and Doughnut charts...
MathematicsArccosine Calculator
Calculate the arccosine (inverse cosine) of any value in [-1, 1]. Get angle in degrees or radians with quadrant, related arcsin and arctan values, Bar and...
MathematicsArccotangent Calculator
Calculate the arccotangent (inverse cotangent) of any value. arccot(x) = arctan(1/x) adjusted. Get angle in degrees or radians with related values, Bar and...
MathematicsArcsecant Calculator
Calculate the arcsecant (inverse secant) for |x| >= 1. arcsec(x) = arccos(1/x). Get angle in degrees or radians with domain check, Bar and Doughnut charts...
Mathematics