catanh(3)

πŸ’– catanh(3) β€” the complex arc hyperbolic tangent situation πŸ’–

okay so bestie, you opened the manual for catanh, and you're in the Library Functions Manual zone, section 3. these are the math girlies β€” catanh, catanhf, and catanhl β€” and we're about to get into it. no cap. πŸŽ€


✨ NAME ✨

catanh, catanhf, catanhl β€” complex arc tangents hyperbolic πŸ¦‹

like, the inverse of the hyperbolic tangent, but make it complex. periodt.


πŸ“š LIBRARY πŸ“š

Math library (libm, -lm)

bestie. you have to link -lm. i'm not kidding. every single time someone forgets -lm a small fairy loses her wings. 🧚

🌸 SYNOPSIS 🌸

#include <complex.h>

double complex catanh(double complex z);
float complex catanhf(float complex z);
long double complex catanhl(long double complex z);

three flavours, one vibe. pick your precision, queen. πŸ’…

  • double complex catanh(double complex z); β€” the classic, the default, the main character
  • float complex catanhf(float complex z); β€” the f one, floats, cute and fast
  • long double complex catanhl(long double complex z); β€” the l one, max precision, extra

🫢 DESCRIPTION 🫢

so these functions calculate the complex arc hyperbolic tangent of z. that's the whole thing. it's giving inverse function energy. ✨

the way that works: if y = catanh(z), then z = ctanh(y). yes bestie, they undo each other. iconic behaviour honestly. πŸ”₯

and the imaginary part of y gets chosen in the interval [-pi/2,pi/2]. locked in. that's the branch, no negotiating. πŸ’€

One has: πŸ‘‘

catanh(z) = 0.5 * (clog(1 + z) - clog(1 - z))

that's literally the formula, keep it in your notes. πŸ“


πŸ’… ATTRIBUTES πŸ’…

if you want the whole explanation of what these terms even mean, go read attributes(7). it's a whole thing. but here's the tea for this one:

  • Interface: catanh(), catanhf(), catanhl()
  • Attribute: Thread safety
  • Value: MT-Safe

so yeah. thread safe. you can absolutely have your threads in there at the same time, it's fine, breathe. 🧘


πŸ‘‘ STANDARDS πŸ‘‘

C11, POSIX.1-2008.

she's official. she's standardised. she's certified. ⭐


🌈 HISTORY 🌈

glibc 2.1. and before that, C99, POSIX.1-2001.

a whole legacy. we love a function with lore. πŸ’œ


πŸ“ EXAMPLES πŸ“

okay here's a whole little program, and the comment at the top is IMPORTANT β€” you link with "-lm". do not skip it. 😭

/* Link with "-lm" */

#include <complex.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
    double complex z, c, f;

    if (argc != 3) {
        fprintf(stderr, "Usage: %s <real> <imag>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    z = atof(argv[1]) + atof(argv[2]) * I;

    c = catanh(z);
    printf("catanh() = %6.3f %6.3f*i\n", creal(c), cimag(c));

    f = 0.5 * (clog(1 + z) - clog(1 - z));
    printf("formula  = %6.3f %6.3f*i\n", creal(f), cimag(f));

    exit(EXIT_SUCCESS);
}

what's happening here? you hand it a real part and an imag part as arguments, it builds z out of them, runs catanh(z) and prints it β€” then it also computes the formula by hand with clog and prints that too, so you can see them match. side by side. it's giving proof. slay. πŸ’–

and if you don't pass exactly two args? it screams at you with a usage message and bails with EXIT_FAILURE. fair honestly.


πŸ” SEE ALSO πŸ”

go read those too, bestie, the whole complex family is lowkey fascinating. πŸ¦‹


and that's the page!! this was Linux man-pages 6.20, dated 2026-02-08, filed under catanh(3). 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: GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms