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

EXAMPLE

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

SEE ALSO

50       cabs(3), carg(3), cexp(3), cimag(3), creal(3)
51

COLOPHON

53       This  page  is  part of release 3.22 of the Linux man-pages project.  A
54       description of the project, and information about reporting  bugs,  can
55       be found at http://www.kernel.org/doc/man-pages/.
56
57
58
59                                  2009-07-25                        COMPLEX(7)
Impressum