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 ๐Ÿ’–


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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms