This notebook is licenced under CC BY-SA 4.0.

FriCAS Tutorial (SkewPolynomial)

Ralf Hemmecke <ralf@hemmecke.org>

Sources at Github.

In [1]:
)set message type off
)set output algebra off
setFormat!(FormatMathJax)$JFriCASSupport
)set message type on
In [2]:
)version
Value = "FriCAS a9422d32eb6f6b03d98ac6adfc9bf05ec0f5e8bd compiled at Sa 03 Apr 2021 00:29:13 CEST"

Univariate differential case

Let's first consider a differential operator algebra $A$ over the integers $\mathbb{Z}$. $A$ can be represented as a polynomial ring in the variable $X$ over the polynomial ring $\mathbb{Z}[x]$ where the variable $X$ commutes with the coefficients by the rule $X x = x X + 1$.

In [3]:
Z ==> Integer
Zx ==> UnivariatePolynomial('x, Z)
Out[3]:
Out[3]:

In FriCAS, such a skew polynomial algebra is not given by the above rule, but rather by a general commutation rule. $X p = \sigma(p) X + \delta(p)$, $p\in\mathbb{Z}[x]$.

For a differential algebra $\sigma$ is the identity map and $\delta$ is the derivation of $\mathbb{Z}[x]$ given by $\delta(x)=1$.

In [5]:
sigma1: Automorphism Zx := 1
delta1: Zx -> Zx := D $ Zx
Out[5]:
\[ \texttt{R -> R} \]
Out[5]:
\[ \operatorname{theMap}(D) \]

The notation D $ Zz specifies that FriCAS should take the function $D$ from the domain Zx.

In [6]:
A ==> UnivariateSkewPolynomial('X, Zx, sigma1, delta1)
Out[6]:

In order to work in $A$, we name the indeterminates.

In [9]:
x: A := 'x
X: A := 'X
X*x
Out[9]:
\[ x \]
Out[9]:
\[ X \]
Out[9]:
\[ x\, X+1 \]
In [10]:
(x+X)^3
Out[10]:
\[ {X}^{3}+3\, x\, {X}^{2}+\left(3\, {x}^{2}+3\right)\, X+{x}^{3}+3\, x \]

Univariate shift case

Similarly, we can define a shift algebra $B$ with the respective variables $s$ and $S$, such that $S s = (s+1) S$.

Note that we introduce that shift algebra with coefficients coming from the above operator algebra $A$.

In [12]:
As ==> UnivariatePolynomial('s, A)
ss: As := 's
Out[12]:
Out[12]:
\[ s \]
In [13]:
sigma2: Automorphism As := 
  morphism((p: As): As +->eval(p, ss = ss+1),
           (p: As): As +->eval(p, ss = ss-1))
Out[13]:
\[ \texttt{R -> R} \]
In [14]:
delta2: As -> As := (p: As): As +-> 0
Out[14]:
\[ \operatorname{theMap}(anonymousFunction) \]
In [15]:
B ==> UnivariateSkewPolynomial('S, As, sigma2, delta2)
Out[15]:
In [17]:
s: B := 's
S: B := 'S
Out[17]:
\[ s \]
Out[17]:
\[ S \]
In [18]:
S*s
Out[18]:
\[ \left(s+1\right)\, S \]

Of course, $S$ and $s$ commute with $X$ and $x$.

In [19]:
[S*X, S*x, s*X, s*x]
Out[19]:
\[ \left[X\, S, x\, S, X\, s, x\, s\right] \]

In this skew polynomial algebra, the multiplication sign uses the appropriate commutation rule.

In [20]:
S*X*s
Out[20]:
\[ \left(X\, s+X\right)\, S \]
In [21]:
S^2*X^2*(s-1)*x
Out[21]:
\[ \left(\left(x\, {X}^{2}+2\, X\right)\, s+x\, {X}^{2}+2\, X\right)\, {S}^{2} \]

Multivariate case

The multivariate case is only sligthly more complicated.

Our goal is to create the skew polynomial ring $\mathbb{Q}(q)(y,w,u)[D_y,D_w,D_u]$ where

  • $D_y \cdot y = y \cdot D_y + 1$
  • $D_w \cdot w = (w+1) \cdot D_w$
  • $D_u \cdot u = q u \cdot D_u$

Let us here use a field of rational functions in $q$ as coefficient domain.

In [23]:
)clear prop u y w
Z ==> Integer
Qq ==> Fraction UnivariatePolynomial('q, Z)
Out[23]:
Out[23]:

Now we define two sets of variables. The upper case letter will correspond to the "operator" variable, but in fact, we will not have any "operator algebra" here, since there is no action on any set involved.

In [24]:
V ==> OrderedVariableList ['y, 'w, 'u]
Out[24]:

The lower case letters will be put into the "coefficient domain".

In [26]:
M ==> SparseMultivariatePolynomial(Qq, V)
K := Fraction M
Out[26]:
Out[26]:

We need the respective "sigma" and "delta" functions that define the commutation rules of the skew polynomial ring.

First for the variable $y$.

In [30]:
sigmay: Automorphism K := 1;
yv: V:= 'y;
derivy(m: M): M == D(m, yv)
deltay(k: K): K == D(k, derivy)
Out[30]:
Function declaration derivy : SparseMultivariatePolynomial(Fraction(
UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u])) -> 
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u])) has been added to workspace.
Out[30]:
Function declaration deltay : Fraction(SparseMultivariatePolynomial(Fraction(
UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[30]:

Then for $w$. Note that we will reuse the delta function also for the variable $u$.

In [35]:
wm: M := 'w;
sigmaw1(k: K): K == eval(k, wm, wm+1)
sigmaw2(k: K): K == eval(k, wm, wm-1)
sigmaw: Automorphism K := morphism(sigmaw1, sigmaw2);
deltawu(k: K): K == 0
Function declaration sigmaw1 : Fraction(SparseMultivariatePolynomial(Fraction
(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[35]:
Function declaration sigmaw2 : Fraction(SparseMultivariatePolynomial(Fraction
(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[35]:
Compiling function sigmaw1 with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 
Compiling function sigmaw2 with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 
Function declaration deltawu : Fraction(SparseMultivariatePolynomial(Fraction
(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[35]:

And finally for $u$.

In [39]:
um: M := 'u; qQ: Qq := 'q::Qq; qQ1 := inv qQ;
sigmau1(k: K): K == eval(k, um, qQ*um)$K
sigmau2(k: K): K == eval(k, um, qQ1*um)$K
sigmau: Automorphism K := morphism(sigmau1, sigmau2)$Automorphism(K);
Function declaration sigmau1 : Fraction(SparseMultivariatePolynomial(Fraction
(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[39]:
Function declaration sigmau2 : Fraction(SparseMultivariatePolynomial(Fraction
(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) has been added to workspace.
Out[39]:
Compiling function sigmau1 with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 
Compiling function sigmau2 with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 

With the auxiliary functions above, we can define the sigma and delta function that we actually need for the definition of the domain. The code below, basically selects one of the functions above depending on which variables are involved.

In [42]:
YV: V := index(1)$V; WV: V := index(2)$V;
sigma(v: V): Automorphism K ==
  if v=YV then sigmay else if v=WV then sigmaw else sigmau
delta(v: V): K -> K == if v=YV then deltay else deltawu
Out[42]:
Function declaration sigma : OrderedVariableList([y,w,u]) -> Automorphism(
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u])))) has been added to workspace.
Out[42]:
Function declaration delta : OrderedVariableList([y,w,u]) -> (Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) -> Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u])))) has
 been added to workspace.
Out[42]:

We put everything together.

In [43]:
T ==> SparseMultivariateSkewPolynomial(K, V, sigma, delta)
Out[43]:
In [45]:
y: T := 'y::K::T;
w: T := 'w::K::T; u: T := 'u::K::T; q: T := qQ::K::T;
Compiling function sigma with type OrderedVariableList([y,w,u]) -> 
Automorphism(Fraction(SparseMultivariatePolynomial(Fraction(
UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u])))) 
Compiling function delta with type OrderedVariableList([y,w,u]) -> (Fraction(
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u]))) -> Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u])))) 
In [48]:
Y: T := monomial(1, index(1)$V, 1)
W: T := monomial(1, index(2)$V, 1)
U: T := monomial(1, index(3)$V, 1)
Out[48]:
\[ {D}_{y} \]
Out[48]:
\[ {D}_{w} \]
Out[48]:
\[ {D}_{u} \]
In [49]:
u
Out[49]:
\[ u \]
In [53]:
t: T := y*w*u*q
Y*t
W*t
U*t
Out[53]:
\[ q\, u\, w\, y \]
Compiling function deltay with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 
Compiling function derivy with type SparseMultivariatePolynomial(Fraction(
UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u])) -> 
SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer)),
OrderedVariableList([y,w,u])) 
Out[53]:
\[ q\, u\, w\, y\, {D}_{y}+q\, u\, w \]
Compiling function deltawu with type Fraction(SparseMultivariatePolynomial(
Fraction(UnivariatePolynomial(q,Integer)),OrderedVariableList([y,w,u]))) -> 
Fraction(SparseMultivariatePolynomial(Fraction(UnivariatePolynomial(q,Integer
)),OrderedVariableList([y,w,u]))) 
Out[53]:
\[ \left(q\, u\, w+q\, u\right)\, y\, {D}_{w} \]
Out[53]:
\[ {q}^{2}\, u\, w\, y\, {D}_{u} \]
In [54]:
W^2*Y^2*(w-1)*y
Out[54]:
\[ \left(w+1\right)\, y\, {\left({D}_{w}\right)}^{2}\, {\left({D}_{y}\right)}^{2}+\left(2\, w+2\right)\, {\left({D}_{w}\right)}^{2}\, {D}_{y} \]

Vectors and Matrices over Skew Polynomial Rings

In [55]:
VT ==> Vector T
Out[55]:
In [56]:
[Y, W, U]
Out[56]:
\[ \left[{D}_{y}, {D}_{w}, {D}_{u}\right] \]
In [57]:
lt: List T := [Y, W, U]
Out[57]:
\[ \left[{D}_{y}, {D}_{w}, {D}_{u}\right] \]
In [58]:
vt: VT := vector lt
Out[58]:
\[ \left[{D}_{y}, {D}_{w}, {D}_{u}\right] \]
In [59]:
dot(vt, vt)
Out[59]:
\[ {\left({D}_{y}\right)}^{2}+{\left({D}_{w}\right)}^{2}+{\left({D}_{u}\right)}^{2} \]
In [60]:
dot(vt, vt*y*w*u)
Out[60]:
\[ u\, w\, y\, {\left({D}_{y}\right)}^{2}+2\, u\, w\, {D}_{y}+\left(u\, w+2\, u\right)\, y\, {\left({D}_{w}\right)}^{2}+{q}^{2}\, u\, w\, y\, {\left({D}_{u}\right)}^{2} \]
In [62]:
w*vt
vt*w
Out[62]:
\[ \left[w\, {D}_{y}, w\, {D}_{w}, w\, {D}_{u}\right] \]
Out[62]:
\[ \left[w\, {D}_{y}, \left(w+1\right)\, {D}_{w}, w\, {D}_{u}\right] \]
In [64]:
MT ==> SquareMatrix(3, T)
mt: MT := 1
Out[64]:
Out[64]:
\[ \begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix} \]
In [65]:
mt: MT := diagonalMatrix lt
Out[65]:
\[ \begin{bmatrix}{D}_{y}&0&0\\0&{D}_{w}&0\\0&0&{D}_{u}\end{bmatrix} \]
In [66]:
mt2: MT := matrix [[0,y,w],[0,0,u],[0,0,0]]
Out[66]:
\[ \begin{bmatrix}0&y&w\\0&0&u\\0&0&0\end{bmatrix} \]
In [67]:
m := mt+mt2
Out[67]:
\[ \begin{bmatrix}{D}_{y}&y&w\\0&{D}_{w}&u\\0&0&{D}_{u}\end{bmatrix} \]
In [68]:
m*m
Out[68]:
\[ \begin{bmatrix}{\left({D}_{y}\right)}^{2}&y\, {D}_{y}+y\, {D}_{w}+1&w\, {D}_{y}+w\, {D}_{u}+u\, y\\0&{\left({D}_{w}\right)}^{2}&u\, {D}_{w}+u\, {D}_{u}\\0&0&{\left({D}_{u}\right)}^{2}\end{bmatrix} \]
In [70]:
DT ==> DirectProduct(3, T)
dt: DT := [u*W+1, w*y, w^2*W*u]
Out[70]:
Out[70]:
\[ \left[u\, {D}_{w}+1, w\, y, u\, {w}^{2}\, {D}_{w}\right] \]
In [71]:
m*m*dt
Out[71]:
\[ \left[\left(u\, {D}_{w}+1\right)\, {\left({D}_{y}\right)}^{2}+\left(u\, {w}^{3}\, {D}_{w}+w\, {y}^{2}\right)\, {D}_{y}+\left(q\, u\, {w}^{3}\, {D}_{u}+\left(w+1\right)\, {y}^{2}+{u}^{2}\, {w}^{2}\, y\right)\, {D}_{w}+2\, w\, y, \left(\left(w+2\right)\, y+{u}^{2}\, {w}^{2}+2\, {u}^{2}\, w+{u}^{2}\right)\, {\left({D}_{w}\right)}^{2}+q\, {u}^{2}\, {w}^{2}\, {D}_{u}\, {D}_{w}, {q}^{2}\, u\, {w}^{2}\, {\left({D}_{u}\right)}^{2}\, {D}_{w}\right] \]
In [72]:
MT has Ring
Out[72]:
\[ \texttt{true} \]
In [73]:
MT has CommutativeRing
Out[73]:
\[ \texttt{false} \]
In [74]:
mt*mt2
Out[74]:
\[ \begin{bmatrix}0&y\, {D}_{y}+1&w\, {D}_{y}\\0&0&u\, {D}_{w}\\0&0&0\end{bmatrix} \]
In [75]:
mt2*mt
Out[75]:
\[ \begin{bmatrix}0&y\, {D}_{w}&w\, {D}_{u}\\0&0&u\, {D}_{u}\\0&0&0\end{bmatrix} \]
In [76]:
mt*mt2-mt2*mt
Out[76]:
\[ \begin{bmatrix}0&y\, {D}_{y}-y\, {D}_{w}+1&w\, {D}_{y}-w\, {D}_{u}\\0&0&u\, {D}_{w}-u\, {D}_{u}\\0&0&0\end{bmatrix} \]
In [77]:
P ==> UnivariatePolynomial('x, MT)
Out[77]:
In [78]:
p: P := mt2*x^2+mt*x+m
Out[78]:
\[ \begin{bmatrix}0&y&w\\0&0&u\\0&0&0\end{bmatrix}\, {x}^{2}+\begin{bmatrix}{D}_{y}&0&0\\0&{D}_{w}&0\\0&0&{D}_{u}\end{bmatrix}\, x+\begin{bmatrix}{D}_{y}&y&w\\0&{D}_{w}&u\\0&0&{D}_{u}\end{bmatrix} \]
In [79]:
p*p
Out[79]:
\[ \begin{bmatrix}0&0&u\, y\\0&0&0\\0&0&0\end{bmatrix}\, {x}^{4}+\begin{bmatrix}0&y\, {D}_{y}+y\, {D}_{w}+1&w\, {D}_{y}+w\, {D}_{u}\\0&0&u\, {D}_{w}+u\, {D}_{u}\\0&0&0\end{bmatrix}\, {x}^{3}+\begin{bmatrix}{\left({D}_{y}\right)}^{2}&y\, {D}_{y}+y\, {D}_{w}+1&w\, {D}_{y}+w\, {D}_{u}+2\, u\, y\\0&{\left({D}_{w}\right)}^{2}&u\, {D}_{w}+u\, {D}_{u}\\0&0&{\left({D}_{u}\right)}^{2}\end{bmatrix}\, {x}^{2}+\begin{bmatrix}2\, {\left({D}_{y}\right)}^{2}&y\, {D}_{y}+y\, {D}_{w}+1&w\, {D}_{y}+w\, {D}_{u}\\0&2\, {\left({D}_{w}\right)}^{2}&u\, {D}_{w}+u\, {D}_{u}\\0&0&2\, {\left({D}_{u}\right)}^{2}\end{bmatrix}\, x+\begin{bmatrix}{\left({D}_{y}\right)}^{2}&y\, {D}_{y}+y\, {D}_{w}+1&w\, {D}_{y}+w\, {D}_{u}+u\, y\\0&{\left({D}_{w}\right)}^{2}&u\, {D}_{w}+u\, {D}_{u}\\0&0&{\left({D}_{u}\right)}^{2}\end{bmatrix} \]
In [80]:
P has CommutativeRing
Out[80]:
\[ \texttt{false} \]