function acos( x ) {
	var z;
	if ( isnan( x ) ) {
		return NaN;
	}
	if ( x < -1.0 || x > 1.0 ) {
		return NaN;
	}
	if ( x > 0.5 ) {
		return 2.0 * asin( sqrt( 0.5 - (0.5*x) ) );
	}
	z = PIO4 - asin( x );
	z += MOREBITS;
	z += PIO4;
	return z;
}
Computes the arccosine of a double-precision floating-point number.

## Method

-   Analytically,

    ```tex
    \operatorname{acos}(x) = \frac{\pi}{2} - \operatorname{asin}(x)
    ```

    However, if \\(\|x\|\\) is near \\(1\\), there is cancellation error in subtracting \\(\opertorname{asin}(x)\\) from \\(\pi/2\\). Hence, if \\(x < -0.5\\),

    ```tex
    \operatorname{acos}(x) = \pi - 2.0 \cdot \operatorname{asin}(\sqrt{(1+x)/2})
    ```

    or, if \\(x > +0.5\\),

    ```tex
    \operatorname{acos}(x) = 2.0 \cdot \operatorname{asin}( \sqrt{(1-x)/2} )}
    ```

## Notes

-   Relative error:

    | arithmetic | domain | # trials | peak    | rms     |
    |:-----------|:------:|:---------|:--------|:--------|
    | DEC        | -1, 1  | 50000    | 3.3e-17 | 8.2e-18 |
    | IEEE       | -1, 1  | 10^6     | 2.2e-16 | 6.5e-17 |

@param {number} x - input value
@returns {number} arccosine (in radians)

@example
var v = acos( 1.0 );
// returns 0.0

@example
var v = acos( 0.707 ); // ~pi/4
// returns ~0.7855

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