====================================================================
XPolynomial examples
====================================================================

The XPolynomial domain constructor implements multivariate polynomials
whose set of variables is Symbol.  These variables do not commute.
The only parameter of this construtor is the coefficient ring which
may be non-commutative.  However, coefficients and variables commute.
The representation of the polynomials is recursive.  The abbreviation
for XPolynomial is XPOLY.

Other constructors like XPolynomialRing, XRecursivePolynomial as well 
as XDistributedPolynomial, LiePolynomial and XPBWPolynomial implement 
multivariate polynomials in non-commutative variables.

We illustrate now some of the facilities of the XPOLY domain constructor.

Define a polynomial ring over the integers.

  poly := XPolynomial(Integer)
    XPolynomial Integer
                                 Type: Domain

Define a first polynomial,

  pr: poly := 2*x + 3*y-5 
    - 5 + x 2 + y 3
                                 Type: XPolynomial Integer

and a second one.

  pr2: poly := pr*pr
    25 + x(- 20 + x 4 + y 6) + y(- 30 + x 6 + y 9)
                                 Type: XPolynomial Integer

Rewrite pr in a distributive way,

  pd  := expand pr
    - 5 + 2x + 3y
                                 Type: XDistributedPolynomial(Symbol,Integer)

compute its square,

  pd2 := pd*pd
                       2                   2
    25 - 20x - 30y + 4x  + 6x y + 6y x + 9y
                                 Type: XDistributedPolynomial(Symbol,Integer)

and checks that:

  expand(pr2) - pd2
    0
                                 Type: XDistributedPolynomial(Symbol,Integer)

We define:

  qr :=  pr**3
     - 125 + x(150 + x(- 60 + x 8 + y 12) + y(- 90 + x 12 + y 18))
   + 
     y(225 + x(- 90 + x 12 + y 18) + y(- 135 + x 18 + y 27))
                                 Type: XPolynomial Integer

and:

  qd :=  pd**3
                              2                       2     3      2
     - 125 + 150x + 225y - 60x  - 90x y - 90y x - 135y  + 8x  + 12x y + 12x y x
   + 
          2        2                2       3
     18x y  + 12y x  + 18y x y + 18y x + 27y
                                 Type: XDistributedPolynomial(Symbol,Integer)

We truncate qd at degree 3.

  trunc(qd,2)
                             2                       2
    - 125 + 150x + 225y - 60x  - 90x y - 90y x - 135y
                                 Type: XDistributedPolynomial(Symbol,Integer)

The same for qr:

  trunc(qr,2)
    - 125 + x(150 + x(- 60) + y(- 90)) + y(225 + x(- 90) + y(- 135))
                                 Type: XPolynomial Integer

We define:

  Word := OrderedFreeMonoid Symbol
    OrderedFreeMonoid Symbol
                                 Type: Domain

and:

  w: Word := x*y**2
       2
    x y
                                 Type: OrderedFreeMonoid Symbol

We can compute the right-quotient of qr by r:

  rquo(qr,w)
    18
                                 Type: XPolynomial Integer

and the shuffle-product of pr by r:

  sh(pr,w::poly)
    x(x y y 4 + y(x y 2 + y(- 5 + x 2 + y 9))) + y x y y 3
                                 Type: XPolynomial Integer

See Also:
o )help XPBWPolynomial
o )help LiePolynomial
o )help XDistributedPolynomial
o )help XRecursivePolynomial
o )help XPolynomialRing
o )show XPolynomial

