Ch7-FactoringExamples.mws

Factoring polynomials over extensions of the Rationals
Explanation by examples

İMike May, S.J., maymk@slu.edu, Saint Louis University .

>    restart;

In this worksheet, we will use examples to explore factorization of polynomials over extensions of the rationals.

  

The basic factor command

We start by looking at the factor command.  The simplest version of the command factors a polynomial over the rationals.

>    factor(x^4 - 5*x^2 + 6);

(x^2-2)*(x^2-3)

>    factor(x^6 + x^5 + x^4 + x^3 + x^2 + x + 1);

x^6+x^5+x^4+x^3+x^2+x+1

This form of the command will also factor polynomials in several variables.

>    factor(x^2-y^4);

(x-y^2)*(x+y^2)

>   

In working with field theory, we often want to factor polynomials over an extension field of the rationals.  Maple lets you specify the extension by specifying a list of radicals that the field must contain or by specifying a list of roots of irreducible polynomials that must have an irreducible factor in the field

Extensions defined by ajoining radicals

The first extension fields we work with are obtained by ajoining squarte roots and cube roots to the rationals.  It should be noted that a square root can be indicated in Maple with the sqrt command, or as a fractional power, or with the root or surd command.

>    factor(x^2-3);
factor(x^2-3, sqrt(3));
factor(x^2-3, 3^(1/2));
factor(x^2-3, root(3,2));
factor(x^2-3, surd(3,2));

x^2-3

-(x+3^(1/2))*(-x+3^(1/2))

-(x+3^(1/2))*(-x+3^(1/2))

-(x+3^(1/2))*(-x+3^(1/2))

-(x+3^(1/2))*(-x+3^(1/2))

With the obvious modification, the last three methods can be used to designate other roots.

>    factor(x^3-2);
factor(x^3-2,(2)^(1/3));
factor(x^3-2,root(2,3));
factor(x^3-2,surd(2,3));

x^3-2

-(x^2+x*2^(1/3)+2^(2/3))*(-x+2^(1/3))

-(x^2+x*2^(1/3)+2^(2/3))*(-x+2^(1/3))

-(x^2+x*2^(1/3)+2^(2/3))*(-x+2^(1/3))

It should be noted that Maple understands I to be the square root of -1;

>    factor(x^4+1);
factor(x^4 + 1, I);
factor(x^4 + 1, (-1)^(1/2));
factor(x^4 + 1, sqrt(-1));
factor(x^4 + 1, root(-1,2));

x^4+1

-(-x^2+I)*(x^2+I)

-(-x^2+I)*(x^2+I)

-(-x^2+I)*(x^2+I)

-(-x^2+I)*(x^2+I)

It should be noted that square roots of other negative numbers need to be handled with care.  In particular the sqrt and root commands cannot be used since Maple treats such square roots as a term that needs to be simplified. Therefore, trying any of the following will generate errors.

>    factor(x^2 +2, sqrt(-2));
factor(x^2 +2, root(-2,2));
factor(x^2 +2, surd(-2,2));
factor(x^2 +2, (-2)^(1/2));

Error, (in factor) 2nd argument, I*2^(1/2), is not a valid algebraic extension

Error, (in factor) 2nd argument, I*2^(1/2), is not a valid algebraic extension

Error, (in factor) 2nd argument, I*2^(1/2), is not a valid algebraic extension

-(-x+(-2)^(1/2))*(x+(-2)^(1/2))

Finally, it is worth noting that Maple will let you add a list of radicals in  defining an extension field.

>    factor(x^4 - 5*x^2 + 6);
factor(x^4 - 5*x^2 + 6, {sqrt(2), sqrt(3)});
factor(x^4 - 5*x^2 + 6, [sqrt(2), sqrt(3)]);
factor(x^4 - 5*x^2 + 6, [sqrt(2), sqrt(6)]);
factor(x^2 - 6, [sqrt(2), sqrt(3)]);
factor(x^2 - 6, [sqrt(2), sqrt(3), sqrt(6)]);

(x^2-2)*(x^2-3)

(x+3^(1/2))*(-x+3^(1/2))*(x+2^(1/2))*(-x+2^(1/2))

(x+3^(1/2))*(-x+3^(1/2))*(x+2^(1/2))*(-x+2^(1/2))

(x+3^(1/2))*(-x+3^(1/2))*(x+2^(1/2))*(-x+2^(1/2))

-(-x+3^(1/2)*2^(1/2))*(x+3^(1/2)*2^(1/2))

-(-x+3^(1/2)*2^(1/2))*(x+3^(1/2)*2^(1/2))

>   

Extensions defined by ajoining roots of polynomials

The other way to define an extension is to adjoin roots of specified polynomials with the RootOf command.  From above, the square root of -3 is RootOf(x^2+3).  The advantage of the RootOf command is that it gives a wider set of elements to add to an extension field.

Consider now the cubic equation  x^3 -1.  Since 1 is a cube root of unity, this factors as a linear times a quadratic over the rationals.

>    factor(x^3-1);

(x-1)*(x^2+x+1)

Since the solutions of the quadratic factor are   alpha = (-1+sqrt(-3))/2  and    beta = (-1-sqrt(-3))/2 ,  it is straightforward that the quadratic factors over the extension field generated by   sqrt(-3) .

>    factor(x^3-1,(-3)^(1/2));

-1/4*(2*x+1+(-3)^(1/2))*(-2*x-1+(-3)^(1/2))*(x-1)

We would prefer to factor this expression over the field obtained by adjoining either alpha  or beta , one of the roots of the quadratic obtained by factoring x^3-1 .  Notice that Maple will complain if we try to add the expression    (-1+sqrt(-3))/2 .   Once again the solution is to use the RootOf construction.

>    factor(x^3 - 1, (-1 + sqrt(-3))/2);
factor(x^3 - 1, RootOf(x^2 + x + 1));

Error, (in factor) 2nd argument, -1/2+1/2*I*3^(1/2), is not a valid algebraic extension

-(x+1+RootOf(_Z^2+_Z+1))*(-x+RootOf(_Z^2+_Z+1))*(x-1)

As with radicals, we can add in a list of RootOf expressions to the field we are factoring over.

>    factor(x^12 - 1);
factor(x^12 - 1, RootOf(x^2 + 1));
factor(x^12 - 1, RootOf(x^2 + x + 1));
factor(x^12 - 1, {RootOf(x^2 + x + 1), RootOf(x^2 + 1)});

(x-1)*(x+1)*(x^2+x+1)*(x^2-x+1)*(x^2+1)*(x^4-x^2+1)

(x^2-x+1)*(x^2+x*RootOf(_Z^2+1)-1)*(-x^2+x*RootOf(_Z^2+1)+1)*(x^2+x+1)*(x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+1))*(x+1)*(x-1)

-(x^2+1)*(x^2+RootOf(_Z^2+_Z+1))*(-x^2+1+RootOf(_Z^2+_Z+1))*(x+RootOf(_Z^2+_Z+1))*(-x+1+RootOf(_Z^2+_Z+1))*(x+1+RootOf(_Z^2+_Z+1))*(-x+RootOf(_Z^2+_Z+1))*(x+1)*(x-1)
-(x^2+1)*(x^2+RootOf(_Z^2+_Z+1))*(-x^2+1+RootOf(_Z^2+_Z+1))*(x+RootOf(_Z^2+_Z+1))*(-x+1+RootOf(_Z^2+_Z+1))*(x+1+RootOf(_Z^2+_Z+1))*(-x+RootOf(_Z^2+_Z+1))*(x+1)*(x-1)

