Important: The information in this document is obsolete and should not be used for new development.
cos
You can use thecos
function to compute the cosine of a real number.
double_t cos (double_t x);
x
- Any finite floating-point number.
DESCRIPTION
Thecos
function returns the cosine of its argument. The argument is the measure of
an angle expressed in radians. This function is symmetric with respect to the y-axis
(cos x = cos -x).The
acos
function performs the inverse operation .EXCEPTIONS
When x is finite and nonzero, raises the inexact exception.SPECIAL CASES
Table 10-20 shows the results when the argument to thecos
function is a zero, a NaN, or an Infinity, plus other special cases for thecos
function.
Special cases for the cos
functionOperation Result Exceptions raised -1 Inexact 1 None 1 None NaN None[41] NaN Invalid NaN Invalid EXAMPLES
z = cos(0); /* z = 1.0. */ z = cos(pi/2); /* z = -0.0. The inexact exception is raised. */ z = cos(pi); /* z = -1.0. The inexact exception is raised. */ z = cos(-pi/2);/* z = 0.0. The inexact exception is raised. */ z = cos(-pi); /* z = -1.0. The inexact exception is raised. */
[41] If the NaN is a signaling NaN, the invalid exception is raised.