
% 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.


%%
%%  GBF
%%
%%   GroebnerFactorizationPackage
%%
%%  J. Grabmeier 26 04 91

Solving systems of polynomial equations with the
\texht{Gr\"{o}bner}{Groebner}
\index{Groebner basis@{Gr\protect\"{o}bner basis}}
basis algorithm can often be very time consuming because, in general,
\index{basis!Groebner@{Gr\protect\"{o}bner}}
the algorithm has exponential run-time.
These systems, which often come from concrete applications,
frequently have symmetries which are not taken advantage of by the
algorithm.
However, it often happens in this case
that the polynomials which occur during the
\texht{Gr\"{o}bner}{Groebner} calculations are reducible.
Since \Language{} has an excellent polynomial factorization algorithm, it is
very natural to combine the
\texht{Gr\"{o}bner}{Groebner} and factorization algorithms.

\spadtype{GroebnerFactorizationPackage} exports the
\spadfunFrom{groebnerFactorize}{GroebnerFactorizationPackage}
operation which implements a modified
\texht{Gr\"{o}bner}{Groebner} basis algorithm.
In this algorithm, each polynomial that is to be put into the
partial list of the basis is first factored.
The remaining calculation is split into as many parts as there are
irreducible factors.
Call these factors \texht{$p_1, \ldots,p_n.$}{\spad{p1, ..., pn.}}
In the branches corresponding to
\texht{$p_2,\ldots,p_n,$}{\spad{p2, ..., pn,}} the factor
\texht{$p_1$}{\spad{p1}} can be divided out, and so on.
This package also contains operations that allow you to specify the
polynomials that are not zero on the common roots of the final
\texht{Gr\"{o}bner}{Groebner} basis.

Here is an example from chemistry.
\index{chemistry}
In a theoretical model of the cyclohexan \texht{${\rm C}_6{\rm H}_{12}$}{C6H12},
the six carbon atoms each sit in the center of gravity of a
\index{cyclohexan}
tetrahedron that has two hydrogen atoms and two carbon atoms at its
corners.
We first normalize and set the length of each edge to 1.
Hence, the distances of one fixed carbon atom to each of its
immediate neighbours is 1.
We will denote the distances to the other three carbon atoms by
\smath{x}, \smath{y} and \smath{z}.

\texht{A.~Dress}{A. Dress} developed a theory to decide whether a set of points
%% reference?
and distances between them can be realized in an \smath{n}-dimensional space.
Here, of course, we have \smath{n = 3}.
\xtc{
}{
\spadcommand{mfzn : SQMATRIX(6,DMP([x,y,z],Fraction INT)) := [[0,1,1,1,1,1], [1,0,1,8/3,x,8/3], [1,1,0,1,8/3,y], [1,8/3,1,0,1,8/3], [1,x,8/3,1,0,1], [1,8/3,y,8/3,1,0]] \bound{mfzn}}
}
\xtc{
For the cyclohexan, the distances have to satisfy this equation.
}{
\spadcommand{eq := determinant mfzn \free{mfzn}\bound{eq}}
}
\xtc{
They also must satisfy the equations
given by cyclic shifts of the indeterminates.
}{
\spadcommand{groebnerFactorize [eq, eval(eq, [x,y,z], [y,z,x]), eval(eq, [x,y,z], [z,x,y])] \free{eq}}
}

The union of the solutions of this list is the
solution of our original problem.
If we impose positivity conditions, we get two relevant ideals.
One ideal is
zero-dimensional, namely \smath{x = y = z = 11/3}, and this
determines the ``boat'' form of the cyclohexan.
The other ideal is one-dimensional,
which means that we have a solution space given by one parameter.
This gives the ``chair'' form of the cyclohexan.
The parameter describes the angle of the ``back of the chair.''

\spadfunFrom{groebnerFactorize}{GroebnerFactorizationPackage}
has an optional \spadtype{Boolean}-valued second argument.
When it is \spad{true} partial results are displayed, since it may happen that the
calculation does not terminate in a reasonable time.
See the source code for \spadtype{GroebnerFactorizationPackage}
in {\bf groebf\spadFileExt{}} for more details about the algorithms
used.
