commands → cos

cos(x)

The cos command computes the cosine of x where x is in radians. If x is a floating point number then a floating point result is computed, otherwise the result is an exact symbolic value.

Examples

# hardware floating point
cos(1.0);
	0.54030230586814

# symbolic
cos(1);
	cos(1);

Algorithm

To compute cos(x) in extended precision, we first reduce x modulo 2*pi followed by computation of the power series for cos.

References

Gullberg, Jan. Mathematics: From the Birth of Numbers. Norton, 1996.