Tanh Calculator - Hyperbolic Tangent Function

Use this free tanh calculator to evaluate the hyperbolic tangent of any real number, with sinh, cosh, and an inline identity check to confirm the result.

Updated: June 16, 2026 • Free Tool

Tanh Calculator

Tanh accepts any real x. Values with |x| greater than about 709 overflow IEEE 754 doubles and return an overflow warning.

Results

tanh(x)
0
sinh(x) 0
cosh(x) 0
Identity check: 1 - tanh^2 0

What Is a Tanh Calculator?

A tanh calculator evaluates the hyperbolic tangent of any real number using tanh(x) = (e^x - e^-x) / (e^x + e^-x). The hyperbolic tangent shows up in machine learning as a common activation function and in special relativity as the velocity formula v = c tanh(rapidity). This tanh calculator returns tanh, sinh, and cosh in a single pass, then runs the 1 - tanh^2 = sech^2 identity check on the same numbers so you can see the identity hold in real time.

  • Working with neural network activation functions: Evaluate tanh(x) for a layer's pre-activation values to confirm the output stays in (-1, 1), which is the bounded range the activation function was chosen for.
  • Computing rapidity in special relativity: Convert between velocity and rapidity by reading tanh(rapidity) = v / c, which is the standard hyperbolic form of the relativistic velocity formula.
  • Verifying hyperbolic identities in homework: Confirm identities such as 1 - tanh^2(x) = sech^2(x) or tanh(a + b) = (tanh(a) + tanh(b)) / (1 + tanh(a) tanh(b)) while working through calculus problems.
  • Generating reference values for code: Look up tanh, sinh, and cosh for a list of x values to paste into a spreadsheet, a numerical script, or a physics simulation that needs hyperbolic inputs.

Tanh is one of three core hyperbolic functions, alongside sinh and cosh. The three share the same exponential family and the same set of identities. Tanh behaves a little like ordinary tangent: it is odd, smooth, and crosses zero at the origin. It differs in two important ways: tanh(x) is always strictly between -1 and 1, and tanh and sech combine into the identity 1 - tanh^2 = sech^2, where the right-hand side is the hyperbolic secant squared.

Because tanh is the ratio of sinh to cosh, the Cosh Calculator is the closest neighbour for confirming the matching cosh and sinh values in the same hyperbolic family.

How the Tanh Calculator Works

The calculator reads x from the input field, runs the exponential definition of tanh, and reports the result alongside the matching sinh, cosh, and an inline identity check. Every value is computed in IEEE 754 double-precision arithmetic, and the identity check is recomputed from the same tanh so any rounding error is visible at the bottom of the results panel.

tanh(x) = (e^x - e^-x) / (e^x + e^-x)
  • x: The real number you enter. Tanh accepts any real x, including negatives, zero, and large positives up to about 709 before the exponential overflows.
  • e: Euler's number, approximately 2.7182818284590452. It is the base of the natural exponential that defines the whole hyperbolic family.
  • tanh(x): The hyperbolic tangent of x, equal to the difference of e^x and e^-x divided by their sum. Always strictly between -1 and 1 for real x.

The same calculation chain also returns sinh and cosh for the same x. Sinh uses the difference of the two exponentials divided by 2, and cosh uses the sum divided by 2. Showing all three together makes the identity check at the bottom of the results panel read like a self-test rather than a black-box answer.

Worked example: tanh(1)

x = 1, with the result read to six significant digits

Compute e^1 ≈ 2.7182818 and e^-1 ≈ 0.3678794, then form the ratio: tanh(1) = (2.7182818 - 0.3678794) / (2.7182818 + 0.3678794) ≈ 0.7615942.

tanh(1) ≈ 0.7615942, with sinh(1) ≈ 1.1752012 and cosh(1) ≈ 1.5430806

Tanh of 1 sits between 0 and 1 because the difference of the two exponentials is smaller than their sum, and the resulting ratio equals sinh(1) / cosh(1).

According to Wikipedia: Hyperbolic functions, the hyperbolic tangent is defined as tanh(x) = sinh(x) / cosh(x) = (e^x - e^-x) / (e^x + e^-x) and satisfies the identity 1 - tanh^2(x) = sech^2(x) for every real x

Because tanh is built from e^x and e^-x, the Exponential Notation Calculator is a useful companion when you want to look up the underlying exponential values that drive the result.

