====================================================================
UnivariateSkewPolynomial examples
====================================================================

Skew or Ore polynomial rings provide a unified framework to
compute with differential and difference equations.

In the following, let A be an integral domain, equipped with two
endomorphisms \sigma and \delta where:

 \sigma: A -> A is an injective ring endomorphism
 \delta: A -> A, the pseudo-derivation with respect to \sigma, 
         is an additive endomorphism with 

     \delta(ab) = \sigma(a)\delta(b) + \delta(a)b
    
         for all a,b in A

Note that in the domains and categories below, these properties are
not checked.

The skew polynomial ring [\Delta;\sigma,\delta] is the ring of 
polynomials in \Delta with coefficients in A, with the usual addition,
while the product is given by

 \Delta a = \sigma(a)\Delta + \delta(a) for a in A

The two most important examples of skew polynomial rings are:

  K(x)[D,1,\delta], where 1 is the identity on K and \delta is 
                    the usual derviative, is the ring of differential
                    polynomials

  K [E,n,\mapsto n+1,0] is the ring of linear recurrence operators
   n                    with polynomial coefficients


_____________________________________________________________________

For example, 

The UnivariateSkewPolynomialCategory (OREPCAT) provides a unified
framework for polynomial rings in a non-central indeterminate over
some coefficient ring R. The commutation relations between the
indeterminate x and the coefficient t is given by 

   x r = \sigma(r) x + \delta(r)

where \sigma is a ring endomorphism of R
and   \delta is a \sigma-derivation of R
which is an additive map from R to R such that
  
   \delta(rs) = \sigma(r) \delta(s) + \delta(r) s

In case \sigma is the identity map on R, a \sigma-derivation of R
is just called a derivation. Here are some examples

We start with a linear ordinary differential operator. First, we
define the coefficient ring to be expressions in one variable x
with fractional coefficients:

   F:=EXPR(FRAC(INT))

