1complex(7) Miscellaneous Information Manual complex(7)
2
3
4
6 complex - basics of complex mathematics
7
9 Math library (libm, -lm)
10
12 #include <complex.h>
13
15 Complex numbers are numbers of the form z = a+b*i, where a and b are
16 real numbers and i = sqrt(-1), so that i*i = -1.
17
18 There are other ways to represent that number. The pair (a,b) of real
19 numbers may be viewed as a point in the plane, given by X- and Y-coor‐
20 dinates. This same point may also be described by giving the pair of
21 real numbers (r,phi), where r is the distance to the origin O, and phi
22 the angle between the X-axis and the line Oz. Now z = r*exp(i*phi) =
23 r*(cos(phi)+i*sin(phi)).
24
25 The basic operations are defined on z = a+b*i and w = c+d*i as:
26
27 addition: z+w = (a+c) + (b+d)*i
28
29 multiplication: z*w = (a*c - b*d) + (a*d + b*c)*i
30
31 division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c - a*d)/(c*c + d*d))*i
32
33 Nearly all math function have a complex counterpart but there are some
34 complex-only functions.
35
37 Your C-compiler can work with complex numbers if it supports the C99
38 standard. The imaginary unit is represented by I.
39
40 /* check that exp(i * pi) == -1 */
41 #include <math.h> /* for atan */
42 #include <stdio.h>
43 #include <complex.h>
44
45 int
46 main(void)
47 {
48 double pi = 4 * atan(1.0);
49 double complex z = cexp(I * pi);
50 printf("%f + %f * i\n", creal(z), cimag(z));
51 }
52
54 cabs(3), cacos(3), cacosh(3), carg(3), casin(3), casinh(3), catan(3),
55 catanh(3), ccos(3), ccosh(3), cerf(3), cexp(3), cexp2(3), cimag(3),
56 clog(3), clog10(3), clog2(3), conj(3), cpow(3), cproj(3), creal(3),
57 csin(3), csinh(3), csqrt(3), ctan(3), ctanh(3)
58
59
60
61Linux man-pages 6.05 2023-07-18 complex(7)