%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%W  radiroot.tex          Radiroot documentation          Andreas Distler
%%
%H  $Id: radiroot.tex,v 1.3 2006/11/24 15:03:50 gap Exp $
%%
%Y  2005
%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Functionality of the Package}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This chapter describes the methods available in the {\Radiroot}
package.
 
\Section{Methods for Rational Polynomials}

\> IsSeparablePolynomial( <f> )

returns `true' if the rational polynomial <f> has simple roots only
and `false' otherwise.

\> IsSolvable( <f> )
\> IsSolvablePolynomial( <f> )

returns `true' if the rational polynomial <f> has a solvable Galois group and
`false' otherwise. It signals an error if there exists an irreducible factor
with degree greater than 15.

For a rational polynomial <f>
\> SplittingField( <f> )

For a rational polynomial <f>, the smallest algebraic extension of the
rationals containing all roots of <f> is returned. The field is
constructed with `FieldByPolynomial' (see Creation of number fields in
\Alnuth).

A matrix field isomorphic to the splitting field will be known after
the computation and can be accessed using the attribute
`IsomorphicMatrixField'.
\beginexample
gap> x := Indeterminate( Rationals, "x" );;
gap> f := UnivariatePolynomial( Rationals, [1,3,4,1] );
x^3+4*x^2+3*x+1
gap> L := SplittingField( f );
<algebraic extension over the Rationals of degree 6>
gap> IsomorphicMatrixField( L );
<rational matrix field of degree 6>
gap> y := Indeterminate( L, "y" );;
gap> g := AlgExtEmbeddedPol( L, x^3+4*x^2+3*x+1 );
y^3+!4*y^2+!3*y+!1
gap> Factors( g );
[ y+((-168/47-535/94*a-253/94*a^2-24/47*a^3-3/94*a^4)),
  y+((336/47+488/47*a+253/47*a^2+48/47*a^3+3/47*a^4)),
  y+((20/47-441/94*a-253/94*a^2-24/47*a^3-3/94*a^4)) ]
gap> FactorsPolynomialAlgExt( L, f );
[ y+((-168/47-535/94*a-253/94*a^2-24/47*a^3-3/94*a^4)),
  y+((20/47-441/94*a-253/94*a^2-24/47*a^3-3/94*a^4)),
  y+((336/47+488/47*a+253/47*a^2+48/47*a^3+3/47*a^4)) ]
\endexample
To factorise a polynomial over its splitting field  one has to embed the
polynomial first, as seen in the example, or use `FactorsPolynomialAlgExt' (see
\Alnuth) instead of `Factors'. The primitive element of the splitting field is
denoted by `a'.

\> IsomorphismMatrixField( <F> )

returns a bijective mapping from the number field <F> to an isomorphic
matrix field.
 
\> RootsAsMatrices( <f> )

gives a list of matrices - one for every distinct root of <f> - whose minimal
polynomial is <f>. The field generated by these matrices is a
splitting field of <f>. Using `IsomorphismMatrixField' one can map the
matrices to the roots of <f> in `SplittingField( <f> )'.

\beginexample
gap> Display(RootsAsMatrices(f)[1]);
[ [   0,   1,   0,   0,   0,   0 ],
  [   0,   0,   1,   0,   0,   0 ],
  [  -1,  -3,  -4,   0,   0,   0 ],
  [   0,   0,   0,   0,   1,   0 ],
  [   0,   0,   0,   0,   0,   1 ],
  [   0,   0,   0,  -1,  -3,  -4 ] ]
gap> MinimalPolynomial( Rationals, RootsAsMatrices(f)[1]);
x^3+4*x^2+3*x+1
gap> FieldByMatrices( RootsAsMatrices(f));
<rational matrix field of degree 6>
gap> iso := IsomorphismMatrixField( L );
MappingByFunction( <algebraic extension over the Rationals of degree
6>, <rational matrix field of degree
6>, function( x ) ... end, function( mat ) ... end )
gap> PreImages( iso, RootsAsMatrices( f ) );
[ (-336/47-488/47*a-253/47*a^2-48/47*a^3-3/47*a^4),
  (-20/47+441/94*a+253/94*a^2+24/47*a^3+3/94*a^4),
  (168/47+535/94*a+253/94*a^2+24/47*a^3+3/94*a^4) ]
\endexample

\> GaloisGroupOnRoots( <f> )

calculates the Galois group <G> of the rational polynomial <f>, which
has to be separable, as a permutation group with respect to the
ordering of the roots of <f> given as matrices in `RootsAsMatrices'.