Define Dx to be a derivative d/dx:

   Dx:F->F:=f+->D(f,['x])

Define a skew polynomial ring over F with identity endomorphism as
\sigma and derivation d/dx as \delta:

   D0:=OREUP('d,F,1,Dx)

   u:D0:=(operator 'u)(x)

   d:D0:='d

   a:D0:=u^3*d^3+u^2*d^2+u*d+1

            3 3       2 2
        u(x) d  + u(x) d  + u(x)d + 1

   b:D0:=(u+1)*d^2+2*d

                   2
        (u(x) + 1)d  + 2d

   r:=rightDivide(a,b)

                                 3 ,          3       2
                    3      - u(x) u (x) - u(x)  + u(x)
                u(x)
   [quotient= -------- d + ----------------------------,
              u(x) + 1               2
                                 u(x)  + 2u(x) + 1
                    3 ,           3
               2u(x) u (x) + 3u(x)  + u(x)

    remainder= --------------------------- d + 1]
                        2
                    u(x)  + 2u(x) + 1


   r.quotient

                           3 ,          3       2
              3      - u(x) u (x) - u(x)  + u(x)
          u(x)
        -------- d + ----------------------------
        u(x) + 1               2
                           u(x)  + 2u(x) + 1


   r.remainder

              3 ,           3
         2u(x) u (x) + 3u(x)  + u(x)

         --------------------------- d + 1
                  2
              u(x)  + 2u(x) + 1


_____________________________________________________________________

   )clear all

As a second example, we consider the so-called Weyl algebra.

Define the coefficient ring to be an ordinary polynomial over integers
in one variable t
 
   R:=UP('t,INT)

Define a skew polynomial ring over R with identity map as \sigma
and derivation d/dt as \delta. The resulting algebra is then called
a Weyl algebra. This is a simple ring over a division ring that is
non-commutative, similar to the ring of matrices.

   W:=OREUP('x,R,1,D)

   t:W:='t

   x:W:='x

Let 

   a:W:=(t-1)*x^4+(t^3+3*t+1)*x^2+2*t*x+t^3

                4     3           2           3
        (t - 1)x  + (t  + 3t + 1)x  + 2t x + t

   b:W:=(6*t^4+2*t^2)*x^3+3*t^2*x^2

           4     2  3     2 2
        (6t  + 2t )x  + 3t x

Then

   a*b
           5     4     3     2  7       4      3      2        6
        (6t  - 6t  + 2t  - 2t )x  + (96t  - 93t  + 13t  - 16t)x
      + 
           7      5     4       3       2       5
        (6t  + 20t  + 6t  + 438t  - 406t  - 24)x
      + 
            6      5       4      3       2              4
        (48t  + 15t  + 152t  + 61t  + 603t  - 532t - 36)x
      + 
           7      5      4       3       2               3
        (6t  + 74t  + 60t  + 226t  + 116t  + 168t - 140)x
      + 
           5     3      2            2
        (3t  + 6t  + 12t  + 18t + 6)x

   a^3
         3     2           12      5     4      3      2           10
       (t  - 3t  + 3t - 1)x   + (3t  - 6t  + 12t  - 15t  + 3t + 3)x
     + 
          3      2       9      7     6      5      4      3     2            8
       (6t  - 12t  + 6t)x  + (3t  - 3t  + 21t  - 18t  + 24t  - 9t  - 15t - 3)x
     + 
           5      4      3      2        7
       (12t  - 12t  + 36t  - 24t  - 12t)x
     + 
         9      7     6      5     4      3      2           6
       (t  + 15t  - 3t  + 45t  + 6t  + 36t  + 15t  + 9t + 1)x
     + 
          7      5      3      2       5
       (6t  + 48t  + 54t  + 36t  + 6t)x
     + 
          9      7     6      5      4      3      2  4
       (3t  + 21t  + 3t  + 39t  + 18t  + 39t  + 12t )x
     + 
           7      5      4     3  3      9     7     6      5  2     7     9
       (12t  + 36t  + 12t  + 8t )x  + (3t  + 9t  + 3t  + 12t )x  + 6t x + t


_____________________________________________________________________

   )clear all 

As a third example, we construct a difference operator algebra over
the ring of EXPR(INT) by using an automorphism S defined by a
"shift" operation S:EXPR(INT) -> EXPR(INT)

   s(e)(n) = e(n+1)

and an S-derivation defined by DF:EXPR(INT) -> EXPR(INT) as

   DF(e)(n) = e(n+1)-e(n)

Define S to be a "shift" operator, which acts on expressions with 
the discrete variable n:

   S:EXPR(INT)->EXPR(INT):=e+->eval(e,[n],[n+1])

Define DF to be a "difference" operator, which acts on expressions
with a discrete variable n:

   DF:EXPR(INT)->EXPR(INT):=e+->eval(e,[n],[n+1])-e

Then define the difference operator algebra D0:

   D0:=OREUP('D,EXPR(INT),morphism S,DF)

   u:=(operator 'u)[n]

   L:D0:='D+u

        D + u(n)

   L^2

         2                2
        D  + 2u(n)D + u(n)

_____________________________________________________________________

   )clear all

As a fourth example, we construct a skew polynomial ring by using an
inner derivation \delta induced by a fixed y in R:

   \delta(r) = yr - ry

First we should expose the constructor SquareMatrix so it is visible
in the interpreter:

   )set expose add constructor SquareMatrix

Define R to be the square matrix with integer entries:

   R:=SQMATRIX(2,INT)

   y:R:=matrix [[1,1],[0,1]]
        +1  1+
        |    |
        +0  1+

Define the inner derivative \delta:

   delta:R->R:=r+->y*r-r*y

Define S to be a skew polynomial determined by \sigma = 1
and \delta as an inner derivative:

   S:=OREUP('x,R,1,delta)

   x:S:='x

   a:S:=matrix [[2,3],[1,1]]
        +2  3+
        |    |
        +1  1+

   x^2*a
        +2  3+ 2   +2  - 2+    +0  - 2+
        |    |x  + |      |x + |      |
        +1  1+     +0  - 2+    +0   0 +


See Also:
o )show UnivariateSkewPolynomial
o )show UnivariateSkewPolynomialCategory
o )show SquareMatrix

