OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / man7 / complex.7
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\"
4 .TH COMPLEX 7 2011-09-16 "" "Linux Programmer's Manual"
5 .SH NAME
6 complex \- basics of complex mathematics
7 .SH SYNOPSIS
8 .B #include <complex.h>
9 .SH DESCRIPTION
10 Complex numbers are numbers of the form z = a+b*i, where a and b are
11 real numbers and i = sqrt(\-1), so that i*i = \-1.
12 .br
13 There are other ways to represent that number.
14 The pair (a,b) of real
15 numbers may be viewed as a point in the plane, given by X- and
16 Y-coordinates.
17 This same point may also be described by giving
18 the pair of real numbers (r,phi), where r is the distance to the origin O,
19 and phi the angle between the X-axis and the line Oz.
20 Now
21 z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)).
22 .PP
23 The basic operations are defined on z = a+b*i and w = c+d*i as:
24 .TP
25 .B addition: z+w = (a+c) + (b+d)*i
26 .TP
27 .B multiplication: z*w = (a*c \- b*d) + (a*d + b*c)*i
28 .TP
29 .B division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c \- a*d)/(c*c + d*d))*i
30 .PP
31 Nearly all math function have a complex counterpart but there are
32 some complex-only functions.
33 .SH EXAMPLE
34 Your C-compiler can work with complex numbers if it supports the C99 standard.
35 Link with \fI\-lm\fP.
36 The imaginary unit is represented by I.
37 .sp
38 .nf
39 /* check that exp(i * pi) == \-1 */
40 #include <math.h>        /* for atan */
41 #include <stdio.h>
42 #include <complex.h>
43
44 int
45 main(void)
46 {
47     double pi = 4 * atan(1.0);
48     double complex z = cexp(I * pi);
49     printf("%f + %f * i\\n", creal(z), cimag(z));
50 }
51 .fi
52 .SH "SEE ALSO"
53 .BR cabs (3),
54 .BR cacos (3),
55 .BR cacosh (3),
56 .BR carg (3),
57 .BR casin (3),
58 .BR casinh (3),
59 .BR catan (3),
60 .BR catanh (3),
61 .BR ccos (3),
62 .BR ccosh (3),
63 .BR cerf (3),
64 .BR cexp (3),
65 .BR cexp2 (3),
66 .BR cimag (3),
67 .BR clog (3),
68 .BR clog10 (3),
69 .BR clog2 (3),
70 .BR conj (3),
71 .BR cpow (3),
72 .BR cproj (3),
73 .BR creal (3),
74 .BR csin (3),
75 .BR csinh (3),
76 .BR csqrt (3),
77 .BR ctan (3),
78 .BR ctanh (3)