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
|
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\XPolynomialRingXmpTitle}{XPolynomialRing}
\newcommand{\XPolynomialRingXmpNumber}{9.90}
%
% =====================================================================
\begin{page}{XPolynomialRingXmpPage}{9.90 XPolynomialRing}
% =====================================================================
\beginscroll
The \spadtype{XPolynomialRing} domain constructor implements
generalized polynomials with coefficients from an arbitrary \spadtype{Ring}
(not necessarily commutative) and whose exponents are
words from an arbitrary \spadtype{OrderedMonoid}
(not necessarily commutative too).
Thus these polynomials are (finite) linear combinations of words.
This constructor takes two arguments.
The first one is a \spadtype{Ring}
and the second is an \spadtype{OrderedMonoid}.
The abbreviation for \spadtype{XPolynomialRing} is \spadtype{XPR}.
Other constructors like \spadtype{XPolynomial}, \spadtype{XRecursivePolynomial}
\spadtype{XDistributedPolynomial},
\spadtype{LiePolynomial} and
\spadtype{XPBWPolynomial}
implement multivariate polynomials
in non-commutative variables.
We illustrate now some of the facilities of the \spadtype{XPR} domain constructor.
\xtc{
Define the free ordered monoid generated by the symbols.
}{
\spadpaste{Word := OrderedFreeMonoid(Symbol) \bound{Word}}
}
\xtc{
Define the linear combinations of these words with integer coefficients.
}{
\spadpaste{poly:= XPR(Integer,Word) \free{Word} \bound{poly}}
}
\xtc{
Then we define a first element from {\bf poly}.
}{
\spadpaste{p:poly := 2 * x - 3 * y + 1 \free{poly} \bound{p}}
}
\xtc{
And a second one.
}{
\spadpaste{q:poly := 2 * x + 1 \free{poly} \bound{q}}
}
\xtc{
We compute their sum,
}{
\spadpaste{p + q \free{p}\free{q} }
}
\xtc{
their product,
}{
\spadpaste{p * q \free{p}\free{q} }
}
\xtc{
and see that variables do not commute.
}{
\spadpaste{(p +q)^2 -p^2 -q^2 - 2*p*q \free{p}\free{q} }
}
\xtc{
Now we define a ring of square matrices,
}{
\spadpaste{M := SquareMatrix(2,Fraction Integer) \bound{M}}
}
\xtc{
and the linear combinations of words with these matrices as coefficients.
}{
\spadpaste{poly1:= XPR(M,Word) \free{Word} \free{M} \bound{poly1}}
}
\xtc{
Define a first matrix,
}{
\spadpaste{m1:M := matrix [[i*j**2 for i in 1..2] for j in 1..2] \free{M} \bound{m1}}
}
\xtc{
a second one,
}{
\spadpaste{m2:M := m1 - 5/4 \free{M} \free{m1} \bound{m2}}
}
\xtc{
and a third one.
}{
\spadpaste{m3: M := m2**2 \free{M} \free{m2} \bound{m3}}
}
\xtc{
Define a polynomial,
}{
\spadpaste{pm:poly1 := m1*x + m2*y + m3*z - 2/3 \free{poly1} \free{m1} \free{m2} \free{m3} \bound{pm}}
}
\xtc{
a second one,
}{
\spadpaste{qm:poly1 := pm - m1*x \free{m1} \free{pm} \bound{qm}}
}
\xtc{
and the following power.
}{
\spadpaste{qm**3 \bound{qm}}
}
\endscroll
\autobuttons
\end{page}
%
|