lec10.mw

> restart;

L-10 MCS 320 Wednesday 14 September 2005

1 Univariate Polynomials

> p := sum('c||i*x^i','i'=0..5); # general quintic

p := c0+c1*x+c2*x^2+c3*x^3+c4*x^4+c5*x^5

> degree(p,x); # do not forget to specify the variable

5

> coeff(p,x,3); # the coefficient with x^3

c3

> coeffs(sort(p,x),x);

c0, c3, c2, c1, c5, c4

> randomize(2): # initializes the seed

> r := randpoly(x,degree=5);

r := -17-71*x^5-11*x^4+25*x^3+29*x^2+77*x

> d := x+1;

d := x+1

> r1:= rem(r,d,x);

r1 := -30

> q := quo(r,d,x,'rest');

q := -71*x^4+60*x^3-35*x^2+64*x+13

> rest;

-30

To verify our calculations, we can compute q*d + r1 = r

> q*d + r1 = r;

(-71*x^4+60*x^3-35*x^2+64*x+13)*(x+1)-30 = -17-71*x^5-11*x^4+25*x^3+29*x^2+77*x

By default, Maple does not expand, we have to ask it:

> expand(lhs(%)) = r;

-17-71*x^5-11*x^4+25*x^3+29*x^2+77*x = -17-71*x^5-11*x^4+25*x^3+29*x^2+77*x

The opposite command to the expand, is the factor:

> factor(r);

-17-71*x^5-11*x^4+25*x^3+29*x^2+77*x

Over the rational numbers, Maple does not find a factorization.

> Factor(r) mod 2;

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

If we change our field, say, here to the binary numbers {0,1}, then r factors.

> factor(r,complex);

-71.*(x+1.104554288)*(x+(.1845027374+.9606180485*I))*(x+(.1845027374-.9606180485*I))*(x-.2030875632)*(x-1.115542622)

This is the numerical factorization over the field of complex numbers.  According to the fundamental theorem of algebra, every polynomial of degree d has d complex roots.

> fsolve(r,x,complex);

-1.104554288, -.1845027374-.9606180485*I, -.1845027374+.9606180485*I, .2030875632, 1.115542622

The numerical factorization corresponds to the numerical root finding problem, the f in the fsolve stands for floating-point arithmetic.

Let us do it by hand:

> alias(alpha=RootOf(r));

alpha

> d := x - alpha;

d := x-alpha

> q := quo(r,d,x,'rest');

q := 77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+(29+25*alpha-11*alpha^2-71*alpha^3)*x+(25-11*alpha-71*alpha^2)*x^2+(-11-71*alpha)*x^3-71*x^4

> evala(q*d + rest) = r;

-17-71*x^5-11*x^4+25*x^3+29*x^2+77*x = -17-71*x^5-11*x^4+25*x^3+29*x^2+77*x

> factor(q);

77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+29*x+25*x*alpha-11*x*alpha^2-71*x*alpha^3+25*x^2-11*x^2*alpha-71*x^2*alpha^2-11*x^3-71*x^3*alpha-71*x^4

> alias(beta=RootOf(q));

alpha, beta

> d1 := x - beta;

d1 := x-beta

> q1 := quo(q,d1,x,'rest');

q1 := 29+25*alpha-11*alpha^2-71*alpha^3+25*beta-11*beta*alpha-71*beta*alpha^2-11*beta^2-71*beta^2*alpha-71*beta^3+(25-11*alpha-71*alpha^2-11*beta-71*beta*alpha-71*beta^2)*x+(-11-71*alpha-71*beta)*x^2-...q1 := 29+25*alpha-11*alpha^2-71*alpha^3+25*beta-11*beta*alpha-71*beta*alpha^2-11*beta^2-71*beta^2*alpha-71*beta^3+(25-11*alpha-71*alpha^2-11*beta-71*beta*alpha-71*beta^2)*x+(-11-71*alpha-71*beta)*x^2-...

> evala(q1*d1 + rest) = q;

