complex(7)
๐ complex(7) โ Miscellaneous Information Manual ๐
okay bestie, pull up a chair, because we're doing complex(7) from the miscellaneous info section and it's literally the glow-up era of math ๐โจ
โจ NAME โจ
complex โ the basics of complex mathematics, and yes she's iconic for it ๐
๐ LIBRARY ๐
Math library (libm, -lm) โ go link her, she's waiting ๐ซถ
๐ธ SYNOPSIS ๐ธ
#include <complex.h>
that's it, that's the whole vibe check ๐
๐ DESCRIPTION ๐
So. Complex numbers, right? They're numbers shaped like z = a+b*i, where a and b are real numbers and i = sqrt(-1), which means i*i = -1. no cap, that's literally the whole definition and she ate ๐ฅ
There's more than one way to represent that same number, bestie. You can take the pair (a,b) of real numbers and read it as a point in the plane โ the X- and Y-coordinates, super chill, very "graph it and go". โจ But wait โจ โ that exact same point can also be described by a different pair of real numbers, (r,phi), where r is the distance to the origin O, and phi is the angle between the X-axis and the line Oz. And then:
z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi))
two representations, one queen ๐ง
The basic operations, defined on z = a+b*i and w = c+d*i, are:
- addition:
z+w = (a+c) + (b+d)*i - multiplication:
z*w = (a*c - b*d) + (a*d + b*c)*i - division:
z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c - a*d)/(c*c + d*d))*i
not me memorizing the division one, it's giving "plot twist at the denominator" ๐ญ
And here's the tea: nearly all math function have a complex counterpart โ but there are some complex-only functions. those ones are special, iykyk ๐
๐ EXAMPLES ๐
Your C-compiler can work with complex numbers if it supports the C99 standard. The imaginary unit is represented by I. uppercase, diva behavior, respect it ๐
/* check that exp(i * pi) == -1 */
#include <math.h> /* for atan */
#include <stdio.h>
#include <complex.h>
int
main(void)
{
double pi = 4 * atan(1.0);
double complex z = cexp(I * pi);
printf("%f + %f * i\n", creal(z), cimag(z));
}
it prints and everything, main character energy fr fr ๐
๐ฆ SEE ALSO ๐ฆ
the whole friend group, no one left out ๐
cabs(3),cacos(3),cacosh(3),carg(3),casin(3),casinh(3),catan(3),catanh(3),ccos(3),ccosh(3),cerf(3),cexp(3),cexp2(3),cimag(3),clog(3),clog10(3),clog2(3),conj(3),cpow(3),cproj(3),creal(3),csin(3),csinh(3),csqrt(3),ctan(3),ctanh(3)
and that's the page, bestie!! ๐ this one's from Linux man-pages 6.20, dated 2026-02-08 โ so like, remember the date for the exam or whatever ๐ slay, go write some #include <complex.h> code, 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
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms