function kernelCos( x, y ) {
	var hz;
	var r;
	var w;
	var z;

	z = x * x;
	w = z * z;
	r = z * polyval13( z );
	r += w * w * polyval46( z );
	hz = 0.5 * z;
	w = 1.0 - hz;
	return w + ( ((1.0-w) - hz) + ((z*r) - (x*y)) );
}
Computes the cosine on \\( \[-\pi/4, \pi/4] \\), where \\( \pi/4 \approx 0.785398164 \\).

## Method

-   Since \\( \cos(-x) = \cos(x) \\), we need only to consider positive \\(x\\).

-   If \\( x < 2^{-27} \\), return \\(1\\) which is inexact if \\( x \ne 0 \\).

-   \\( cos(x) \\) is approximated by a polynomial of degree \\(14\\) on \\( \[0,\pi/4] \\).

    ```tex
    \cos(x) \approx 1 - \frac{x \cdot x}{2} + C_1 \cdot x^4 + \ldots + C_6 \cdot x^{14}
    ```

    where the Remez error is

    ```tex
    \left| \cos(x) - \left( 1 - \frac{x^2}{2} + C_1x^4 + C_2x^6 + C_3x^8 + C_4x^{10} + C_5x^{12} + C_6x^{15} \right) \right| \le 2^{-58}
    ```

-   Let \\( C_1x^4 + C_2x^6 + C_3x^8 + C_4x^{10} + C_5x^{12} + C_6x^{14} \\), then

    ```tex
    \cos(x) \approx 1 - \frac{x \cdot x}{2} + r
    ```

    Since

    ```tex
    \cos(x+y) \approx \cos(x) - \sin(x) \cdot y \approx \cos(x) - x \cdot y
    ```

    a correction term is necessary in \\( \cos(x) \\). Hence,

    ```tex
    \cos(x+y) = 1 - \left( \frac{x \cdot x}{2} - (r - x \cdot y) \right)
    ```

    For better accuracy, rearrange to

    ```tex
    \cos(x+y) \approx w + \left( t + ( r - x \cdot y ) \right)
    ```

    where \\( w = 1 - \frac{x \cdot x}{2} \\) and \\( t \\) is a tiny correction term (\\( 1 - \frac{x \cdot x}{2} = w + t \\) exactly in infinite precision). The exactness of \\(w + t\\) in infinite precision depends on \\(w\\) and \\(t\\) having the same precision as \\(x\\).

@param {number} x - input value (in radians, assumed to be bounded by ~pi/4 in magnitude)
@param {number} y - tail of `x`
@returns {number} cosine

@example
var v = kernelCos( 0.0, 0.0 );
// returns ~1.0

@example
var v = kernelCos( 3.141592653589793/6.0, 0.0 );
// returns ~0.866

@example
var v = kernelCos( 0.785, -1.144e-17 );
// returns ~0.707

@example
var v = kernelCos( NaN, 0.0 );
// returns NaN