\beginexample
gap> GaloisGroupOnRoots(f);
Group([ (2,3), (1,2) ])
\endexample

If you only want to get the Galois group itself it is often better to use
the function `GaloisType' (see Chapter~"ref:Polynomials over the Rationals" in
the {\GAP} reference manual).


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Solving a Polynomial by Radicals}

\> RootsOfPolynomialAsRadicals( <f> [, <mode> [, <file> ] ] )

computes a solution by radicals for the irreducible, rational polynomial <f>
up to degree 15 if this is possible. That is if the Galois group of <f> is
solvable, and returns `fail' otherwise. If it succeeds the function
returns the name of the file, containing the computed information.

The user has several options to specify what happens with the results
of the computation. Therefore the optional second argument <mode>, a
string, can be set to one of the following values:

\beginexample
"dvi"
\endexample
To use this option latex and the dvi-viewer xdvi have to be
available. It will cause the irreducible radical expression to appear in a new
window. The package uses this option as the default.

\beginexample
"latex"
\endexample
A LaTeX file is generated, which contains the encoding for the
expression by radicals. This gives the user the opportunity to adjust
the layout of the individual example before displaying the expression.

\beginexample
"maple"
\endexample
Generates a file containing the roots of <f> that can be read into
Maple \cite{Maple10}.

\beginexample
"off"
\endexample
In this mode the function does not actually compute a radical
expression but is only called for its side effects. Namely, the
attributes `SplittingField', `RootsAsMatrices' and
`GaloisGroupOnRoots' are known for <f> afterwards. This is slightly
more effective than calling the corresponding operations one-by-one.

With the optional third argument <file> the user can specify a
file name under which the created file will be stored in the current
directory. Depending on the option for <mode> an extension like <.tex>
might be added automatically.

%Note that it is not possible to have <file> as the second argument.

The computation may take a very long time and can get unfeasible if the
degree of <f> is greater than 7.
\beginexample
\endexample

\> RootsOfPolynomialAsRadicalsNC( <f> [, <mode> [, <file> ] ] )

has the advantage that it can be used for polynomials with arbitrary
degree. It does essentially the same as `RootsOfPolynomialAsRadicals' except
that it runs no test on the input before starting the actual
computation. In particular, it may run for a very long time until a
non-solvable polynomial is recognized as such.

Detailed examples for these two functions can be found in the next section.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Examples}

The function `RootsOfPolynomialAsRadicals' does not generate output
inside \GAP. Depending on the chosen mode, various kinds
of files can be created. As an example the polynomial from the
introduction will be considered.

\beginexample
gap> g := UnivariatePolynomial( Rationals, [1,1,-1,-1,1] );
x^4-x^3-x^2+x+1
gap> RootsOfPolynomialAsRadicals(g);
"/tmp/tmp.8zkw5B/Nst.tex"
\endexample

will cause a dvi file to appear in a new window:

An expression by radicals for the roots of the polynomial
$x^{4}-x^{3}-x^{2} + x + 1$ with the $n$-th root of unity $\zeta_n$ and

$\omega_1 = \sqrt{ - 3}$,

$\omega_2 = \sqrt{\frac{7}{2} - \frac{1}{2}\omega_1}$,

$\omega_3 = \sqrt{\frac{7}{2} + \frac{1}{2}\omega_1}$,

is:

$\frac{1}{4} - \frac{1}{4}\omega_1 + \frac{1}{2}\omega_2$

If one wants to work with the roots, it might be helpful to use Maple
\cite{Maple10}, in which an expression like $2^{(1/2)}$ is valid.

\beginexample
gap> RootsOfPolynomialAsRadicals(g, "maple");
"/tmp/tmp.k9aTCz/Nst"
\endexample

will create a file with the following content:

\beginexample
w1 := (-3)^(1/2);
w2 := ((7/2) + (-1/2)*w1)^(1/2);
w3 := ((7/2) + (1/2)*w1)^(1/2);

a := (1/4) + (1/4)*w1 + (1/2)*w3;
\endexample

After those computations several attributes are known for the
polynomial in \GAP. 

\beginexample
gap> RootsOfPolynomialAsRadicalsNC( g, "off" );
gap> time;
0
gap> SplittingField( g );
<algebraic extension over the Rationals of degree 8>
gap> time;
0
gap> GaloisGroupOnRoots( g );
Group([ (2,4), (1,2)(3,4) ])
gap> time;
0
\endexample

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%E