Key Concepts Behind Tanh

These four concepts explain what the result means, why tanh is odd, and why the identity check is a useful sanity test for the numbers you just computed.

Exponential definition

Tanh is defined by exponentials: tanh(x) = (e^x - e^-x) / (e^x + e^-x). The same definition is the source of every identity and limit, and it is the form the calculator uses internally to avoid relying on a built-in tanh routine.

Odd function

Tanh is an odd function, so tanh(-x) = -tanh(x) for every real x. Swap the sign of x and the result flips sign too, which is why the calculator shows tanh(-2) = -0.9640276 and tanh(2) = 0.9640276.

Range (-1, 1)

Tanh is always strictly between -1 and 1 for real inputs. The function approaches 1 as x grows and -1 as x decreases, but never reaches either boundary at a finite x. The midpoint 0 occurs at x = 0.

Secant-squared identity

Tanh and the hyperbolic secant combine into 1 - tanh^2(x) = sech^2(x), the hyperbolic analogue of the ordinary tangent identity 1 + tan^2(x) = sec^2(x). The sign changes because the hyperbolic family uses exponentials instead of a unit circle.

The four concepts are linked: the exponential definition produces the odd function, the odd function forces a symmetric range, and the secant-squared identity falls out of the same exponential algebra. The minus sign in 1 - tanh^2 = sech^2 is the only minus in the trig family, because the definition uses a difference and a sum of exponentials rather than a sum of squares.

Tanh's output range (-1, 1) matches the Arccos Calculator's input range, so the bounded-range idea is easy to compare.

How to Use This Tanh Calculator

Working with the calculator only takes a few seconds: enter x, read the three hyperbolic results, and check the identity row to confirm the numbers agree with the 1 - tanh^2 = sech^2 identity.

  1. 1 Enter x: Type a real number in the input box. Use 0, 1, 2, 10, or a negative value to test the typical use cases the page calls out.
  2. 2 Read tanh, sinh, and cosh: The big result tile shows tanh(x) and the rows below show sinh(x) and cosh(x). All three update live as you type or change x.
  3. 3 Check the identity row: Look at the bottom row labelled 'Identity check: 1 - tanh^2'. It should sit at sech^2(x) to within floating-point precision when the inputs are well-behaved.
  4. 4 Try a negative or large positive x: Enter a negative number such as -2 to confirm tanh is odd, or a large value such as 10 to watch tanh approach 1 while sinh and cosh grow toward the same magnitude.
  5. 5 Watch for overflow warnings: If |x| passes about 709, the exponential overflows IEEE 754 doubles and the calculator returns a clear overflow message instead of producing Infinity.

For a catenary cable with parameter a = 50 metres, evaluated at x = 75 metres, the slope at the support point is dy/dx = sinh(x / a) / cosh(x / a) = tanh(x / a). Enter 1.5 and read tanh ≈ 0.9051483 to get the cable's slope.

When a trig problem on a unit circle is asking for an ordinary tangent value, the Tangent Ratio Calculator handles the angular side of the same trig family.

Benefits of This Tanh Calculator

A tanh calculator that shows tanh, sinh, cosh, and an identity check in one panel saves a lot of table-lookup time and removes the most common arithmetic mistakes.

  • Three hyperbolic results in one pass: Get tanh(x), sinh(x), and cosh(x) for the same x without recomputing exponentials in a separate tool.
  • Built-in identity check: The bottom row recomputes 1 - tanh^2 from the displayed value, so a sign error in a derivation shows up as a residual that does not match sech^2(x).
  • Odd-function validation: Type x = 2 and x = -2 to confirm tanh is odd. The two values match in magnitude but flip sign, which is the textbook behaviour of the hyperbolic family.
  • Bounded-range readback: Tanh always sits in (-1, 1), so seeing tanh(50) return 0.9999999999 is a quick check that the input is in the regime where the function is close to its asymptote.
  • Reference values for tables and code: Read off tanh, sinh, and cosh for a list of x values in seconds and paste them into a spreadsheet or a numerical script.

The biggest practical win is the identity check. Recomputing 1 - tanh^2 from the displayed value is the quickest way to spot a sign error, because any deviation from sech^2(x) points to a mistake in the calculation rather than the tool.

