@node Introduction to algebraic extensions, Functions and Variables for algebraic extensions, Functions and Variables for Polynomials, Polynomials
@section Introduction to algebraic extensions

We assume here that the fields are of characteristic 0 so that
irreductible polynomials have simple roots (are separable, thus square
free). The base fields @math{K} of interest are the field @math{Q} of rational
numbers, for algebraic numbers, and the fields of rational functions on
the real numbers @math{R} or the complex numbers @math{C}, that is @math{R(t)} or @math{C(t)}, when
considering algebraic functions. An extension of degree @math{n} is defined by
an irreducible degree @math{n} polynomial @math{p(x)} with coefficients in the base
field, and consists of the quotient of the ring @math{K[x]} of polynomials by
the multiples of @math{p(x)}. So if @math{p(x) = x^n + p_0 x^{n - 1} + ... + p_n}, each time one
encounters @math{x^n} one substitutes @math{-(p_0 x^{n - 1} + ... + p_n)}. This is a field
because of Bezout's identity, and a vector space of dimension @math{n} over @math{K}
spanned by @math{1, x, ..., x^{n - 1}}.  When @math{K = C(t)}, this field can be identified
with the field of algebraic functions on the algebraic curve of equation
@math{p(x, t) = 0}.

In Maxima the process of taking rationals modulo @math{p} is obtained by the
function @code{tellrat} when @code{algebraic} is true. The best way to ensure,
in particular when considering the case where @math{p} depends on other
variables that this simplification property is attached to @math{x} is to write
(note the polynomial must be monic):
@code{tellrat(x^n = -(p_0*x^(n - 1) + ... + p_n))} where the @math{p_i} may depend on
other variables. When one wants to remove this tellrat property one then
has to write @code{untellrat(x)}.

In the field @math{K[x]} one may do all sorts of algebraic computations, taking
quotients, GCD of two elements, etc. by the same algorithms as in the
usual case.  In particular one can do factorization of polynomials on an
extension, using the function @code{algfac} below.  Moreover
multiplication by an element @math{f} is a linear operation of the vector space
@math{K[x]} over @math{K} and as such has a trace and a determinant. These are called
@code{algtrace} and @code{algnorm} below. One can see that the trace of
an element @math{f(x)} in @math{K[x]} is the sum of the values @math{f(a)} when @math{a} runs over
roots of @math{p} and the norm is the product of the @math{f(a)}. Both are symmetric
in the roots of @math{p} and thus belong to @math{K}.

The field @math{K[x]} is also called the field obtained by adjoining a root @math{a}
of @math{p(x)} to @math{K}. One can similarly adjoin a second root @math{b} of another
polynomial obtaining a new extension @math{K[a,b]}. In fact there is a ``prime
element'' @math{c} in @math{K[a, b]} such that @math{K[a, b] = K[c]}. This is obtained by
function @code{primeelmt} below. Recursively one can thus adjoin any
number of elements.  In particular adjoining all the roots of @math{p(x)} to @math{K}
one gets the splitting field of @math{p}, which is the smallest extension in
which @math{p} completely splits in linear functions. The function
@code{splitfield} constructs a primitive element of the splitting field,
which in general is of very high degree.

The relevant concepts are explained in a concise and self-contained way in the
small books edited by Dover:
``Algebraic theory of numbers,'' by Pierre Samuel,
``Algebraic curves,'' by  Robert Walker,
and the methods presented here are described in the article
``Algebraic factoring and rational function integration'' by B. Trager,
@emph{Proceedings of the 1976 AMS Symposium on Symbolic and Algebraic Computation}.

@node  Functions and Variables for algebraic extensions, , Introduction to algebraic extensions, Polynomials
@section  Functions and Variables for algebraic extensions

@anchor{algfac}
@deffn {Function} algfac (@var{f}, @var{p})

Returns the factorization of @var{f} in the field @math{K[a]}. Does the same
as @code{factor(@var{f}, @var{p})} which in fact calls @code{algfac}. One can also
specify the variable @var{a} as in @code{algfac(@var{f}, @var{p}, @var{a})}.

Examples:

@example
(%i1) algfac(x^4 + 1, a^2 - 2);
                           2              2
(%o1)                    (x  - a x + 1) (x  + a x + 1)
(%i2) algfac(x^4 - t*x^2 + 1, a^2 - t - 2, a);
                           2              2
(%o2)                    (x  - a x + 1) (x  + a x + 1)
@end example

In the second example note that @math{a = sqrt(2 + t)}.
@end deffn

@anchor{algnorm}
@deffn {Function} algnorm (@var{f}, @var{p}, @var{a})

Returns the norm of the polynomial @math{f(a)} in the extension
obtained by a root @var{a} of polynomial @var{p}. The coefficients of
@var{f} may depend on other variables.

Examples:

@example
(%i1) algnorm(x*a^2 + y*a + z,a^2 - 2, a);
                            2              2      2
(%o1)/R/                   z  + 4 x z - 2 y  + 4 x
@end example

The norm is also the resultant of polynomials @var{f} and @var{p}, and the product
of the differences of the roots of @var{f} and @var{p}.
@end deffn

@anchor{algtrace}
@deffn {Function} algtrace (@var{f}, @var{p}, @var{a})

