function atanh( x ) {
	var sgn;
	var t;
	if ( isnan( x ) || x < -1.0 || x > 1.0 ) {
		return NaN;
	}
	if ( x === 1.0 ) {
		return PINF;
	}
	if ( x === -1.0 ) {
		return NINF;
	}
	if ( x < 0.0 ) {
		sgn = true;
		x = -x;
	}
	// Case: |x| < 2**-28
	if ( x < NEAR_ZERO ) {
		return ( sgn ) ? -x : x;
	}
	if ( x < 0.5 ) {
		t = x + x;
		t = 0.5 * log1p( t + ( t*x/(1-x) ) );
	} else {
		t = 0.5 * log1p( (x+x) / (1-x) );
	}
	return ( sgn ) ? -t : t;
}
Computes the hyperbolic arctangent of a double-precision floating-point number.

## Method

1.  Reduce \\( x \\) to positive by \\( \operatorname{atanh}(-x) = -\operatorname{atanh}(x) \\)

2.  For \\( x \ge 0.5 \\), we calculate

    ```tex
    \operatorname{atanh}(x) = \frac{1}{2} \cdot \log\left( 1 + \tfrac{2x}{1-x} \right) = \frac{1}{2} \cdot \operatorname{log1p}\left( 2 \tfrac{x}{1-x} \right)
    ```

    For \\( x < 0.5 \\), we have

    ```tex
    \operatorname{atanh}(x) = \frac{1}{2} \cdot \operatorname{log1p}\left( 2x + \tfrac{2x^2}{1-x} \right)
    ```

## Special Cases

```tex
\begin{align*}
\operatorname{atanh}(\mathrm{NaN}) &= \mathrm{NaN}\\
\operatorname{atanh}(1.0) &= \infty \\
\operatorname{atanh}(-1.0) &= -\infty \\
\end{align*}
```

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

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

@example
var v = atanh( 0.9 );
// returns ~1.472

@example
var v = atanh( 1.0 );
// returns Infinity

@example
var v = atanh( -1.0 );
// returns -Infinity

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