tanh(3)

πŸ’– tanh(3) β€” hyperbolic tangent, bestie edition πŸ’–

okay so this is a page from the Library Functions Manual (section 3, the "library calls" girlies), and it's all about tanh and her two glow-up siblings tanhf and tanhl. buckle up, this one is short but she's iconic πŸŽ€


✨ NAME ✨

tanh, tanhf, tanhl β€” the hyperbolic tangent function πŸ¦‹


πŸ“š LIBRARY πŸ“š

Math library, aka libm, and you link her with -lm (yes bestie, you have to pass the flag, she's not coming for free) ✨


🌸 SYNOPSIS 🌸

#include <math.h>

double tanh(double x);
float tanhf(float x);
long double tanhl(long double x);

🧚 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

for tanhf() and tanhl():

_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

like, define one of those or the compiler is gonna act brand new, no cap πŸ’€


πŸ‘‘ DESCRIPTION πŸ‘‘

These functions hand you back the hyperbolic tangent of x, and mathematically she is defined as:

tanh(x) = sinh(x) / cosh(x)

that's the whole vibe. sinh over cosh. girl math? no. real math 🌈


πŸ’… RETURN VALUE πŸ’…

On success, these functions return the hyperbolic tangent of x. periodt.

  • If x is a NaN, a NaN is returned. (garbage in, garbage out, she's not gonna lie to you πŸ™ˆ)
  • If x is +0 (-0), +0 (-0) is returned. signed zero stays signed, she remembers 🀝
  • If x is positive infinity (negative infinity), +1 (-1) is returned. she saturates, she's chill like that πŸ”₯

😭 ERRORS 😭

No errors occur. not a single one. she simply does not miss. πŸ’–


🌈 ATTRIBUTES 🌈

For an explanation of the terms used in this section, see attributes(7).

  • Interface: tanh(), tanhf(), tanhl()
  • Attribute: Thread safety
  • Value: MT-Safe

translation: she's MT-Safe, so go off, call her from all your threads, she's not gonna start drama 🫢


⭐ STANDARDS ⭐

C11, POSIX.1-2008. she's certified, she's official, she passed the vibe check πŸ‘‘


πŸ•°οΈ HISTORY πŸ•°οΈ

C99, POSIX.1-2001. been that girl since the late 90s fr fr.

The variant returning double also conforms to SVr4, 4.3BSD, C89. so basically the double version has been around forever, a true elder icon 🌸


πŸ¦‹ SEE ALSO πŸ¦‹

acosh(3), asinh(3), atanh(3), cosh(3), ctanh(3), sinh(3)

the whole hyperbolic friend group!! go say hi, they're all obsessed with each other 🫢✨



and that's the tea, bestie πŸ’œ this was pulled from Linux man-pages 6.20, dated 2026-02-08 β€” so you know it's fresh, it's current, and it ate. mwah. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ 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