aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/COMPLEX.ht
blob: f01b98f1e11edc887cb695ec59848ab5ab9bb545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\ComplexXmpTitle}{Complex}
\newcommand{\ComplexXmpNumber}{9.11}
%
% =====================================================================
\begin{page}{ComplexXmpPage}{9.11 Complex}
% =====================================================================
\beginscroll
%

The \spadtype{Complex} constructor implements complex objects over a
commutative ring \spad{R}.
Typically, the ring \spad{R} is \spadtype{Integer}, \spadtype{Fraction
Integer}, \spadtype{Float} or \spadtype{DoubleFloat}.
\spad{R} can also be a symbolic type, like \spadtype{Polynomial Integer}.
For more information about the numerical and graphical aspects of complex
numbers, see \downlink{``\ugProblemNumericTitle''}{ugProblemNumericPage} in Section \ugProblemNumericNumber\ignore{ugProblemNumeric}.

\xtc{
Complex objects are created by the \spadfunFrom{complex}{Complex} operation.
}{
\spadpaste{a := complex(4/3,5/2) \bound{a}}
}
\xtc{
}{
\spadpaste{b := complex(4/3,-5/2) \bound{b}}
}
\xtc{
The standard arithmetic operations are available.
}{
\spadpaste{a + b \free{a b}}
}
\xtc{
}{
\spadpaste{a - b \free{a b}}
}
\xtc{
}{
\spadpaste{a * b \free{a b}}
}
\xtc{
If \spad{R} is a field, you can also divide the complex objects.
}{
\spadpaste{a / b \free{a b}\bound{adb}}
}
\xtc{
Use a conversion (\downlink{``\ugTypesConvertTitle''}{ugTypesConvertPage} in Section \ugTypesConvertNumber\ignore{ugTypesConvert}) to view the last
object as a fraction of complex integers.
}{
\spadpaste{\% :: Fraction Complex Integer \free{adb}}
}
\xtc{
The predefined macro \spad{\%i} is defined to be \spad{complex(0,1)}.
}{
\spadpaste{3.4 + 6.7 * \%i}
}
\xtc{
You can also compute the \spadfunFrom{conjugate}{Complex} and
\spadfunFrom{norm}{Complex} of a complex number.
}{
\spadpaste{conjugate a \free{a}}
}
\xtc{
}{
\spadpaste{norm a \free{a}}
}
\xtc{
The \spadfunFrom{real}{Complex} and \spadfunFrom{imag}{Complex} operations
are provided to extract the real and imaginary parts, respectively.
}{
\spadpaste{real a \free{a}}
}
\xtc{
}{
\spadpaste{imag a \free{a}}
}

\xtc{
The domain \spadtype{Complex Integer} is also called the Gaussian
integers.
%-% \HDindex{Gaussian integer}{ComplexXmpPage}{9.11}{Complex}
If \spad{R} is the integers (or, more generally,
a \spadtype{EuclideanDomain}), you can compute greatest common divisors.
}{
\spadpaste{gcd(13 - 13*\%i,31 + 27*\%i)}
}
\xtc{
You can also compute least common multiples.
}{
\spadpaste{lcm(13 - 13*\%i,31 + 27*\%i)}
}
\xtc{
You can \spadfunFrom{factor}{Complex} Gaussian integers.
}{
\spadpaste{factor(13 - 13*\%i)}
}
\xtc{
}{
\spadpaste{factor complex(2,0)}
}
\endscroll
\autobuttons
\end{page}
%