catan(3)

πŸ’– catan β€” complex arc tangents πŸ’–

okay bestie, sit DOWN, because today we're talking about catan, catanf and catanl from the math library, and honestly? iconic behavior from all three of them. this is a catan(3) situation, so it's the library-functions manual, and it's giving "trig but make it complex" πŸ’…


✨ LIBRARY ✨

Math library, and you gotta link it like -lm or she simply will not show up. rude? maybe. but that's the vibe. 🫢


🌸 SYNOPSIS 🌸

#include <complex.h>

double complex catan(double complex z);
float complex catanf(float complex z);
long double complex catanl(long double complex z);

three flavors, one function, choose your precision like choosing your drink at starbucks: double, float, long double. periodt. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions calculate the complex arc tangent of z. that's it, that's the job, and they do it flawlessly.

here's the tea on how it works: if

y = catan(z)

then that literally means

z = ctan(y)

and the real part of y gets chosen in the interval [-pi/2, pi/2]. so it's the principal-branch girly, no chaotic branch-hopping happening here, she stays in her lane. πŸ’…

also, one has:

catan(z) = (clog(1 + i * z) - clog(1 - i * z)) / (2 * i)

like, that's the formula, and it's genuinely so elegant it makes me emotional 😭


πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, go check out attributes(7) β€” it's like the glossary bestie, very useful.

  • Interface: catan(), catanf(), catanl()
  • Attribute: Thread safety
  • Value: MT-Safe
so yes, all three of them are <green>MT-Safe</green> πŸ’š which means you can call them from multiple threads without it turning into a whole situation. slay. πŸ”₯

⭐ STANDARDS ⭐

C11, POSIX.1-2008. certified, standardized, official. no cap. βœ…


🌈 HISTORY 🌈

  • glibc 2.1.
  • C99, POSIX.1-2001.

so she's been around since forever and she's still serving. longevity queen. πŸ‘‘


πŸ’œ EXAMPLES πŸ’œ

here's a whole little demo program, and remember: link with -lm or it's not gonna work, bestie, I'm warning you now πŸ™ˆ

/* 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;
    double complex i = I;

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

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

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

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

    exit(EXIT_SUCCESS);
}

what's happening here, translated for the girlies: you pass in a <italic>real</italic> part and an <italic>imag</italic> part, it builds the complex number z, calls catan(z), prints the result, and then ALSO computes the same thing with the formula from up top and prints that too β€” so you can literally watch the function and the math agree with each other. matching outfits. bestie energy. πŸŽ€ and yes, it exits with EXIT_SUCCESS because we're thriving.


🧚 SEE ALSO 🧚

go read those next, they're all part of the same friend group. 🫢


and that's the whole page, babe! this was pulled from Linux man-pages 6.20, dated 2026-02-08, for catan(3). mwah, love u, go compute some arc tangents πŸ’–βœ¨πŸŒΈ

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