Connect via MCP →

Enter Calculation

Any real number (dimensionless)

Formula

Advertisement

Results

Second Derivative tanh''(x)
-0.72686198
dimensionless
tanh(x) 0.46211716
tanh'(x) = 1 - tanh^2(x) 0.78644773
tanh''(x) = -2 tanh(x)(1 - tanh^2(x)) -0.72686198

What this calculator does

This tool evaluates the second derivative of the hyperbolic tangent function, \(\tanh''(x)\), at any real number x. The hyperbolic tangent, \(f(x) = \tanh(x)\), is a smooth, S-shaped function bounded between -1 and 1. It is widely used as an activation function in neural networks, so its first and second derivatives are important for understanding gradient flow and curvature. Alongside the main result, the calculator also reports \(\tanh(x)\) itself and the first derivative \(\tanh'(x)\).

How to use it

Enter any real value for x — positive, negative, or zero — and the calculator returns three numbers: \(\tanh(x)\), its first derivative \(\tanh'(x)\), and its second derivative \(\tanh''(x)\). No units are needed because x and all outputs are dimensionless.

The formula explained

Starting from \(f(x) = \tanh(x)\), the first derivative is \(f'(x) = 1 - \tanh^2(x)\), which also equals \(\operatorname{sech}^2(x)\). Differentiating once more with the chain rule gives

$$\frac{d^2}{dx^2}\tanh(x) = -2\tanh\!\left(x\right)\left(1 - \tanh^{2}\!\left(x\right)\right)$$

Equivalently, \(f''(x) = -2 \tanh(x) \operatorname{sech}^2(x)\). The computation uses \(t = \tanh(x)\) directly, which is numerically stable even for large \(|x|\) and avoids any division by zero, since \(e^x + e^{-x}\) is always at least 2.

Advertisement
Graphs of tanh(x), its first derivative, and its second derivative
tanh(x) (S-curve), its bell-shaped first derivative, and the antisymmetric second derivative crossing zero at x = 0.

Worked example (x = 0.5)

\(\tanh(0.5) = 0.4621172\). Then \(f'(0.5) = 1 - 0.4621172^2 = 0.7864477\), and

$$f''(0.5) = -2 \times 0.4621172 \times 0.7864477 = -0.7270051$$

The second derivative is negative here because x is positive.

Point marked on the second-derivative curve at a sample x value
Evaluating tanh''(x) at a chosen x by reading the height of the second-derivative curve.

FAQ

Why is tanh''(0) zero? At x = 0, \(\tanh(0) = 0\), so the factor of \(\tanh(x)\) in the formula makes the whole expression zero. The function \(f''\) is odd, meaning \(f''(-x) = -f''(x)\).

What happens for very large x? \(\tanh(x)\) saturates toward +1 or -1, so both the first and second derivatives approach 0. This is the "vanishing gradient" behavior relevant to deep neural networks.

Is the second derivative ever undefined? No. tanh is smooth over all real numbers, so its derivatives exist everywhere.

Last updated: