| 1 |
'\" t |
| 2 |
.\" Copyright 1993, David Metcalfe <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH cos 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
cos, cosf, cosl \- cosine function |
| 10 |
.SH LIBRARY |
| 11 |
Math library |
| 12 |
.RI ( libm ,\~ \-lm ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <math.h> |
| 16 |
.P |
| 17 |
.BI "double cos(double " x ); |
| 18 |
.BI "float cosf(float " x ); |
| 19 |
.BI "long double cosl(long double " x ); |
| 20 |
.fi |
| 21 |
.P |
| 22 |
.RS -4 |
| 23 |
Feature Test Macro Requirements for glibc (see |
| 24 |
.BR feature_test_macros (7)): |
| 25 |
.RE |
| 26 |
.P |
| 27 |
.BR cosf (), |
| 28 |
.BR cosl (): |
| 29 |
.nf |
| 30 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 31 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 32 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 33 |
.fi |
| 34 |
.SH DESCRIPTION |
| 35 |
These functions return the cosine of |
| 36 |
.IR x , |
| 37 |
where |
| 38 |
.I x |
| 39 |
is |
| 40 |
given in radians. |
| 41 |
.SH RETURN VALUE |
| 42 |
On success, these functions return the cosine of |
| 43 |
.IR x . |
| 44 |
.P |
| 45 |
If |
| 46 |
.I x |
| 47 |
is a NaN, a NaN is returned. |
| 48 |
.P |
| 49 |
If |
| 50 |
.I x |
| 51 |
is positive infinity or negative infinity, |
| 52 |
a domain error occurs, |
| 53 |
and a NaN is returned. |
| 54 |
.SH ERRORS |
| 55 |
See |
| 56 |
.BR math_error (7) |
| 57 |
for information on how to determine whether an error has occurred |
| 58 |
when calling these functions. |
| 59 |
.P |
| 60 |
The following errors can occur: |
| 61 |
.TP |
| 62 |
Domain error: \f[I]x\f[] is an infinity |
| 63 |
.I errno |
| 64 |
is set to |
| 65 |
.B EDOM |
| 66 |
(but see BUGS). |
| 67 |
An invalid floating-point exception |
| 68 |
.RB ( FE_INVALID ) |
| 69 |
is raised. |
| 70 |
.SH ATTRIBUTES |
| 71 |
For an explanation of the terms used in this section, see |
| 72 |
.BR attributes (7). |
| 73 |
.TS |
| 74 |
allbox; |
| 75 |
lbx lb lb |
| 76 |
l l l. |
| 77 |
Interface Attribute Value |
| 78 |
T{ |
| 79 |
.na |
| 80 |
.nh |
| 81 |
.BR cos (), |
| 82 |
.BR cosf (), |
| 83 |
.BR cosl () |
| 84 |
T} Thread safety MT-Safe |
| 85 |
.TE |
| 86 |
.SH STANDARDS |
| 87 |
C11, POSIX.1-2008. |
| 88 |
.SH HISTORY |
| 89 |
C89, POSIX.1-2001. |
| 90 |
.P |
| 91 |
The variant returning |
| 92 |
.I double |
| 93 |
also conforms to |
| 94 |
SVr4, 4.3BSD. |
| 95 |
.SH BUGS |
| 96 |
Before glibc 2.10, the glibc implementation did not set |
| 97 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6780 |
| 98 |
.I errno |
| 99 |
to |
| 100 |
.B EDOM |
| 101 |
when a domain error occurred. |
| 102 |
.SH SEE ALSO |
| 103 |
.BR acos (3), |
| 104 |
.BR asin (3), |
| 105 |
.BR atan (3), |
| 106 |
.BR atan2 (3), |
| 107 |
.BR ccos (3), |
| 108 |
.BR sin (3), |
| 109 |
.BR sincos (3), |
| 110 |
.BR tan (3) |