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 +0 or -0, 1 is 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 β€” errno gets set to ERANGE, 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms