cacosh(3)

πŸ’– cacosh(3) β€” complex arc hyperbolic cosine πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about cacosh, from section 3 of the manual (that's Library Functions Manual, iykyk). it's giving math. it's giving complex numbers. it's giving slay.

✨ NAME ✨

cacosh, cacoshf, cacoshl β€” complex arc hyperbolic cosine

πŸŽ€ LIBRARY πŸŽ€

Math library (libm, -lm)

fr fr, if you forget the -lm your linker is gonna ghost you. do not let that happen to you.

🌸 SYNOPSIS 🌸

#include <complex.h>

double complex cacosh(double complex z);
float complex cacoshf(float complex z);
long double complex cacoshl(long double complex z);

three functions, three vibes, one job: you want double? she's cacosh. you want float? she's cacoshf. you want long double? she's cacoshl, the queen, the icon, the moment. πŸ‘‘

πŸ¦‹ DESCRIPTION πŸ¦‹

these functions calculate the complex arc hyperbolic cosine of z. and like, what does that even mean? okay so: if y = cacosh(z), then z = ccosh(y). it's the inverse. the un-doing. the "bestie I need to go back" of it all.

here's the part where the nerds got specific and honestly? we love that for them:

  • the imaginary part of y is chosen in the interval [-pi,pi]
  • the real part of y is chosen nonnegative

and the formula, periodt:

cacosh(z) = 2 * clog(csqrt((z + 1) / 2) + csqrt((z - 1) / 2))

literally just clog and csqrt doing a collab. a crossover episode. no cap. πŸ’…

πŸ”₯ ATTRIBUTES πŸ”₯

for the full explanation of the terms used in this section, go check out attributes(7). but here's the tea:

  • Interface: cacosh(), cacoshf(), cacoshl()
  • Attribute: Thread safety
  • Value: MT-Safe

translation bestie: she's MT-Safe. all three of them. you can take her into threads, she will not embarrass you. 🫢

⭐ STANDARDS ⭐

C11, POSIX.1-2008.

πŸ‘‘ HISTORY πŸ‘‘

C99, POSIX.1-2001. glibc 2.1.

she's been around. she's seasoned. she's an elder who still ate. 🌈


πŸ’€ EXAMPLES πŸ’€

here's the demo program, and yes, you do need to link with -lm:

/* 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 = cacosh(z);
    printf("cacosh() = %6.3f %6.3f*i\n", creal(c), cimag(c));

    f = 2 * clog(csqrt((z + 1)/2) + csqrt((z - 1)/2));
    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 imaginary part, it builds z, runs the real cacosh(), then double-checks it against the formula from up top. if those two lines of output agree, the vibe check passed. if they don't? 😭

bestie note: the program expects exactly two arguments beyond the program name, or it prints Usage: %s <real> <imag> to stderr and bails with EXIT_FAILURE. it exits happy with EXIT_SUCCESS otherwise. don't argue with her, she's right.

🧚 SEE ALSO 🧚

acosh(3), cabs(3), ccosh(3), cimag(3), complex(7)


and that's the whole page, no notes, we ate and left no crumbs. this one came from Linux man-pages 6.20, dated 2026-02-08, and that's on cacosh(3) specifically. love her, respect her, include <complex.h>. bye bestie, go compile something πŸ“πŸ’œ

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