cos(3)
๐ cos(3) โ like, the cosine function, bestie ๐
okay so this is page cos(3) from the Library Functions Manual, and we're about to get SO cozy with trigonometry. pull up a chair. ๐
โจ NAME โจ
cos, cosf, cosl โ cosine function ๐
๐ LIBRARY ๐
Math library (libm, link it with -lm) โ yeah you gotta actually link it, don't @ me when it doesn't compile ๐
๐ธ SYNOPSIS ๐ธ
#include <math.h>
double cos(double x);
float cosf(float x);
long double cosl(long double x);
๐ฆ Feature Test Macro Requirements for glibc ๐ฆ
(peep feature_test_macros(7) if you wanna know what these are, iykyk)
cosf(), cosl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
like, you need ALL of that or she simply will not exist for you. the audacity. ๐ญ
๐ซ DESCRIPTION ๐ซ
These functions return the cosine of x, where x is given in radians. that's it. that's the whole vibe. radians only, bestie โ if you hand her degrees she's gonna be real confused and it's gonna be wrong and it's gonna be your fault ๐
๐ซถ RETURN VALUE ๐ซถ
On success, these functions return the cosine of x. slay. โจ
- If
xis aNaN, aNaNis returned. (NaN in, NaN out, iconic behaviour honestly) - If
xis positive infinity or negative infinity, a domain error occurs, and aNaNis returned. infinity is not on the guest list for this function fr fr ๐
๐ฅ ERRORS ๐ฅ
Go read math_error(7) for the whole scoop on how to figure out whether an error happened when you called these. detective work. ๐
The following errors can occur:
๐จ Domain error: x is an infinity ๐จ
errno is set to EDOM (but see BUGS โ there's a lil plot twist down there). An invalid floating-point exception (FE_INVALID) is raised.
lowkey important: yes you read that right, EDOM. write it down.
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
cos(),cosf(),cosl()โ Thread safety โMT-Safe๐ โ
(translation: she's safe to use from multiple threads, go wild, you're fine)
โญ STANDARDS โญ
C11, POSIX.1-2008. certified. stamped. approved. ๐
๐ HISTORY ๐
C89, POSIX.1-2001. she's been around. she's a legend. she's been doing this since before your parents had phones.
The variant returning double also conforms to SVr4, 4.3BSD.
๐ BUGS ๐
Before glibc 2.10, the glibc implementation did not set errno to EDOM when a domain error occurred. so if you're on some ancient glibc, don't trust errno, she's lying to you. that's the tea. ๐ต
๐ง SEE ALSO ๐ง
acos(3), asin(3), atan(3), atan2(3), ccos(3), sin(3), sincos(3), tan(3)
and that's the whole page bestie!! ๐ this one's from Linux man-pages 6.20, dated 2026-02-08 โ go forth and compute your cosines, radians ONLY, and remember: you're the main character of your own trig โจ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms