aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/OP.ht
blob: ef706a12d21bdf5ad524dc5d8d9377300577c5d7 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\OperatorXmpTitle}{Operator}
\newcommand{\OperatorXmpNumber}{9.58}
%
% =====================================================================
\begin{page}{OperatorXmpPage}{9.58 Operator}
% =====================================================================
\beginscroll
Given any ring \spad{R}, the ring of the \spadtype{Integer}-linear operators
over \spad{R} is called \spadtype{Operator(R)}.
%-% \HDindex{operator}{OperatorXmpPage}{9.58}{Operator}
To create an operator over \spad{R}, first create a basic operator using the
operation \spadfun{operator}, and then convert it to \spadtype{Operator(R)}
for the \spad{R} you want.
%
\xtc{
We choose \spad{R} to be the two by two matrices over the integers.
}{
\spadpaste{R := SQMATRIX(2, INT)\bound{r}}
}
\xtc{
Create the operator \spad{tilde} on \spad{R}.
}{
\spadpaste{t := operator("tilde") :: OP(R) \free{r}\bound{t}}
}
%
Since \spadtype{Operator} is unexposed we must either package-call operations
from it, or expose it explicitly.  For convenience we will do the latter.
%
\noOutputXtc{
Expose \spad{Operator}.
}{
\spadpaste{)set expose add constructor Operator \free{t}\bound{expose}}
}
%
To attach an evaluation function (from \spad{R} to \spad{R}) to an
operator over \spad{R}, use \spad{evaluate(op, f)} where \spad{op}
is an operator over \spad{R} and \spad{f} is a function \spad{R ->
R}.
This needs to be done only once when the operator is defined.
Note that \spad{f} must be \spadtype{Integer}-linear (that is,
\spad{f(ax+y) = a f(x) + f(y)} for any integer \spad{a}, and any
\spad{x} and \spad{y} in \spad{R}).
%
\xtc{
We now attach the transpose map to the above operator \spad{t}.
}{
\spadpaste{evaluate(t, m +-> transpose m)\free{expose}\free{t}\bound{evt}}
}
%
Operators can be manipulated formally as in any ring: \spadop{+} is the
pointwise addition and \spadop{*} is composition.
Any element \spad{x} of \spad{R} can be converted to an operator
\subscriptText{\tt op}{\tt x}
over \spad{R}, and the evaluation function of
\subscriptText{\tt op}{\tt x}
is left-multiplication by \spad{x}.
%
\xtc{
Multiplying on the
left by this matrix swaps the two rows.
}{
\spadpaste{s : R := matrix [[0, 1], [1, 0]]\bound{s}}
}
%
\xtc{
Can you guess what is the action of the following operator?
}{
\spadpaste{rho := t * s\free{evt s}\bound{rho}}
}
%
%
\xtc{
Hint: applying \spad{rho} four times gives the identity, so
\spad{rho**4-1} should return 0 when applied to any two by two matrix.
}{
\spadpaste{z := rho**4 - 1\free{rho}\bound{z}}
}
%
%
\xtc{
Now check with this matrix.
}{
\spadpaste{m:R := matrix [[1, 2], [3, 4]]\bound{m}}
}
\xtc{
}{
\spadpaste{z m\free{z m}}
}
%
%
\xtc{
As you have probably guessed by now, \spad{rho} acts on matrices
by rotating the elements clockwise.
}{
\spadpaste{rho m\free{rho m}}
}
\xtc{
}{
\spadpaste{rho rho m\free{rho m}}
}
\xtc{
}{
\spadpaste{(rho**3) m\free{rho m}}
}
%
%
\xtc{
Do the swapping of rows and transposition commute?
We can check by computing their bracket.
}{
\spadpaste{b := t * s - s * t\free{s evt}\bound{b}}
}
%
%
\xtc{
Now apply it to \spad{m}.
}{
\spadpaste{b m \free{b m}}
}
%
 
Next we demonstrate how to define a differential operator
on a polynomial ring.
\xtc{
This is the recursive definition of the \spad{n}-th Legendre polynomial.
%-% \HDindex{polynomial!Legendre}{OperatorXmpPage}{9.58}{Operator}
}{
\begin{spadsrc}[\bound{l}]
L n ==
  n = 0 => 1
  n = 1 => x
  (2*n-1)/n * x * L(n-1) - (n-1)/n * L(n-2)
\end{spadsrc}
}
\xtc{
Create the differential operator \texht{$d \over {dx}$}{\spad{d/dx}} on
polynomials in \spad{x} over the rational numbers.
}{
\spadpaste{dx := operator("D") :: OP(POLY FRAC INT) \bound{dx}}
}
\xtc{
Now attach the map to it.
}{
\spadpaste{evaluate(dx, p +-> D(p, 'x)) \free{dx}\bound{edx}}
}
\xtc{
This is the differential equation satisfied by the \spad{n}-th
Legendre polynomial.
}{
\spadpaste{E n == (1 - x**2) * dx**2 - 2 * x * dx + n*(n+1) \free{edx}\bound{E}}
}
\xtc{
Now we verify this for \spad{n = 15}.
Here is the polynomial.
}{
\spadpaste{L 15 \free{L}}
}
\xtc{
Here is the operator.
}{
\spadpaste{E 15 \free{E}}
}
\xtc{
Here is the evaluation.
}{
\spadpaste{(E 15)(L 15) \free{L E}}
}
\endscroll
\autobuttons
\end{page}
%