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),  cacos(3),  cacosh(3), carg(3), casin(3), casinh(3), catan(3),
51       catanh(3), ccos(3), ccosh(3),  cerf(3),  cexp(3),  cexp2(3),  cimag(3),
52       clog(3),  clog10(3),  clog2(3),  conj(3),  cpow(3), cproj(3), creal(3),
53       csin(3), csinh(3), csqrt(3), ctan(3), ctanh(3)
54

COLOPHON

56       This page is part of release 3.53 of the Linux  man-pages  project.   A
57       description  of  the project, and information about reporting bugs, can
58       be found at http://www.kernel.org/doc/man-pages/.
59
60
61
62                                  2011-09-16                        COMPLEX(7)
Impressum