1COS(P)                     POSIX Programmer's Manual                    COS(P)
2
3
4

NAME

6       cos, cosf, cosl - cosine function
7

SYNOPSIS

9       #include <math.h>
10
11       double cos(double x);
12       float cosf(float x);
13       long double cosl(long double x);
14
15

DESCRIPTION

17       These  functions shall compute the cosine of their argument x, measured
18       in radians.
19
20       An application wishing to check for error situations should  set  errno
21       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
22       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
23       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
24       occurred.
25

RETURN VALUE

27       Upon successful completion, these functions shall return the cosine  of
28       x.
29
30       If x is NaN, a NaN shall be returned.
31
32       If x is ±0, the value 1.0 shall be returned.
33
34       If  x  is  ±Inf,  a domain error shall occur, and either a NaN (if sup‐
35       ported), or an implementation-defined value shall be returned.
36

ERRORS

38       These functions shall fail if:
39
40       Domain Error
41              The x argument is ±Inf.
42
43       If the integer expression (math_errhandling & MATH_ERRNO) is  non-zero,
44       then   errno  shall  be  set  to  [EDOM].  If  the  integer  expression
45       (math_errhandling &  MATH_ERREXCEPT)  is  non-zero,  then  the  invalid
46       floating-point exception shall be raised.
47
48
49       The following sections are informative.
50

EXAMPLES

52   Taking the Cosine of a 45-Degree Angle
53              #include <math.h>
54              ...
55              double radians = 45 * M_PI / 180;
56              double result;
57              ...
58              result = cos(radians);
59

APPLICATION USAGE

61       These  functions  may  lose accuracy when their argument is near an odd
62       multiple of pi/2 or is far from 0.
63
64       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
65       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
66       at least one of them must be non-zero.
67

RATIONALE

69       None.
70

FUTURE DIRECTIONS

72       None.
73

SEE ALSO

75       acos() , feclearexcept() , fetestexcept() , isnan() , sin() ,  tan()  ,
76       the  Base  Definitions  volume  of  IEEE Std 1003.1-2001, Section 4.18,
77       Treatment of Error Conditions for Mathematical Functions, <math.h>
78
80       Portions of this text are reprinted and reproduced in  electronic  form
81       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
82       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
83       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
84       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
85       event of any discrepancy between this version and the original IEEE and
86       The Open Group Standard, the original IEEE and The Open Group  Standard
87       is  the  referee document. The original Standard can be obtained online
88       at http://www.opengroup.org/unix/online.html .
89
90
91
92IEEE/The Open Group                  2003                               COS(P)
Impressum