For follow-up problems that go from a tangent value back to the principal angle, the Arctan Calculator returns the inverse in degrees, radians, and pi form.

Factors That Affect Your Tanh Result

A handful of factors control what the calculator can return. Knowing them up front prevents the most common mistakes, especially when x is near the overflow boundary or the result is close to the asymptote.

Sign of x

Tanh is odd, so tanh(-x) = -tanh(x). Negative inputs flip the sign of tanh and sinh; cosh and the 1 - tanh^2 check both stay the same because cosh and tanh^2 are even.

Magnitude of x

For |x| greater than about 3, tanh is very close to plus or minus 1 and small changes in x barely change the result. Past x = 10 the values are so close to 1 that they need scientific notation to read the residual.

Floating-point precision

Tanh is computed in IEEE 754 doubles, so the result is exact to about 15 significant digits. Treat the identity check as a sanity check, not an equality test, because tiny residuals are normal at the edge of double precision.

Overflow boundary at |x| near 709

Once |x| is roughly 709, e^x or e^-x exceeds the largest finite double and the calculation overflows. The calculator surfaces this with a clear overflow message rather than returning Infinity.

  • The calculator returns tanh for real x only. It does not compute the complex-valued tanh of a non-real z = a + bi, which would need e^z and e^-z as complex exponentials.
  • The result is rounded to six significant digits in the display. For higher precision, copy the JavaScript formula in the page source and run it in a tool that supports arbitrary-precision arithmetic.

Beyond the limits above, the only thing that materially changes the result is the input itself. Tanh has no parameters, no modes, and no unit settings, so once x is in the input box the four rows in the results panel are fully determined.

According to Wolfram MathWorld: Hyperbolic Tangent, tanh(x) is an odd function, ranges in the open interval (-1, 1), crosses zero at x = 0, and approaches 1 as x grows and -1 as x decreases

According to Paul's Online Math Notes: Hyperbolic Functions, the hyperbolic functions are defined by exponentials and obey identities such as 1 - tanh^2(x) = sech^2(x) and cosh^2(x) - sinh^2(x) = 1

Tanh calculator input panel showing a real x value and matching tanh, sinh, cosh, and identity check result fields
Tanh calculator input panel showing a real x value and matching tanh, sinh, cosh, and identity check result fields

Frequently Asked Questions

Q: What is tanh?

A: Tanh is the hyperbolic tangent, a function defined by tanh(x) = sinh(x) / cosh(x) = (e^x - e^-x) / (e^x + e^-x). It behaves a little like ordinary tangent but uses exponentials instead of angles, and it is odd, smooth, and always strictly between -1 and 1 for any real input.

Q: How do you calculate tanh by hand?

A: Compute e^x and e^-x with a calculator, take their difference to get sinh(x), then divide by cosh(x), which is the sum divided by 2. For x = 0, both exponentials equal 1, so tanh(0) = 0. For x = 1, e^1 - e^-1 divided by e^1 + e^-1 is about 0.7615942.

Q: What is the range of tanh?

A: Tanh of a real number always returns a value strictly between -1 and 1, written as the open interval (-1, 1). The function crosses zero at x = 0, and as x grows it approaches 1 from below; as x decreases it approaches -1 from above. Tanh never reaches 1 or -1 at any finite x.

Q: Is tanh the same as tangent?

A: No. Tangent of an angle uses a unit circle and has vertical asymptotes that send it to plus or minus infinity, while tanh uses exponentials and is bounded between -1 and 1. They share the ratio structure tan = sin / cos, but the hyperbolic version replaces trigonometric circles with the exponential family.

Q: What is tanh of 0?

A: Tanh of 0 is exactly 0, because (e^0 - e^0) / (e^0 + e^0) = 0 / 2 = 0. The tanh calculator returns 0 for x = 0 along with sinh(0) = 0 and cosh(0) = 1, which all satisfy the 1 - tanh^2 = sech^2 identity check at the bottom of the results panel.

Q: Why does tanh approach 1 for large positive x?

A: Tanh equals (e^x - e^-x) / (e^x + e^-x). As x grows, the e^-x term in the numerator and denominator becomes negligible, so the ratio tends toward e^x / e^x = 1. The closer x is to 19 or higher, the closer tanh gets to 1 without ever reaching it, which is why the calculator reports values like tanh(10) ≈ 0.9999999959.