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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       cos, cosf, cosl - cosine function
13

SYNOPSIS

15       #include <math.h>
16
17       double cos(double x);
18       float cosf(float x);
19       long double cosl(long double x);
20
21

DESCRIPTION

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

RETURN VALUE

33       Upon  successful completion, these functions shall return the cosine of
34       x.
35
36       If x is NaN, a NaN shall be returned.
37
38       If x is ±0, the value 1.0 shall be returned.
39
40       If x is ±Inf, a domain error shall occur, and either  a  NaN  (if  sup‐
41       ported), or an implementation-defined value shall be returned.
42

ERRORS

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

EXAMPLES

58   Taking the Cosine of a 45-Degree Angle
59              #include <math.h>
60              ...
61              double radians = 45 * M_PI / 180;
62              double result;
63              ...
64              result = cos(radians);
65

APPLICATION USAGE

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

RATIONALE

75       None.
76

FUTURE DIRECTIONS

78       None.
79

SEE ALSO

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