Hyperbolic tangent (source code)

= Hyperbolic tangent
{title2=$\tanh x$}
{wiki}

The hyperbolic tangent is
$$
\tanh x=\frac{\sinh x}{\cosh x}=\frac{e^{2x}-1}{e^{2x}+1}.
$$
For real $x$, it is an <odd>, <strictly increasing> <smooth function> mapping $\mathbb R$ onto $(-1,1)$. The exponential expression gives its limits $-1$ and $1$ at the two infinities. The <quotient rule> and the <hyperbolic Pythagorean identity> give
$$
\frac{d}{dx}\tanh x=\operatorname{sech}^2x=1-\tanh^2x>0.
$$
Hence it is nearly linear near zero, with $\tanh x=x+O(x^3)$, and saturates for large input magnitude. Its real <inverse function> is $\operatorname{artanh}y=\tfrac12\log((1+y)/(1-y))$ for $|y|<1$. The profile $u(x)=\tanh x$ solves $u'=1-u^2$, connecting a simple <nonlinear ordinary differential equation> with a smooth transition between two limiting states.