% Copyright The Numerical Algorithms Group Limited 1991.
% All rights reserved

% Polynomial page
% @(#)poly.ht   1.1 90/07/12 18:32:24
% added PolynomialNumberFieldFactorizationPage: 90/12/05 J. Grabmeier

\begin{page}{PolynomialPage}{Polynomials}
\beginscroll
\beginmenu
\menulink{Basic Functions}{PolynomialBasicPage} \tab{18}
Create and manipulate polynomials.
\menulink{Substitutions}{PolynomialSubstitutionPage} \tab{18}
Evaluate polynomials.
\menulink{Factorization}{ugProblemFactorPage} \tab{18}
Factor in different contexts.
\menulink{GCDs and Friends}{PolynomialGCDPage} \tab{18}
Greatest common divisors etc..
\menulink{Roots}{PolynomialRootPage}\tab{18}
Work with and solve for roots.
\menulink{Specific Types}{PolynomialTypesPage}\tab{18}
More specific information.
\endmenu
\endscroll
\autobuttons
\end{page}

\begin{page}{PolynomialTypesPage}{The Specific Polynomial Types}
\beginscroll
\beginmenu
\menulink{Polynomial}{PolynomialXmpPage} \newline
The general type.
\menulink{UnivariatePolynomial}{UnivariatePolynomialXmpPage} \newline
One variable polynomials.
\menulink{MultivariatePolynomial}{MultivariatePolynomialXmpPage} \newline
Multiple variable polynomials, recursive structure.
\menulink{DistributedMultivariatePolynomial}{DistributedMultivariatePolynomialXmpPage}
\newline
Multiple variable polynomials, non-recursive structure.
\endmenu
\endscroll
\autobuttons
\end{page}

\begin{page}{PolynomialBasicPage}{Basic Operations On Polynomials}

\beginscroll
You create
polynomials using the usual operations of \spadopFrom{+}{Polynomial},
\spadopFrom{-}{Polynomial}, \spadopFrom{*}{Polynomial}
(for multiplication), and \spadopFrom{^}{Polynomial} (for exponentiation).
Here are two examples: \newline
\spadpaste{p := a*x^2 + b*x*y + c*y^2 \bound{p}}
\spadpaste{q := 13*x^2 + 3*z \bound{q}}
These operations can also be used to combine polynomials.
Try the following:
\spadpaste{p + q \free{p q}}
\spadpaste{p - 3*q \free{p q}}
\spadpaste{p^2 + p*q \free{p q}}
\spadpaste{r := (p + q)^2 \bound{r} \free{p q}}
As you can see from the above examples, the variables are ordered
by defaults \spad{z > y > x > c > b > a},
that is, \spad{z} is the main variable, then
\spad{y} and so on in reverse alphabetical order.
You can redefine this
ordering (for display purposes only) with the \spadfun{setVariableOrder}
command.
For example, the following
makes \spad{a} the main variable, then \spad{b}, and so on:
\spadpaste{setVariableOrder [a,b,c,x,y,z] \bound{vord}}
Now compare the way polynomials are displayed:
\spadpaste{p \free{p vord}}
\spadpaste{q \free{q vord}}
\spadpaste{r \free{r vord}}
To return to the system's default ordering,
use \spadfun{resetVariableOrder}.
\spadpaste{resetVariableOrder() \bound{rvord}}
\spadpaste{p \free{p rvord}}
Polynomial coefficients can be pulled out
using the function \spadfun{coefficient}. \newline
For example:
\spadpaste{coefficient(q,x,2) \free{q}}
will give you the coefficient of \spad{x^2} in the polynomial \spad{q}.
\newline
Try these commands:
\spadpaste{coefficient(r,x,3) \free{r}}
\spadpaste{c := coefficient(r,z,1) \free{r} \bound{c}}
\spadpaste{coefficient(c,x,2) \free{c}}
Coefficients of monomials can be obtained as follows:
\spadpaste{coefficient(q^2, [x,z], [2,1]) \free{q}}
This will return the coefficient of x^2 * z in the polynomial q^2.
Also,
\spadpaste{coefficient(r, [x,y], [2,2]) \free{r}}
will return the coefficient of \spad{x^2 * y^2}
in the polynomial \spad{r(x,y)}.
\endscroll
\autobuttons
\end{page}

\begin{page}{PolynomialSubstitutionPage}{Polynomial Evaluation and Substitution}
\beginscroll
The function \spadfun{eval} is used to substitute values into polynomials.
Here's an example of how to use it:
\spadpaste{p := x^2 + y^2 \bound{p}}
\spadpaste{eval(p,x=5) \free{p}}
\newline
This example would give you the value of the polynomial \spad{p} at 5.
You can also substitute into polynomials with
several variables.  First, specify the polynomial, then give
a list of bindings of the form \spad{variable = value}. For example:
\spadpaste{eval(p,[x = a + b,y = c + d]) \free{p}}
Here \spad{x} was replaced by \spad{a + b},
and \spad{y} was replaced by \spad{c + d}.
Here's another example:
\spadpaste{q := x^3 + 5*x - y^4 \bound{q}}
\spadpaste{eval(q,[x=y,y=x]) \free{q}}
Substitution is done ``in parallel.''
That is, \Language{} takes
\spad{q(x,y)} and returns \spad{q(y,x)}.
\newline
You can also substitute numerical values for some or all of the
variables:
\spadpaste{px := eval(p, y = sin(2.0)) \bound{px} \free{p}}
\spadpaste{eval(px, x = cos(2.0)) \free{px}}
\endscroll
\autobuttons
\end{page}

\begin{page}{PolynomialGCDPage}{Greatest Common Divisors, Resultants, and Discriminants}
\beginscroll
You can compute the greatest common divisor of two polynomials using the
function \spadfun{gcd}.
Here's an example:
\spadpaste{p := 3*x^8 + 2*x^7 + 6*x^2 + 7*x + 2 \bound{p}}
\spadpaste{q := 2*x^13 + 9*x^7 + 2*x^6 + 10*x + 5 \bound{q}}
\spadpaste{gcd(p,q) \free{p q}}
You could
also see that \spad{p} and \spad{q} have a factor in common by using the
function \spadfun{resultant}:
\spadpaste{resultant(p,q,x) \free{p q}}
The resultant of two polynomials vanishes precisely when they have a
factor in common.
(In the example above
we specified the variable with
which we wanted to compute the resultant because the
polynomials could have involved variables other than x.)
Discriminant:
\spadpaste{discriminant(p, x) \free{p}}
\endscroll
\autobuttons
\end{page}

\begin{page}{PolynomialRootPage}{Roots of Polynomials}
\beginscroll
\beginmenu
\menulink{Using a Single Root of a Polynomial}{ugxProblemSymRootOnePage}
\newline
Working with a single root of a polynomial.
\menulink{Using All Roots of a Polynomial}{ugxProblemSymRootAllPage}
\newline
Working with all the roots of a polynomial.
\menulink{Solution of a Single Polynomial Equation}{ugxProblemOnePolPage}
\newline
Finding the roots of one polynomial.
\menulink{Solution of Systems of Polynomial Equations}{ugxProblemPolSysPage}
\newline
Finding the roots of a system of polynomials.
\endmenu
\endscroll
\autobuttons
\end{page}
