Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Trigonometric Functions


cos

You can use the cos function to compute the cosine of a real number.

double_t cos (double_t x);
x
Any finite floating-point number.
DESCRIPTION
The cos 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 (arccos(y)) .

EXCEPTIONS
When x is finite and nonzero, cos(x) raises the inexact exception.

SPECIAL CASES
Table 10-20 shows the results when the argument to the cos function is a zero, a NaN, or an Infinity, plus other special cases for the cos function.
Special cases for the cos function
OperationResultExceptions raised
cos(pi) -1Inexact
cos(+0) 1None
cos(-0) 1None
cos(NaN) NaNNone[41]
cos(+ ) NaNInvalid
cos(- ) NaNInvalid

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.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996