-(x+RootOf(_Z^2+_Z+1))*(-x+1+RootOf(_Z^2+_Z+1))*(x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+1)+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+_Z+1)*Roo...
-(x+RootOf(_Z^2+_Z+1))*(-x+1+RootOf(_Z^2+_Z+1))*(x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+1)+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+_Z+1)*Roo...
-(x+RootOf(_Z^2+_Z+1))*(-x+1+RootOf(_Z^2+_Z+1))*(x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+1))*(-x+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+1)+RootOf(_Z^2+_Z+1)*RootOf(_Z^2+1))*(x+RootOf(_Z^2+_Z+1)*Roo...

It is worth noting that Maple didn't tell us which root of the polynomial was being chosen for the RootOf construction.  You will recall that algebraically, the roots of an irreducible polynomial are indistinguishable.  Given any two roots of an irreducible polynomial, there is an isomorphism of the splitting field taking the first root to the second.   If we use RootOf on a reducible equation, Maple will complain when we try to use the root in factoring .

>    factor(x^4 - 5*x^2 + 6);
beta := RootOf(x^4 - 5*x^2 + 6);
factor(x^4 - 5*x^2 + 6, beta);

(x^2-2)*(x^2-3)

beta := RootOf(_Z^4-5*_Z^2+6)

Error, (in evala) reducible RootOf detected.  Substitutions are {RootOf(_Z^4-5*_Z^2+6) = RootOf(_Z^2-2), RootOf(_Z^4-5*_Z^2+6) = RootOf(_Z^2-3)}

Aliases - getting pretty output

Notice that all of the RootOf(...) stuff looks ugly.  Maple lets us rename an expression with the alias command.  This is different from an assign statement.  Where "x:=y" can be understood as asigning the value "y" to the variable "x", the statement "alias(x=y)" makes "x" an abreviation for the expression "y".  The output of the alias command is a list of currently aliases.

>    alias(omega = RootOf(x^2 + x + 1));
factor(x^3-1, omega);

omega

-(x+1+omega)*(-x+omega)*(x-1)

We can use the same technique for other primative roots of unity.

>    alias (zeta[4]=RootOf(x^2+ 1));

omega, zeta[4]

>    alias (zeta[6]=RootOf(x^2 - x + 1),
      zeta[12]=RootOf(x^4 - x^2 +1));

omega, zeta[4], zeta[6], zeta[12]

>    factor(x^12 - 1, zeta[12]);

-(x-1+zeta[12]^2)*(-x+zeta[12]^2)*(-x+zeta[12]^3)*(x+zeta[12]^3)*(-x-zeta[12]+zeta[12]^3)*(-x+zeta[12])*(x+zeta[12])*(x-zeta[12]+zeta[12]^3)*(x+zeta[12]^2)*(-x-1+zeta[12]^2)*(x+1)*(x-1)

This lets us see how a polynomial factors in different extension fields

>    factor(x^12 - 1);
factor(x^12 - 1, omega);
factor(x^12 - 1, zeta[4]);
factor(x^12 - 1, zeta[6]);
factor(x^12 - 1, {omega, zeta[4]});
factor(x^12 - 1, zeta[12]);

(x-1)*(x+1)*(x^2+x+1)*(x^2-x+1)*(x^2+1)*(x^4-x^2+1)

-(x^2+1)*(x^2+omega)*(-x^2+1+omega)*(x+omega)*(-x+1+omega)*(x+1+omega)*(-x+omega)*(x+1)*(x-1)

(x^2-x+1)*(x^2+x*zeta[4]-1)*(-x^2+x*zeta[4]+1)*(x^2+x+1)*(x+zeta[4])*(-x+zeta[4])*(x+1)*(x-1)

-(x^2+1)*(-x^2+zeta[6])*(x^2-1+zeta[6])*(x-1+zeta[6])*(-x+zeta[6])*(-x-1+zeta[6])*(x+zeta[6])*(x+1)*(x-1)

-(x+omega)*(-x+1+omega)*(x+zeta[4])*(-x+zeta[4])*(-x+omega*zeta[4])*(x+zeta[4]+omega*zeta[4])*(x+omega*zeta[4])*(-x+zeta[4]+omega*zeta[4])*(x+1+omega)*(-x+omega)*(x+1)*(x-1)

-(x-1+zeta[12]^2)*(-x+zeta[12]^2)*(-x+zeta[12]^3)*(x+zeta[12]^3)*(-x-zeta[12]+zeta[12]^3)*(-x+zeta[12])*(x+zeta[12])*(x-zeta[12]+zeta[12]^3)*(x+zeta[12]^2)*(-x-1+zeta[12]^2)*(x+1)*(x-1)

>   

A caution on mixing methods

It is worth noting that while we can add a list of radicals or a list of RootOf expressions, Maple will complain if we try to mix the methods

>    factor(x^4-6);
factor(x^4-6, {sqrt(2), sqrt(3)});
factor(x^4-6, {RootOf(x^2-2), RootOf(x^2-3)});
factor(x^4-6, {RootOf(x^2-2), sqrt(3)});

x^4-6

-(x^2+3^(1/2)*2^(1/2))*(-x^2+3^(1/2)*2^(1/2))

-(x^2+RootOf(_Z^2-2)*RootOf(_Z^2-3))*(-x^2+RootOf(_Z^2-2)*RootOf(_Z^2-3))

Error, (in factor) 2nd argument, {3^(1/2), RootOf(_Z^2-2)}, is not a valid algebraic extension

In particular, recall that I is understood as a radical.

>    factor(x^4-4);
factor(x^4-4, {sqrt(2), I});
factor(x^4-4, {RootOf(x^2-2), I});

(x^2-2)*(x^2+2)

(-x+2^(1/2)*I)*(x+2^(1/2)*I)*(x+2^(1/2))*(-x+2^(1/2))

Error, (in factor) 2nd argument, {RootOf(_Z^2-2), I}, is not a valid algebraic extension

>   

Splitting polynomials with the split command

If one approach is to see how a polynomial factors in a specified extension of the rationals, the other obvious approach is to ask how a polynomial splits in some extension of the rationals.  That is done with the split command from the polytools package.  The command only allows polynomials in one variable, which must be specified.)

