cosh(3)
π cosh(3) β bestie edition π
okay so you opened the manual page for cosh and honestly? iconic of you. this is cosh(3), the hyperbolic cosine situation, and she is serving math library realness. let's get into it, no cap β¨
πΈ NAME πΈ
cosh, coshf, coshl β the hyperbolic cosine function, but make it three flavors π
π LIBRARY π
Math library, aka libm, link her with -lm or she simply will not show up π
β¨ SYNOPSIS β¨
#include <math.h>
double cosh(double x);
float coshf(float x);
long double coshl(long double x);
π§ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
for coshf(), coshl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
like yes bestie you have to declare your source macro first, that's the vibe check π«Ά
π DESCRIPTION π
these functions hand you back the hyperbolic cosine of x, which, mathematically speaking, is defined as:
cosh(x) = (exp(x) + exp(-x)) / 2
that's it. that's the whole formula. ate and left no crumbs π
π RETURN VALUE π
- on success, these functions return the hyperbolic cosine of x β slay β
- if x is a NaN, a NaN is returned (NaN in, NaN out, that's the law π)
- if x is
+0or-0,1is returned (both zeros, same answer, balanced queen π) - if x is positive infinity or negative infinity, positive infinity is returned
- if the result overflows, a range error occurs, and the functions return
+HUGE_VAL,+HUGE_VALF, or+HUGE_VALL, respectively
π ERRORS π
peep math_error(7) for the tea on how to figure out whether an error actually happened when you called these functions π«
the following errors can occur:
- Range error: result overflow β
errnogets set toERANGE, and an overflow floating-point exception (FE_OVERFLOW) is raised
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
cosh(),coshf(),coshl()β Thread safety: MT-Safe β¨
(translation: she's thread safe, she can hang with everybody at the same time, no drama π)
π STANDARDS π
C11, POSIX.1-2008.
π¦ HISTORY π¦
C99, POSIX.1-2001.
also, the variant that returns double (that's plain old cosh()) additionally conforms to SVr4, 4.3BSD. old money behavior fr fr π
π BUGS π
in glibc 2.3.4 and earlier, an overflow floating-point (FE_OVERFLOW) exception is not raised when an overflow occurs. so if you're time traveling back to old glibc, beware bestie, the exception just doesn't show up π
π SEE ALSO π
acosh(3), asinh(3), atanh(3), ccos(3), sinh(3), tanh(3)
this whole thing is from Linux man-pages 6.20, dated 2026-02-08 π and that's the cosh(3) page, periodt. go forth and compute your hyperbolic cosines, you gorgeous nerd πΈπ¦β¨
π¦ 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