77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+29*x+25*x*alpha-11*x*alpha^2-71*x*alpha^3+25*x^2-11*x^2*alpha-71*x^2*alpha^2-11*x^3-71*x^3*alpha-71*x^4 = 77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+(29+...77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+29*x+25*x*alpha-11*x*alpha^2-71*x*alpha^3+25*x^2-11*x^2*alpha-71*x^2*alpha^2-11*x^3-71*x^3*alpha-71*x^4 = 77+29*alpha+25*alpha^2-11*alpha^3-71*alpha^4+(29+...

> f := d*d1*q1;

f := (x-alpha)*(x-beta)*(29+25*alpha-11*alpha^2-71*alpha^3+25*beta-11*beta*alpha-71*beta*alpha^2-11*beta^2-71*beta^2*alpha-71*beta^3+(25-11*alpha-71*alpha^2-11*beta-71*beta*alpha-71*beta^2)*x+(-11-71*...f := (x-alpha)*(x-beta)*(29+25*alpha-11*alpha^2-71*alpha^3+25*beta-11*beta*alpha-71*beta*alpha^2-11*beta^2-71*beta^2*alpha-71*beta^3+(25-11*alpha-71*alpha^2-11*beta-71*beta*alpha-71*beta^2)*x+(-11-71*...

The symbolic factorization of a polynomial consists in adding sufficiently many formal roots to the number field.  What is nice is that Maple can switch to the numerical factorization:

> a := evalf(alpha); b := evalf(beta);

a := .2030875632

b := 1.115542622

> subs(x=a,r); subs(x=b,r);

0.

0.11e-6

The symbolic factorization in a more common form:

> p := x^2 - 2;

p := x^2-2

> factor(p);

x^2-2

> evala(AFactor(p));

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

> convert(%,radical);

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

The third factorization is the exact factorization

> factor(x^2 - 1);

(x-1)*(x+1)

For this simple example, the numeric, symbolic factorization coincide.

2 Multivariate Polynomials

The absolute factorization extends to the multivariate polynomials:

> p := x^2 - 2*y^2;

p := x^2-2*y^2

> factor(p);

x^2-2*y^2

> evala(AFactor(p));

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

An absolute factorization means: factoring over the complex numbers.

> convert(%,radical);

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

This is the more common symbolic form of the factorization.

The plot below shows the geometric meaning of the absolute factorization: if it factors over the complex numbers, then the curve defined by the polynomial consists of several pieces.  In this case, the curve defined by p(x,y) = 0 degenerates in two lines.

> plots[implicitplot](p,x=-2..2,y=-2..2,numpoints=1000);

[Plot]

We may see multivariate polynomials as polynomials in one variable:

> r := randpoly([x,y,z],degree=3,dense);

r := -55-19*x^3+9*x^2*y+14*x^2*z-19*x^2-27*x*y^2+83*x*y*z-87*x*y+67*x*z^2-31*x*z-25*x+37*y^3+15*y^2*z-9*y^2+89*y*z^2+98*y*z-23*y-18*z^3+75*z^2+63*zr := -55-19*x^3+9*x^2*y+14*x^2*z-19*x^2-27*x*y^2+83*x*y*z-87*x*y+67*x*z^2-31*x*z-25*x+37*y^3+15*y^2*z-9*y^2+89*y*z^2+98*y*z-23*y-18*z^3+75*z^2+63*z

> collect(r,x);

-19*x^3+(14*z-19+9*y)*x^2+(-25-87*y+67*z^2-31*z-27*y^2+83*y*z)*x-55+89*y*z^2+98*y*z-23*y-18*z^3+75*z^2+63*z+37*y^3+15*y^2*z-9*y^2-19*x^3+(14*z-19+9*y)*x^2+(-25-87*y+67*z^2-31*z-27*y^2+83*y*z)*x-55+89*y*z^2+98*y*z-23*y-18*z^3+75*z^2+63*z+37*y^3+15*y^2*z-9*y^2

> collect(r,[x,z]);

-19*x^3+(14*z-19+9*y)*x^2+(67*z^2+(-31+83*y)*z-25-87*y-27*y^2)*x-18*z^3+(89*y+75)*z^2+(98*y+15*y^2+63)*z-55-9*y^2-23*y+37*y^3-19*x^3+(14*z-19+9*y)*x^2+(67*z^2+(-31+83*y)*z-25-87*y-27*y^2)*x-18*z^3+(89*y+75)*z^2+(98*y+15*y^2+63)*z-55-9*y^2-23*y+37*y^3

The output of the last command shows our multivariate polynomial as a polynomial in x,

with coefficients as polynomials in y and z.  The coefficient are polynomials in z, with coefficients as polynomials in y.

>