1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
3 .\" SPDX-License-Identifier: GPL-1.0-or-later
5 .TH complex 7 (date) "Linux man-pages (unreleased)"
7 complex \- basics of complex mathematics
10 .RI ( libm ", " \-lm )
13 .B #include <complex.h>
16 Complex numbers are numbers of the form z = a+b*i, where a and b are
17 real numbers and i = sqrt(\-1), so that i*i = \-1.
19 There are other ways to represent that number.
20 The pair (a,b) of real
21 numbers may be viewed as a point in the plane, given by X- and
23 This same point may also be described by giving
24 the pair of real numbers (r,phi), where r is the distance to the origin O,
25 and phi the angle between the X-axis and the line Oz.
27 z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)).
29 The basic operations are defined on z = a+b*i and w = c+d*i as:
31 .B addition: z+w = (a+c) + (b+d)*i
33 .B multiplication: z*w = (a*c \- b*d) + (a*d + b*c)*i
35 .B division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c \- a*d)/(c*c + d*d))*i
37 Nearly all math function have a complex counterpart but there are
38 some complex-only functions.
40 Your C-compiler can work with complex numbers if it supports the C99 standard.
41 The imaginary unit is represented by I.
44 /* check that exp(i * pi) == \-1 */
45 #include <math.h> /* for atan */
52 double pi = 4 * atan(1.0);
53 double complex z = cexp(I * pi);
54 printf("%f + %f * i\en", creal(z), cimag(z));