function cos( x ) {
	var sgn;
	var zz;
	var i;
	var j;
	var y;
	var z;

	if ( isnan( x ) || isinfinite( x ) ) {
		return NaN;
	}

	// Make argument positive...
	sgn = 1;
	if ( x < 0 ) {
		x = -x;
	}

	y = floor( x/PIO4 );
	z = ldexp( y, -4 );
	z = floor( z ); // Integer part of y/8
	z = y - ldexp( z, 4 ); // y - 16 * (y/16)

	// Integer and fractional part modulo one octant...
	i = y;

	// Map zeros to origin...
	if ( i & 1 ) {
		i += 1;
		y += 1.0;
	}
	j = i & 7;
	if ( j > 3 ) {
		j -= 4;
		sgn = -sgn;
	}
	if ( j > 1 ) {
		sgn = -sgn;
	}

	// Extended precision modular arithmetic...
	z = ( ( x - ( y*DP1 ) ) - ( y*DP2 ) ) - ( y * DP3 );
	zz = z * z;

	if ( j === 1 || j === 2 ) {
		y = z + ( z * z * z * polyvalSIN( zz ) );
	} else {
		y = 1.0 - ldexp( zz, -1 ) + ( zz * zz * polyvalCOS( zz ) );
	}

	if ( sgn < 0 ) {
		y = -y;
	}
	return y;
}
Computes the cosine of a number.

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

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

@example
var v = cos( 3.14/4.0 );
// returns ~0.707

@example
var v = cos( -3.14/6.0 );
// returns ~0.866

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