% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\XPBWPolynomialXmpTitle}{XPBWPolynomial}
\newcommand{\XPBWPolynomialXmpNumber}{9.92}
%
% =====================================================================
\begin{page}{XPBWPolynomialXmpPage}{9.92 XPBWPolynomial}
% =====================================================================
\beginscroll

%
%
%
%
%


Initialisations
\xtc{
}{
\spadpaste{a:Symbol := 'a \bound{a}}
}
\xtc{
}{
\spadpaste{b:Symbol := 'b \bound{b}}
}
\xtc{
}{
\spadpaste{RN    := Fraction(Integer) \bound{RN}}
}
\xtc{
}{
\spadpaste{word   := FreeMonoid Symbol \bound{word}}
}
\xtc{
}{
\spadpaste{lword := LyndonWord(Symbol) \bound{lword}}
}
\xtc{
}{
\spadpaste{base  := PoincareBirkhoffWittLyndonBasis Symbol \bound{base}}
}
\xtc{
}{
\spadpaste{dpoly := XDistributedPolynomial(Symbol, RN) \bound{dpoly} \free{RN}}
}
\xtc{
}{
\spadpaste{rpoly := XRecursivePolynomial(Symbol, RN) \bound{rpoly} \free{RN}}
}
\xtc{
}{
\spadpaste{lpoly := LiePolynomial(Symbol, RN) \bound{lpoly} \free{RN}}
}
\xtc{
}{
\spadpaste{poly  := XPBWPolynomial(Symbol, RN) \bound{poly} \free{RN}}
}
\xtc{
}{
\spadpaste{liste : List lword := LyndonWordsList([a,b], 6) \bound{liste} \free{lword a b }}
}

Let's make some polynomials
\xtc{
}{
\spadpaste{0\$poly \free{poly}}
}
\xtc{
}{
\spadpaste{1\$poly \free{poly}}
}
\xtc{
}{
\spadpaste{p : poly := a \free{a poly} \bound{p}}
}
\xtc{
}{
\spadpaste{q : poly := b \free{b poly} \bound{q}}
}
\xtc{
}{
\spadpaste{pq: poly := p*q \free{p q poly} \bound{pq}}
}
\xtc{
Coerce to distributed polynomial
}{
\spadpaste{pq :: dpoly \free{pq dpoly}}
}

Check some polynomial operations
\xtc{
}{
\spadpaste{mirror pq \free{pq}}
}
\xtc{
}{
\spadpaste{listOfTerms pq \free{pq}}
}
\xtc{
}{
\spadpaste{reductum pq \free{pq}}
}
\xtc{
}{
\spadpaste{leadingMonomial pq \free{pq}}
}
\xtc{
}{
\spadpaste{coefficients pq \free{pq}}
}
\xtc{
}{
\spadpaste{leadingTerm pq \free{pq}}
}
\xtc{
}{
\spadpaste{degree pq \free{pq}}
}
\xtc{
}{
\spadpaste{pq4:=exp(pq,4) \bound{pq4} \free{pq}}
}
\xtc{
}{
\spadpaste{log(pq4,4) - pq \free{pq4 pq} }
}

Calculations with verification in \spadtype{XDistributedPolynomial}.
\xtc{
}{
\spadpaste{lp1 :lpoly := LiePoly liste.10 \free{liste lpoly} \bound{lp1}}
}
\xtc{
}{
\spadpaste{lp2 :lpoly := LiePoly liste.11 \free{liste lpoly} \bound{lp2}}
}
\xtc{
}{
\spadpaste{lp  :lpoly := [lp1, lp2] \free{lp1 lp2 lpoly} \bound{lp}}
}
\xtc{
}{
\spadpaste{lpd1: dpoly := lp1 \free{lp1 dpoly} \bound{lpd1}}
}
\xtc{
}{
\spadpaste{lpd2: dpoly := lp2 \free{lp2 dpoly} \bound{lpd2}}
}
\xtc{
}{
\spadpaste{lpd : dpoly := lpd1 * lpd2 - lpd2 * lpd1 \free{dpoly lpd1 lpd2} \bound{lpd}}
}
\xtc{
}{
\spadpaste{lp :: dpoly - lpd \free{lpd dpoly lp}}
}

Calculations with verification in \spadtype{XRecursivePolynomial}.
\xtc{
}{
\spadpaste{p := 3 * lp \free{lp} \bound{pp}}
}
\xtc{
}{
\spadpaste{q := lp1 \free{lp1} \bound{qq}}
}
\xtc{
}{
\spadpaste{pq:= p * q \free{pp qq} \bound{pqpq}}
}
\xtc{
}{
\spadpaste{pr:rpoly := p :: rpoly \free{rpoly pp} \bound{pr}}
}
\xtc{
}{
\spadpaste{qr:rpoly := q :: rpoly \free{rpoly qq} \bound{qr}}
}
\xtc{
}{
\spadpaste{pq :: rpoly - pr*qr \free{pr qr rpoly pqpq} }
}
\endscroll
\autobuttons
\end{page}
%
