
% Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
%     - Redistributions of source code must retain the above copyright
%       notice, this list of conditions and the following disclaimer.
%
%     - Redistributions in binary form must reproduce the above copyright
%       notice, this list of conditions and the following disclaimer in
%       the documentation and/or other materials provided with the
%       distribution.
%
%     - Neither the name of The Numerical ALgorithms Group Ltd. nor the
%       names of its contributors may be used to endorse or promote products
%       derived from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
% TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
% OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES-- LOSS OF USE, DATA, OR
% PROFITS-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.



The domain constructor \spadtype{MultivariatePolynomial} is similar to
\spadtype{Polynomial} except that it specifies the variables to be used.
\index{polynomial!multiple variables} Most functions available for
\spadtype{Polynomial} are available for \spadtype{MultivariatePolynomial}.
The abbreviation for \spadtype{MultivariatePolynomial} is
\spadtype{MPOLY}.
The type expressions
\begin{texonly}
\begin{center}
\spadtype{MultivariatePolynomial([x,y],Integer)} \quad and \quad \spadtype{MPOLY([x,y],INT)}
\end{center}
\end{texonly}
\htonly
\begin{center}
\spadtype{MultivariatePolynomial([x,y],Integer)}
\end{center}
and
\begin{center}
\spadtype{MPOLY([x,y],INT)}
\end{center}
\endhtonly
refer to the domain of multivariate polynomials in the variables
\spad{x} and \spad{y} where the coefficients are restricted to be integers.
The first
variable specified is the main variable and the display of the
polynomial reflects this.
\xtc{
This polynomial appears with
terms in descending powers of the variable \spad{x}.
}{
\spadcommand{m : MPOLY([x,y],INT) := (x^2 - x*y^3 +3*y)^2 \bound{m}}
}
\xtc{
It is easy to see a different variable ordering by doing a conversion.
}{
\spadcommand{m :: MPOLY([y,x],INT) \free{m}}
}
\xtc{
You can use other, unspecified variables, by using
\spadtype{Polynomial} in the coefficient type of \spadtype{MPOLY}.
}{
\spadcommand{p : MPOLY([x,y],POLY INT) \bound{pdec}}
}
\xtc{
}{
\spadcommand{p := (a^2*x - b*y^2 + 1)^2 \free{pdec}\bound{p}}
}
\xtc{
Conversions can be used to re-express such polynomials in terms of
the other variables.  For example, you can first push all the
variables into a polynomial with integer coefficients.
}{
\spadcommand{p :: POLY INT \free{p}\bound{prev}}
}
\xtc{
Now pull out the variables of interest.
}{
\spadcommand{\% :: MPOLY([a,b],POLY INT) \free{prev}}
}

\beginImportant
\noindent {\bf Restriction:}
\texht{\begin{quotation}\noindent}{\newline\indent{5}}
\Language{} does not allow you to create types where
\spadtype{MultivariatePolynomial} is contained in the coefficient type of
\spadtype{Polynomial}. Therefore,
\spad{MPOLY([x,y],POLY INT)} is legal but
\spad{POLY MPOLY([x,y],INT)} is not.
\texht{\end{quotation}}{\indent{0}}
\endImportant

\xtc{
Multivariate polynomials may be combined with univariate polynomials
to create types with special structures.
}{
\spadcommand{q : UP(x, FRAC MPOLY([y,z],INT)) \bound{qdec}}
}
\xtc{
This is a polynomial in \spad{x} whose coefficients are
quotients of polynomials in \spad{y} and \spad{z}.
}{
\spadcommand{q := (x^2 - x*(z+1)/y +2)^2 \free{qdec}\bound{q}}
}
\xtc{
Use conversions for structural rearrangements.
\spad{z} does not appear in a denominator and so it can be made
the main variable.
}{
\spadcommand{q :: UP(z, FRAC MPOLY([x,y],INT)) \free{q}}
}
\xtc{
Or you can make a multivariate polynomial in \spad{x} and \spad{z}
whose coefficients are fractions in polynomials in \spad{y}.
}{
\spadcommand{q :: MPOLY([x,z], FRAC UP(y,INT)) \free{q}}
}
A conversion like \spad{q :: MPOLY([x,y], FRAC UP(z,INT))} is not
possible in this example
because \spad{y} appears in the denominator of a fraction.
As you can see, \Language{} provides extraordinary flexibility in the
manipulation and display of expressions via its conversion facility.

For more information on related topics, see
\xmpref{Polynomial},
\xmpref{UnivariatePolynomial}, and
\xmpref{DistributedMultivariatePolynomial}.
\showBlurb{MultivariatePolynomial}
