OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man7 / complex.7
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
5 .\" %%%LICENSE_END
6 .\"
7 .TH COMPLEX 7 2011-09-16 "" "Linux Programmer's Manual"
8 .SH NAME
9 complex \- basics of complex mathematics
10 .SH SYNOPSIS
11 .B #include <complex.h>
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.
15 .br
16 There are other ways to represent that number.
17 The pair (a,b) of real
18 numbers may be viewed as a point in the plane, given by X- and
19 Y-coordinates.
20 This same point may also be described by giving
21 the pair of real numbers (r,phi), where r is the distance to the origin O,
22 and phi the angle between the X-axis and the line Oz.
23 Now
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
35 some complex-only functions.
36 .SH EXAMPLE
37 Your C-compiler can work with complex numbers if it supports the C99 standard.
38 Link with \fI\-lm\fP.
39 The imaginary unit is represented by I.
40 .sp
41 .nf
42 /* check that exp(i * pi) == \-1 */
43 #include <math.h>        /* for atan */
44 #include <stdio.h>
45 #include <complex.h>
46
47 int
48 main(void)
49 {
50     double pi = 4 * atan(1.0);
51     double complex z = cexp(I * pi);
52     printf("%f + %f * i\\n", creal(z), cimag(z));
53 }
54 .fi
55 .SH SEE ALSO
56 .BR cabs (3),
57 .BR cacos (3),
58 .BR cacosh (3),
59 .BR carg (3),
60 .BR casin (3),
61 .BR casinh (3),
62 .BR catan (3),
63 .BR catanh (3),
64 .BR ccos (3),
65 .BR ccosh (3),
66 .BR cerf (3),
67 .BR cexp (3),
68 .BR cexp2 (3),
69 .BR cimag (3),
70 .BR clog (3),
71 .BR clog10 (3),
72 .BR clog2 (3),
73 .BR conj (3),
74 .BR cpow (3),
75 .BR cproj (3),
76 .BR creal (3),
77 .BR csin (3),
78 .BR csinh (3),
79 .BR csqrt (3),
80 .BR ctan (3),
81 .BR ctanh (3)
82 .SH COLOPHON
83 This page is part of release 3.79 of the Linux
84 .I man-pages
85 project.
86 A description of the project,
87 information about reporting bugs,
88 and the latest version of this page,
89 can be found at
90 \%http://www.kernel.org/doc/man\-pages/.