csqrt(3)

πŸ’… csqrt β€” complex square root, but make it cute

okay bestie so like. the manual name is csqrt and she is the math girlie for square roots, but for complex numbers ✨. her whole friend group is csqrt, csqrtf, and csqrtl 🫢


🌈 LIBRARY

Math library (libm, link it with -lm) β€” yes you have to actually link it, no cap. πŸŽ€


✨ SYNOPSIS

#include <complex.h>

double complex csqrt(double complex z);
float complex csqrtf(float complex z);
long double complex csqrtl(long double complex z);

like. three of them. same vibe, different precision πŸ¦‹


πŸ’– DESCRIPTION

so these functions find the complex square root of z. iconic behaviour, honestly. πŸ”₯

but here's the tea β˜• β€” there's a branch cut running along the negative real axis. and the way that works is:

  • csqrt(-1+eps*I) is gonna land close to I
  • csqrt(-1-eps*I) is gonna land close to -I

…as long as eps is a small positive real number. so like, you approach that negative real axis from above β†’ you get one answer. from below β†’ you get the other one. the discontinuity is just there, and she's not sorry πŸ’… that's the math, periodt.


🌸 ATTRIBUTES

ngl if you don't know what these words mean, go read attributes(7) β€” it's giving required reading πŸ“š

  • csqrt(), csqrtf(), csqrtl() β€” Thread safety: MT-Safe πŸ‘‘ β€” so you can call her from multiple threads and she will not have a meltdown. obsessed.

(the original had a whole cute little table for this. this is the table. it's one row. she ate. πŸ“)


⭐ STANDARDS

C11, POSIX.1-2008. certified and official bestie πŸ’œ


🧚 HISTORY

  • glibc 2.1 β€” that's when she first showed up on the scene ✨
  • And she's been around since C99 and POSIX.1-2001, so like, a legacy icon fr fr 🌟

πŸŽ€ SEE ALSO

go hang out with her friends:


lowkey reminder: that branch cut is not a bug, it's a feature. don't come for her. 🫢

csqrt(3) comes to you from Linux man-pages 6.20, dated 2026-02-08 β€” mwah, love that for her, that's the whole page bestie, go compute something slay πŸ’…πŸ’–βœ¨

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