>    polytools[split](x^4 + x^2 - 6, x);

(x-RootOf(_Z^2+3))*(x+RootOf(_Z^2+3))*(x+RootOf(_Z^2-2))*(x-RootOf(_Z^2-2))

This command also allows you to give as a third input parameter, a name which will be used to store the extension needed to split the polynomials.  The extension field can be used by the factor command.  This lets you determine how one polynomial factors in the splitting field of another polynomial.

>    polytools[split](x^4 + x^2 - 6, x, 'ExtField');
print(ExtField);

(x-RootOf(_Z^2+3))*(x+RootOf(_Z^2+3))*(x+RootOf(_Z^2-2))*(x-RootOf(_Z^2-2))

{RootOf(_Z^2+3), RootOf(_Z^2-2)}

>    factor(x^4 + 3*x^2 -10);
factor(x^4 + 3*x^2 -10, ExtField);

(x^2-2)*(x^2+5)

-(x^2+5)*(x+RootOf(_Z^2-2))*(-x+RootOf(_Z^2-2))

>   

Factoring polynomials over the reals and the complexes

Everything we have been discussing so far looks at finding exact factors over an algebraic extension of the rationals.  For completeness it is worth noting that Maple also allows you to specify that you want to factor over either the reals or the complexes.  Such a choice obviously leads to floating point approximations.

>    factor(x^9 + x + 3);
factor(x^9 + x + 3, real);
factor(x^9 + x + 3, complex);

x^9+x+3

(x+1.075454452)*(x^2+1.722667875*x+1.196570376)*(x^2+.4854779152*x+1.273610457)*(x^2-1.093342188*x+1.336619504)*(x^2-2.190258054*x+1.369451249)

(x+1.075454452)*(x+.8613339373+.6742953540*I)*(x+.8613339373-.6742953540*I)*(x+.2427389576+1.102128965*I)*(x+.2427389576-1.102128965*I)*(x-.5466710940+1.018710076*I)*(x-.5466710940-1.018710076*I)*(x-1....
(x+1.075454452)*(x+.8613339373+.6742953540*I)*(x+.8613339373-.6742953540*I)*(x+.2427389576+1.102128965*I)*(x+.2427389576-1.102128965*I)*(x-.5466710940+1.018710076*I)*(x-.5466710940-1.018710076*I)*(x-1....