| 1 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 5 |
.\" |
| 6 |
.TH complex 7 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
complex \- basics of complex mathematics |
| 9 |
.SH LIBRARY |
| 10 |
Math library |
| 11 |
.RI ( libm ,\~ \-lm ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <complex.h> |
| 15 |
.fi |
| 16 |
.SH DESCRIPTION |
| 17 |
Complex numbers are numbers of the form z = a+b*i, where a and b are |
| 18 |
real numbers and i = sqrt(\-1), so that i*i = \-1. |
| 19 |
.P |
| 20 |
There are other ways to represent that number. |
| 21 |
The pair (a,b) of real |
| 22 |
numbers may be viewed as a point in the plane, given by X- and |
| 23 |
Y-coordinates. |
| 24 |
This same point may also be described by giving |
| 25 |
the pair of real numbers (r,phi), where r is the distance to the origin O, |
| 26 |
and phi the angle between the X-axis and the line Oz. |
| 27 |
Now |
| 28 |
z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)). |
| 29 |
.P |
| 30 |
The basic operations are defined on z = a+b*i and w = c+d*i as: |
| 31 |
.TP |
| 32 |
.B addition: z+w = (a+c) + (b+d)*i |
| 33 |
.TP |
| 34 |
.B multiplication: z*w = (a*c \- b*d) + (a*d + b*c)*i |
| 35 |
.TP |
| 36 |
.B division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c \- a*d)/(c*c + d*d))*i |
| 37 |
.P |
| 38 |
Nearly all math function have a complex counterpart but there are |
| 39 |
some complex-only functions. |
| 40 |
.SH EXAMPLES |
| 41 |
Your C-compiler can work with complex numbers if it supports the C99 standard. |
| 42 |
The imaginary unit is represented by I. |
| 43 |
.P |
| 44 |
.EX |
| 45 |
/* check that exp(i * pi) == \-1 */ |
| 46 |
#include <math.h> /* for atan */ |
| 47 |
#include <stdio.h> |
| 48 |
#include <complex.h> |
| 49 |
\& |
| 50 |
int |
| 51 |
main(void) |
| 52 |
{ |
| 53 |
double pi = 4 * atan(1.0); |
| 54 |
double complex z = cexp(I * pi); |
| 55 |
printf("%f + %f * i\[rs]n", creal(z), cimag(z)); |
| 56 |
} |
| 57 |
.EE |
| 58 |
.SH SEE ALSO |
| 59 |
.BR cabs (3), |
| 60 |
.BR cacos (3), |
| 61 |
.BR cacosh (3), |
| 62 |
.BR carg (3), |
| 63 |
.BR casin (3), |
| 64 |
.BR casinh (3), |
| 65 |
.BR catan (3), |
| 66 |
.BR catanh (3), |
| 67 |
.BR ccos (3), |
| 68 |
.BR ccosh (3), |
| 69 |
.BR cerf (3), |
| 70 |
.BR cexp (3), |
| 71 |
.BR cexp2 (3), |
| 72 |
.BR cimag (3), |
| 73 |
.BR clog (3), |
| 74 |
.BR clog10 (3), |
| 75 |
.BR clog2 (3), |
| 76 |
.BR conj (3), |
| 77 |
.BR cpow (3), |
| 78 |
.BR cproj (3), |
| 79 |
.BR creal (3), |
| 80 |
.BR csin (3), |
| 81 |
.BR csinh (3), |
| 82 |
.BR csqrt (3), |
| 83 |
.BR ctan (3), |
| 84 |
.BR ctanh (3) |