function tanh( x ) {
	var s;
	var z;
	z = abs( x );
	if ( z > 0.5*MAXLOG ) {
		return ( x < 0.0 ) ? -1.0 : 1.0;
	}
	if ( z >= 0.625 ) {
		s = exp( 2.0 * z );
		z = 1.0 - ( 2.0/(s+1.0) );
		if ( x < 0.0 ) {
			z = -z;
		}
	} else {
		if ( x === 0.0 ) {
			return x; // Handle `+-0`
		}
		s = x * x;
		z = x + ( x*s*ratval( s ) );
	}
	return z;
}
Computes the hyperbolic tangent of a double-precision floating-point number.

## Method

For \\( |x| < 0.625 \\), we use a rational function of the form (Cody and Waite)

```tex
x + x^3 \frac{\mathrm{P}(x)}{\mathrm{Q}(x)}
```

Otherwise,

```tex
\begin{align*}
\operatorname{tanh}(x) &= \frac{\operatorname{sinh}(x)}{\operatorname{cosh(x)}} \\
&= 1 - \frac{2}{e^{2x} + 1}
\end{align*}
```

## Notes

-   Relative error:

    | arithmetic | domain | # trials | peak    | rms     |
    |:----------:|:------:|:--------:|:-------:|:-------:|
    | DEC        | -2,2   | 50000    | 3.3e-17 | 6.4e-18 |
    | IEEE       | -2,2   | 30000    | 2.5e-16 | 5.8e-17 |

@param {number} x - input value
@returns {number} hyperbolic tangent

@example
var v = tanh( 0.0 );
// returns 0.0

@example
var v = tanh( 2.0 );
// returns ~0.964

@example
var v = tanh( -2.0 );
// returns ~-0.964

@example
var v = tanh( NaN );
// returns NaN