]>
Commit | Line | Data |
---|---|---|
481aaca1 | 1 | .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
2297bf0e | 2 | .\" |
95fb8859 | 3 | .\" SPDX-License-Identifier: GPL-1.0-or-later |
481aaca1 | 4 | .\" |
4c1c5274 | 5 | .TH complex 7 (date) "Linux man-pages (unreleased)" |
481aaca1 MK |
6 | .SH NAME |
7 | complex \- basics of complex mathematics | |
8 | .SH SYNOPSIS | |
c7db92b9 | 9 | .nf |
481aaca1 | 10 | .B #include <complex.h> |
c7db92b9 | 11 | .fi |
481aaca1 MK |
12 | .SH DESCRIPTION |
13 | Complex numbers are numbers of the form z = a+b*i, where a and b are | |
14 | real numbers and i = sqrt(\-1), so that i*i = \-1. | |
fa814524 | 15 | .PP |
c13182ef MK |
16 | There are other ways to represent that number. |
17 | The pair (a,b) of real | |
481aaca1 | 18 | numbers may be viewed as a point in the plane, given by X- and |
c13182ef MK |
19 | Y-coordinates. |
20 | This same point may also be described by giving | |
481aaca1 | 21 | the pair of real numbers (r,phi), where r is the distance to the origin O, |
c13182ef MK |
22 | and phi the angle between the X-axis and the line Oz. |
23 | Now | |
481aaca1 MK |
24 | z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)). |
25 | .PP | |
26 | The basic operations are defined on z = a+b*i and w = c+d*i as: | |
27 | .TP | |
28 | .B addition: z+w = (a+c) + (b+d)*i | |
29 | .TP | |
30 | .B multiplication: z*w = (a*c \- b*d) + (a*d + b*c)*i | |
31 | .TP | |
32 | .B division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c \- a*d)/(c*c + d*d))*i | |
33 | .PP | |
34 | Nearly all math function have a complex counterpart but there are | |
faebe20b | 35 | some complex-only functions. |
a14af333 | 36 | .SH EXAMPLES |
481aaca1 | 37 | Your C-compiler can work with complex numbers if it supports the C99 standard. |
20c58d70 | 38 | Link with \fI\-lm\fP. |
c13182ef | 39 | The imaginary unit is represented by I. |
bdd915e2 MK |
40 | .PP |
41 | .EX | |
cf0a9ace | 42 | /* check that exp(i * pi) == \-1 */ |
7295b7ed | 43 | #include <math.h> /* for atan */ |
9935c43c | 44 | #include <stdio.h> |
481aaca1 | 45 | #include <complex.h> |
cf0a9ace MK |
46 | |
47 | int | |
c13182ef | 48 | main(void) |
cf0a9ace | 49 | { |
9a77f5ef | 50 | double pi = 4 * atan(1.0); |