Returns the trace of the polynomial @math{f(a)} in the extension
obtained by a root @var{a} of polynomial @var{p}. The coefficients of
@var{f} may depend on other variables which remain ``inert''.

Example:

@example
(%i1) algtrace(x*a^5 + y*a^3 + z + 1, a^2 + a + 1, a);
(%o1)/R/                       2 z + 2 y - x + 2
@end example
@end deffn

@anchor{bdiscr}
@deffn {Function} bdiscr (@var{args})

Computes the discriminant of a basis @math{x_i} in @math{K[a]} as
the determinant of the matrix of elements @math{trace(x_i*x_j)}.
The args are the elements of the basis followed by the minimal
polynomial.

Example:

@example
(%i1) bdiscr(1, x, x^2, x^3 - 2);
(%o1)/R/                             - 108
(%i2) poly_discriminant(x^3 - 2, x);
(%o2)                                - 108
@end example

A standard base in an extension of degree n is @math{1, x, ..., x^{n - 1}}.
In this case it is known that the discriminant of this base is the discriminant
of the minimal polynomial. This is checked in (%o2) above.

@end deffn


@anchor{primelmt}
@deffn {Function} primelmt (@var{f_b}, @var{p_a}, @var{c})

Computes a prime element for the extension of @math{K[a]} by a root
@var{b} of a polynomial @math{f_b(b)} whose coefficients may depend on
@var{a}. One assumes that @var{f_b} is square free. The function returns
an irreducible polynomial, a root of which generates @math{K[a, b]}, and
the expression of this primitive element in terms of @var{a} and
@var{b}.

Examples:

@example
(%i1) primelmt(b^2 - a*b - 1, a^2 - 2, c);
                              4       2
(%o1)                       [c  - 12 c  + 9, b + a]
(%i2) solve(b^2 - sqrt(2)*b - 1)[1];
                                  sqrt(6) - sqrt(2)
(%o2)                       b = - -----------------
                                          2
(%i3) primelmt(b^2 - 3, a^2 - 2, c);
                              4       2
(%o3)                       [c  - 10 c  + 1, b + a]
(%i4) factor(c^4 - 12*c^2 + 9, a^4 - 10*a^2 + 1);
                 3    2                       3    2
(%o4) ((4 c - 3 a  - a  + 27 a + 5) (4 c - 3 a  + a  + 27 a - 5)
                           3    2                       3    2
                 (4 c + 3 a  - a  - 27 a + 5) (4 c + 3 a  + a  - 27 a - 5))/256
(%i5) primelmt(b^3 - 3, a^2 - 2, c);
                   6      4      3       2
(%o5)            [c  - 6 c  - 6 c  + 12 c  - 36 c + 1, b + a]
(%i6) factor(b^3 - 3, %[1]);
            5       4        3        2
(%o6) ((48 c  + 27 c  - 320 c  - 468 c  + 124 c + 755 b - 1092)
           5        5         4       4          3        3          2        2
 ((- 48 b c ) - 54 c  - 27 b c  + 64 c  + 320 b c  + 360 c  + 468 b c  + 149 c
                           2
 - 124 b c - 1272 c + 755 b  + 1092 b + 1606))/570025
@end example

In (%o1), @var{f_b} depends on @code{a}. Using @code{solve}, the solution depends on sqrt(2) and sqrt(3).
In (%o3), @math{K[sqrt(2), sqrt(3)]} is computed, and we see that the the primitive polynomial
in (%o1) factorizes completely here. In (%i5), we compute @math{K[sqrt(2), 3^{1/3}]}, and we see
that @code{b^3 - 3} gets one factor in this extension. If we assume this extension is real,
the two other factors are complex.

@end deffn

@anchor{splitfield}
@deffn {Function} splitfield (@var{p}, @var{x})

Computes the splitting field of the polynomial @math{p(x)}.
In the generic case it is of degree @math{n!} in terms of the degree @math{n}
of @var{p}, but may be of lower order if the Galois group of @var{p}
is a strict subgroup of the group of permutations of @math{n}
elements. The function returns a primitive polynomial for this extension
and the expressions of the roots of @var{p} as polynomials of a root
of this primitive polynomial. The polynomial @var{f} may be
irreducible or factorizable.

Examples:

@example
(%i1) splitfield(x^3 + x + 1, x);
                                              4         2
              6         4         2       alg1  + 5 alg1  - 9 alg1 + 4
(%o1)/R/ [alg1  + 6 alg1  + 9 alg1  + 31, ----------------------------, 
                                                       18
                                 4         2          4         2
                             alg1  + 5 alg1  + 4  alg1  + 5 alg1  + 9 alg1 + 4
                           - -------------------, ----------------------------]
                                      9                        18
(%i2) splitfield(x^4 + 10*x^2 - 96*x - 71, x)[1];
             8           6           5            4             3
(%o2)/R/ alg2  + 148 alg2  - 576 alg2  + 9814 alg2  - 42624 alg2
                                                    2
                                       + 502260 alg2  + 1109952 alg2 + 18860337
@end example

In the first case we have the primitive polynomial of degree 6 and the 3 roots
of the third degree equations in terms of a variable @code{alg1} produced by
the system. In the second case the primitive polynomial is of degree 8
instead of 24, because the Galois group of the equation is reduced to D8
since there are relations between the roots.

@end deffn
