1COMPLEX(7)                 Linux Programmer's Manual                COMPLEX(7)
2
3
4

NAME

6       complex - basics of complex mathematics
7

SYNOPSIS

9       #include <complex.h>
10

DESCRIPTION

12       Complex  numbers  are  numbers of the form z = a+b*i, where a and b are
13       real numbers and i = sqrt(-1), so that i*i = -1.
14
15       There are other ways to represent that number.  The pair (a,b) of  real
16       numbers  may be viewed as a point in the plane, given by X- and Y-coor‐
17       dinates.  This same point may also be described by giving the  pair  of
18       real  numbers (r,phi), where r is the distance to the origin O, and phi
19       the angle between the X-axis and the line Oz.  Now z =  r*exp(i*phi)  =
20       r*(cos(phi)+i*sin(phi)).
21
22       The basic operations are defined on z = a+b*i and w = c+d*i as:
23
24       addition: z+w = (a+c) + (b+d)*i
25
26       multiplication: z*w = (a*c - b*d) + (a*d + b*c)*i
27
28       division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c - a*d)/(c*c + d*d))*i
29
30       Nearly  all math function have a complex counterpart but there are some
31       complex-only functions.
32

EXAMPLES

34       Your C-compiler can work with complex numbers if it  supports  the  C99
35       standard.  Link with -lm.  The imaginary unit is represented by I.
36
37       /* check that exp(i * pi) == -1 */
38       #include <math.h>        /* for atan */
39       #include <stdio.h>
40       #include <complex.h>
41
42       int
43       main(void)
44       {
45           double pi = 4 * atan(1.0);
46           double complex z = cexp(I * pi);
47           printf("%f + %f * i\n", creal(z), cimag(z));
48       }
49

SEE ALSO

51       cabs(3),  cacos(3),  cacosh(3), carg(3), casin(3), casinh(3), catan(3),
52       catanh(3), ccos(3), ccosh(3),  cerf(3),  cexp(3),  cexp2(3),  cimag(3),
53       clog(3),  clog10(3),  clog2(3),  conj(3),  cpow(3), cproj(3), creal(3),
54       csin(3), csinh(3), csqrt(3), ctan(3), ctanh(3)
55

COLOPHON

57       This page is part of release 5.13 of the Linux  man-pages  project.   A
58       description  of  the project, information about reporting bugs, and the
59       latest    version    of    this    page,    can     be     found     at
60       https://www.kernel.org/doc/man-pages/.
61
62
63
64                                  2021-03-22                        COMPLEX(7)
Impressum