CHAPTER 3

image

Polynomial Divisibility, Interpolation, and Algebraic Extensions

3-1. Commands for Handling Polynomial Expressions

This chapter is about working with polynomials and algebraic extensions. We will study the MATLAB commands that enable you to perform polynomial operations, working with roots, Galois extensions, Gröbner bases, polynomial interpolation, and operations modulo an integer. We will also present the commands that Maple implements to the same effect.

MATLAB enables agile work with polynomials, providing several commands for handling polynomial algebraic expressions. These expressions can also be treated as general algebraic expressions, but MATLAB offers particular tools for polynomial algebraic expressions, including case-specific commands. Let’s take a look at some of these commands:

  • conv(a,b) returns the vector whose entries are the coefficients of the polynomial defined as the product of the polynomials whose coefficients are given by the vectors a and b.
  • [q,r] = deconv(a,b) gives the vector q of coefficients of the polynomial defined as the quotient of polynomials whose coefficients are given by the vectors a and b, and the vector r of coefficients of the remainder polynomial.
  • poly2sym(a) returns the polynomial whose coefficients are those specified by the vector a.
  • sym2poly(poly) returns the vector of coefficients of the specified polynomial (the reverse of the previous operation).
  • roots(a) gives the roots of the polynomial whose coefficients are given by the vector a.
  • poly(v) gives the polynomial whose roots are the components of the vector v.
  • poly(A) gives the characteristic polynomial of the matrix A.
  • polyder(a) gives the vector whose coefficients are those of the first derivative of the polynomial defined by a.
  • polyder(a,b) gives the vector whose coefficients are those of the first derivative of the product of polynomials defined by a and b.
  • [q,d] = polyder(a,b) returns the numerator q and denominator d of the derivative of the polynomial quotient a/b (here all arguments are vectors of coefficients of polynomials).
  • polyval(p,S) evaluates the polynomial p at S.
  • polyvalm(p,S) evaluates the polynomial p at a matrix S.
  • [r,p,k] = residue(a,b) gives the column vectors r, p and k such that: b(s)/a(s)=r1/(s-p1)+r2/(s-p2)+...+rn/(s-pn) +k(s).
  • [a,b] = residue(r, p, k) performs the reverse of the previous operation.

Now let’s look at some examples of the above defined commands:

Let’s decompose the fraction (-x ^ 2 + 2 x + 1) /(x^2-1) into the sum of its simple fractions:

>> [r,p,k]=residue([-1,2,1],[1,0,-1])
r =

    1.0000
    1.0000

p =

   -1.0000
    1.0000

k =

    -1

So the decomposition will be:

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

The same result can be obtained in the following way:

>> pretty(sym(maple('convert((-x^2+2*x+1)/(x^2-1),parfrac,x)')))
                                      1      1
                              -1 + ----- + -----
                                   x - 1   x + 1

Next we will evaluate the polynomial x ^ 4-6 * x ^ 3-x ^ 2 + 10 * x-11 at the point x = 5 and at the unit matrix of order 4.

>> polyval([1,-6,-1,10,-11],5)
ans =

  -111
>> polyvalm([1,-6,-1,10,-11],ones(4))
ans =

   -37 - 26 - 26 - 26
   -26 - 37 - 26 - 26
   -26 – 26 - 37 - 26
   -26 - 26 – 26 - 37

Now let’s find the roots of the polynomial x ^ 3-x:

>> roots([1,0,-1,0])
ans =

         0
   -1.0000
    1.0000

Now we solve the equation -x ^ 5 + 2 * x ^ 4 + x ^ 3 + x ^ 2 = 0:

>> roots([-1,2,1,1,0,0])
ans =
        0
        0
   2.5468
  -0.2734 + 0.5638i
  -0.2734 - 0.5638i

EXERCISE 3-1

Consider the polynomials with coefficients a = [2 - 4, 5, 8, 0, 0, 1] and b = [- 7, 15, 0, 12, 0]. Calculate the coefficients of the product and the quotient of polynomials defined by a and b, and also calculate the coefficients of the derivatives of the product and quotient of the polynomials defined by a and b.

>> a=[2,-4,5,8,0,0,1]; b=[-7,15,0,12,0];
>> conv(a,b)

ans =

   -14    58   -95    43    72    60    89    15     0    12     0

>> [q,r]=deconv(a,b)

q =

   -0.2857   -0.0408   -0.8017
r =

    0         0         0   23.4548    0.4898    9.6210    1.0000

>> polyder(a)

ans =

    12   -20    20    24     0     0

>> polyder(a,b)

ans =

  -140-522 - 760 301 432 300 356 45 0 12

>> [q, d] = polyder(a, b)

q =

   -28 118 -120 251 -192 180 220 -45 0 -12

d =

    49 -210 225 -168 360 0 144 0 0

In the previous calculations, we could instead have transformed the coefficient vectors into the equivalent polynomials with the command poly2sym, obtaining the results in polynomial form. The product polynomial is:

>> pretty(poly2sym(conv(a,b)))

        10      9       8      7     6      5      4      3
   -14 x + 58 x  - 95 x + 43 x + 72 x + 60 x + 89 x + 15 x + 12 x

The quotient polynomial is:

>> pretty(poly2sym(q))

                                   2           275
                            -2/7 x - 2/49 x -  ---
                                               343

The first derivative of the polynomial defined by a is:

>> pretty(poly2sym(polyder(a)))

                             5      4      3       2
                         12 x - 20 x + 20 x + 24 x

The first derivative of the product of polynomials defined by a and b is:

>> pretty(poly2sym(polyder(a,b)))

        9       8       7       6       5       4       3      2
  -140 x + 522 x - 760 x + 301 x + 432 x + 300 x + 356 x + 45 x + 12

The first derivative of the polynomial quotient a/b will be q/d where q and d are as follows:

>> [q,d]=polyder(a,b);
>> pretty(poly2sym(q))

       9        8       7       6       5       4       3       2
  -28 x + 118 x - 120 x + 251 x - 192 x + 180 x  + 220 x - 45 x - 12

>> pretty(poly2sym(d))

                  8        7       6       5       4       2
              49 x - 210 x + 225 x - 168 x + 360 x + 144 x

EXERCISE 3-2

Find the characteristic polynomial of the matrix whose rows are the vectors [2,-4,5,8], [0,0,0,1], [-7,15,0,12] and [0,-1,-1,0]. Also find the roots of this polynomial and verify that the matrix satisfies the characteristic polynomial equation.

>> A=[2,-4,5,8;0,0,0,1;-7,15,0,12;0,-1,-1,0]

A =
     2    -4     5     8
     0     0     0     1
    -7    15     0    12
     0    -1    -1     0

>> p=poly(A)

p =

    1.0000   -2.0000   48.0000  -67.0000   33.0000

>> pretty(poly2sym(p))

                          4      3       2
                         x  - 2 x  + 48 x  - 67 x + 33

To find the roots of the characteristic polynomial we do the following:

>> roots(p)

ans =

   0.2836 + 6.8115i
   0.2836 - 6.8115i
   0.7164 + 0.4435i
   0.7164 - 0.4435i

To verify that the matrix A satisfies the characteristic polynomial, we evaluate the characteristic polynomial at the matrix A and observe that it (almost) returns the null matrix.

>> polyvalm(p,A)

ans =

  1.0E-012 *

    0.4619 - 0.9663   0.0426 - 0.9095
    0.0016 - 0.0071   0.0142   0.0142
    0.1181 - 0.0568   0.6466   0.7390
   -0.0995   0.2132 - 0.0140   0.1634

EXERCISE 3-3

Expand the following polynomial expressions:

image

>> syms x y z
>> pretty(expand(simple(5*x^3*y^2*z-4*x*y^2*z^3)^3))

                9  6  3        7  6  5        5  6  7       3  6  9
           125 x  y  z  - 300 x  y  z  + 240 x  y  z  - 64 x  y  z

>> pretty(expand((x+y)*(x^4+x^2*y^2+y^4)*(x-y)))

                                      6    6
                                    x  - y

Here we see that the first polynomial presents difficulties when we try to expand it using only the command expand; we need to use the simple command first.

EXERCISE 3-4

Factorize the following polynomial expressions as much as possible.

a) 4x2 + y2t2 + z4 − 4xyt + 4xz2 − 2ytz2

b) x4x2y2 + 2xy2 + x2 − 2x3y2

c) amx + amybmxbmy + bnxanxany + bny

>> syms x y z t a b m n
>> pretty(factor(4*x^2+y^2*t^2+z^4-4*x*y*t+4*x*z^2-2*y*t*z^2))

                                              2  2
                               (2 x - y t + z  )

>> pretty(factor(x^4- x^2*y^2+2*x*y^2+x^2-2*x^3-y^2))

                                    2
                            (x - 1)  (x - y) (x + y)

>> pretty(factor(a*m*x+a*m*y-b*m*x-b*m*y+b*n*x-a*n*x-a*n*y+b*n*y))

                          - (x + y) (n - m) (- b + a)

In general, in polynomial expressions, the command expand performs operations and simplifies the result, and the command factor factorizes as much as possible.

3-2. Extracting Parts of a Polynomial

The following commands enable MATLAB to extract various parts of a polynomial (after prior use of the maple command):

  • coeff(polynomial,var,n) extracts the coefficient of the polynomial in var corresponding to the monomial of power n. Before applying coeff, be sure it is suitable to do so, by first applying collect to group the terms in the variable.
  • coeff(polynomial,expression) extracts the coefficient corresponding to the specified expression in the given polynomial.
  • coeffs(polynomial,variable) extracts the sequence of all the coefficients of the polynomial in the given variable.
  • coeffs(polynomial) extracts the sequence of all the coefficients of all the variables of the specified multivariable polynomial.
  • coeffs(polynomial,{var1,...,varn}) or coeffs(polynomial,[var1,...,varn]) extracts the sequence of coefficients of the given multivariate polynomials corresponding to the specified set of variables.
  • coeffs(poly,var,name) finds the sequence of polynomial coefficients corresponding to the variable var and assigns to it the specified name.
  • sign(poly) returns the sign of the leading coefficient of the given multivariate polynomial. If the polynomial is positive, returns 1, and if it is negative, returns - 1.
  • sign(poly,var) gives the sign of the leading coefficient of the polynomial in the variable var.
  • sign(poly,[var1,...,varn]) gives the sign of the leading coefficient of the polynomial in the variables var1,..., varn.
  • lcoeff(polynomial) finds the leading coefficient of the multivariate polynomial with respect to all variables appearing in the polynomial.
  • lcoeff(polynomial,variable) finds the leading coefficient of the polynomial with respect to the given variable.
  • lcoeff(polynomial,{var1,...,varn}) or lcoeff(polynomial,[var1,...,varn]) finds the leading coefficient of the polynomial for the given variable set.
  • tcoeff(polynomial) finds the trailing coefficient of the polynomial for all its variables.
  • tcoeff(polynomial,variable) finds the trailing coefficient of the polynomial output in the given variable.
  • tcoeff(polynomial,{var1,...,varn}) or tcoeff(polynomial,[var1,...,varn]) finds the trailing coefficient of the polynomial for the given variables.
  • ldegree(polynomial,var) determines the lowest degree of the polynomial in the given variable.
  • ldegree(polynomial) determines the lowest degree of the polynomial with respect to all of its variables.
  • ldegree(polynomial,{var1,...,varn}) or ldegrace(polynomial, [var1,...,varn]) determines the lowest degree of the polynomial with respect to the given set of variables.
  • degree(polynomial,variable) determines the highest degree of the polynomial in the given variable.
  • degree(polynomial) determines the highest degree of the polynomial with respect to all of its variables.
  • degree(polynomial,{var1,...,varn}) or dgree(polynomial,[var1,...,varn])  determines the highest degree of the polynomial for the given variables.

Here are some examples:

>> pretty (sym (maple('p:= 2*x^2 + 3*y^3-5:'))))
>> pretty(sym(maple('coeff(p,x,2), coeff(p,x^2), coeff(p,x,0) ')))
                                      3
                            2, 2, 3 y - 5
>> pretty (sym (maple ('q: = 3 * a * (x + 1) ^ 2 + sin (a) * x ^ 2 * y - y ^ 2 * x + x - a:')))
>> pretty(sym(maple('coeff(q,x)')))

                                    2
                             6 a - y + 1

>> pretty(sym(maple('q := collect(q,x)')))

                                 2          2
          q: = (sin (a) y + 3a) x + (6 a - y + 1) x + 2a

>> pretty(sym(maple('coeff(q,x)')))

                                    2
                             6 a - y + 1

>> pretty(sym(maple('s := 3*v^2*w^3*x^4+1')))

                                 2 3 4
                         s: = 3 v w x + 1

>> pretty(sym(maple('lcoeff(s), tcoeff(s), lcoeff(s, [v,w], t), t')))

                                        4  2 3
                               3, 1, 3 x, v w

>> maple('degree(2/x^2+5+7*x^3,x), ldegree(2/x^2+5+7*x^3,x),degree(x*sin(x),x)')

                             3, - 2, FAIL

>> maple('degree(x*sin(x),sin(x)), degree((x+1)/(x+2),x),degree(x*y^3+x^2,[x,y]) ')

                              1, FAIL, 2

>> pretty(sym(maple('degree(x*y^3+x^2,{x,y}), ldegree(x*y^3+x^2,[x,y]) ')))

                                 4, 4

>> pretty(sym(maple('expr := 3*x^2*y^4 - 2*x*y^5 + x')))
>> pretty(sym(maple('indets(expr), sign(expr), sign(expr, [x,y]), sign(expr, [y,x]),       sign(expr, [y,x], a), a')))
{x, y}, 1, 1, - 1, - 1, x * y ^ 5

3-3. Factorization of Polynomials

This section presents the commands that implement various polynomial factorizations (following prior use of the maple command).

  • factor(polynomial) factorizes a multivariate polynomial over the ring determined by its coefficients (integer, real, rational, and so on).
  • factor(polynomial,radical) factorizes the polynomial over the algebraic extension Q(radical).
  • factor(polynomial,RootOf) factorizes the polynomial over the algebraic extension Q(RootOf).
  • factor(polynomial,[radical1,...,radicaln]) factorizes the polynomial over the algebraic extension Q(radical1,...,radicaln).
  • factor(polynomial,[RootOf1,..,RootOfn]) factorizes the polynomial over the algebraic extension Q(RootOf1,...,RootOfn).
  • factor([polynomial1,..., polynomialn] or factor({polynomial1,...,polynomialn})) factorizes the specified polynomials.
  • factors(polynomial) returns a list with the multivariate polynomial factors and their multiplicities.
  • factors(polynomial,radical) returns a list with the multivariate polynomial factors and their multiplicities in the algebraic extension Q(radical).
  • factors(polynomial,RootOf) returns a list with the multivariate polynomial factors and their multiplicities in the algebraic extension Q(RootOf).
  • factors(polynomial,[rad1,...,radn]) or factors(polynomial,{rad1,...,radn}) returns a list with the multivariate polynomial factors and their multiplicities in the algebraic extension Q(radical1,...,radicaln).
  • factors(poly,[RootOf1,...,RootOfn]) or factors(poly,{RootOf1,...,RootOfn}) returns a list with the multivariate polynomial factors and their multiplicities in the algebraic extension Q(RootOf1,...,RootOfn).
  • Factor(polynomial) performs the inert factorization of the polynomial.
  • factor(n) returns a row vector of prime factors of the positive integer n.
  • ifactor(n,option) gives the entire factorization of n according to the given option. Possible option values are sqfof (which uses the square free factorization method), pollard (which uses the Pollard method), lenstra (which uses the Lenstra method) and easy (which calculates only the easy factorizations).
  • Factor(polynomial) modn performs the inert factorization of the polynomial modulo n.
  • grading(Factor(polynomial,expr),option) factorizes the polynomial in the algebraic extension defined by expr according to the method given in the option (lenstra, trager, or linear).
  • Factors(polynomial) returns inert form factors and their multiplicities for the given polynomial.
  • Factors(polynomial) modn gives the factors and their multiplicities for polynomial modulo n.
  • grading(Factors(polynomial,expression),option) gives the list of factors and multiplicities of the polynomial in the given algebraic extension defined by the expression according to the specified option (lenstra, trager, or linear).
  • Afactor(polynomial) performs the inert absolute factorization of the polynomial.
  • Afactors(polynomial) returns the list of factors of the inert absolute factorization of the polynomial.
  • Berlekamp(poly,variable) returns the inert form of the Berlekamp factorization of varying degrees for the polynomial poly with respect to the given variable.
  • Berlekamp(poly,var) modn as above, but working modulo n.
  • Berlekamp(variable,radical,polynomial) returns the inert form of the Berlekamp factorization of varying degrees for the polynomial over the algebraic extension defined by radical.
  • DistDeg(polynomial,var) returns the inert form of the factorization of varying degrees of the polynomial given with respect to the variable var.
  • DistDeg(poly,var) mod n gives the factorization of varying degrees of the given polynomial with respect to the variable var modulo n.
  • readlib(split):split(polynomial,variable) performs the complete factorization of the polynomial with respect to the variable given over the ring determined by its coefficients.
  • readlib(splits):splits(polynomial,variable) returns the factors and their multiplicities for the complete factorization of the polynomial with respect to the given variable.
  • sqrfree(polynomial) returns the square-free factors and their multiplicities of a polynomial with rational coefficients.
  • sqrfree(polynomial,variable) returns the square-free factors and their multiplicities of a polynomial with rational coefficients in the specified variable.
  • Sqrfree(polynomial) returns the inert square-free factors and their multiplicities of a polynomial with rational coefficients.
  • Sqrfree(polynomial) modn returns the inert square-free factors and their multiplicities of a polynomial with rational coefficients modulo n.
  • with(lattice): mipolys(n,p) gives the number of irreducible univariate monic polynomials of degree n over Z (modp).
  • with(lattice): mipolys(n,p,m) gives the number of irreducible univariate monic polynomials of degree n over the Galois field defined by pm.
  • irreduc(polynomial) determines whether the multivariate polynomial is irreducible over the ring defined by its coefficients.
  • irreduc(polynomial,radical) determines whether the multivariate polynomial is irreducible over the algebraic extension Q(radical).
  • irreduc(polynomial,{rad1,...,radn}) or irreduc(polynomial,[rad1,...,radn]) determines whether the multivariate polynomial is irreducible over the extension Q(radical1,...,radicaln).
  • Irreduc(polynomial) represents the inert form of irreduc.
  • Irreduc(polynomial) mod n determines whether the multivariate polynomial is irreducible over the ring defined by its coefficients modulo n.

Here are some examples:

>> pretty(sym(maple('factor(x^3+5)')))

                                 3
                                x  + 5

>> pretty(sym(maple('factor(x^3+5.0)')))

                              2
         (x + 1.709975947). (x - 1.709975947 x + 2.924017740).

>> pretty(sym(maple('factor(a^3+a^2+a+1) ')))
                                     2
                           (a + 1) (a + 1)
>> pretty(sym(maple('factor(a^3+a^2+a+1,complex) ')))
                    (a + 1.) (a + 1.) I) (a - 1. I)
>> pretty(sym(maple('readlib(factors):factors(a^10-2*a^5+1) ')))

                                3   4   2
             [1, [[a - 1, 2], [a + a + a + a + 1, 2]]]

>> pretty(sym(maple('readlib(factors):factors(a^10-2*a^5+1,real) ')))

       2
[1, [[a + 1.618033989 a + 1.000000000, 2], [a - 1., 2],]]
                  2
 [[[a.6180339888 a + 1.000000000, 2]]]

>> pretty(sym(maple('Factors(a^10-2*a^5+1) mod 7')))

                                4    3    2
             [1, [[a + 6, 2], [a  + a  + a  + a + 1, 2]]]

>> pretty(sym(maple('Factor(a^10-2*a^5+1) mod 7')))

                          2   4    3    2         2
                   (a + 6)  (a  + a  + a  + a + 1)

>> pretty(sym(maple('Factor(a^10-2*a^5+1)')))

                                10      5
                        Factor(a   - 2 a  + 1)

>> pretty(sym(maple('evala(")')))

                     4    3    2         2        2
                   (a  + a  + a  + a + 1)  (a - 1)

>> pretty(sym(maple('readlib(split): split(x^2+x+1,x)')))

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

>> pretty(sym(maple('readlib(splits): splits(x^2+x+1,x)')))

                   2                                  2
[1,[[x - RootOf(_Z  + _Z + 1), 1], [x + 1 + RootOf(_Z  + _Z + 1), 1] ]]

>> pretty(sym(maple(' f := x^3*y-x^3-x^2*y^2+x^2*y')))

>> pretty(sym(maple('sqrfree(f,x) ')))

                    [y - 1, [[-y + x, 1], [x, 2]]]

>> pretty(sym(maple('sqrfree(f,y)')))

                      2                2
                   [-x , [[-x y + x + y  - y, 1]]]

>> pretty(sym(maple('sqrfree(f,[x,y])')))

                [1, [[y - 1, 1], [-y + x, 1], [x, 2]]]

>> pretty(sym(maple('Sqrfree(4*x^2+4*x+1) mod 7')))

                          [4, [[x + 4, 2]]]

>> pretty(sym(maple('irreduc( x^3+5 )')))

                                 true

>> pretty(sym(maple('irreduc( x^3+5, 5^(1/3))')))

                                false

>> pretty(sym(maple('Irreduc(2*x^2+6*x+6) mod 7,Factor(2*x^2+6*x+6) mod 7')))

                       false,    2*(x+6)*(x+4)

>> pretty(sym(maple('Irreduc(x^4+x+1) mod 2,   Factor(x^4+x+1) mod 2')))

                          true,   x^4+x+1

As we have already seen many examples and exercises relating to factorization of univariate and multivariate polynomials, we shall present only a pair of exercises.

EXERCISE 3-5

Factorize the polynomial a4 - 9/4 in the following cases:

(a) over the field defined by its coefficients

(b) over the real field

(c) over the complex field

(d) over the algebraic extension Q(√2,√3)

(e) over the algebraic extension Q(√2,√3, i)

(f) over the algebraic extension Q(RootOf(Z^2+3/2)).

>> pretty(sym(maple('factor(a^4-9/4)')))

                              2          2
                      1/4 (2 a  - 3) (2 a  + 3)

>> pretty(sym(maple('factor(a^4-9/4,real)')))

                                                   2
            (a + 1.224744871) (a - 1.224744871) (a  + 1.499999999)

>> pretty(sym(maple('factor(a^4-9/4,complex)')))

(a + 1.224744871)(a + 1.224744871 I)(a-1.224744871 I)(a-1.224744871)

>> pretty(sym(maple('factor(a^4-9/4,{(3)^(1/2),2^(1/2)})')))

                       2              1/2  1/2           1/2  1/2
             - 1/8 (2 a  + 3) (2 a + 3    2   ) (-2 a + 3    2   )

>> pretty(sym(maple('factor(a^4-9/4,{(3)^(1/2),2^(1/2),I})')))

                1/2  1/2            1/2  1/2          1/2  1/2
1/16 (-2 a + I 3    2   ) (2 a + I 3    2   ) (2 a + 3    2   )

             1/2  1/2
    (-2 a + 3    2   )

>> pretty(sym(maple('factor(a^4-9/4,RootOf(Z^2+3/2))')))

            2                      2                       2
    1/2 (2 a  - 3) (a + RootOf(2 _Z  + 3)) (a - RootOf(2 _Z  + 3))

EXERCISE 3-6

Determine whether the polynomial x9 + 1 is irreducible in the following cases:

(a) over the field defined by its coefficients

(b) over the algebraic extension Q(√3 i).

Perform its factorization where possible.

>> pretty(sym(maple('irreduc(x^9+1)')))

                                false

>> pretty(sym(maple('factor(x^9+1)')))

                            2            6    3
                  (x + 1) (x  - x + 1) (x  - x  + 1)

>> pretty(sym(maple('irreduc(x^9+1,(-3)^(1/2))')))

                                false

>> pretty(sym(maple('factor(x^9+1,(-3)^(1/2))')))

          3          1/2      3          1/2                 1/2
1/16 (-2 x  + 1 + I 3   ) (2 x  - 1 + I 3   ) (-2 x + 1 + I 3   )

                  1/2
    (2 x - 1 + I 3   ) (x + 1)

3-4. Roots of Polynomials

The following group of MATLAB commands, all of which require the prior use of the maple command, may be used to work with roots of polynomials:

  • roots(polynomial) gives univariate polynomial roots by offering a list of lists with the roots and their multiplicities. The calculation is performed over the ring defined by the coefficients.
  • roots(polynomial,radical) finds the roots of the univariate polynomial over the algebraic extension Q(radical)or Q(RootOf).
  • roots(polynomial,[rad1,...,radn]) or roots(polynomial,{rad1,...,radn}) finds the roots of a univariate polynomial over Q(rad1,...,radn) or Q(RootOf1,...,RoofOfn).
  • Roots(poly) returns the inert form of the roots of the polynomial poly.
  • Roots(poly) modn gives the roots of the polynomial poly modulo n.
  • reallib(realroot): realroot(polynomial) finds intervals in which the real roots of a univariate polynomial with integer coefficients are contained.
  • reallib(realroot): realroot(polynomial,n) finds intervals with a maximum width of n in which the real roots of a univariate polynomial with integer coefficients are contained.
  • reallib(proot): proot(poly,n) calculates the nth root of the given polynomial with rational coefficients.
  • reallib(psqrt): psqrt(poly) computes the square root of the given polynomial with rational coefficients.
  • with(numtheory): cyclotomic(n,variable) returns the n-th cyclotomic polynomial in the given variable.
  • readlib(sturm): sturmseq(polynomial,variable) gives a list of polynomials representing the Sturm sequence for the given polynomial.
  • readlib(sturm): sturm(expression,variable,a,b) returns the number of real roots of the polynomial in the interval (a, b] using the Sturm sequence.
  • readlib(lattice): minpoly(r,n) returns a polynomial of degree less than or equal to n with small integer coefficients, such that r is one of its roots.
  • readlib(lattice): minpoly(r,n,e) returns a polynomial of degree less than or equal to n with small integer coefficients, such that r is one of its approximate roots with an accuracy given by e.

Here are some examples. First, we find the roots and their multiplicities over the field defined by the coefficients of the given polynomials:

>> pretty(sym(maple('roots(2*x^3+11*x^2+12*x-9)')))

                         [[-3, 2], [1/2, 1]]

>> pretty(sym(maple('roots(x^3+(-6-b-a)*x^2+(6*a+5+5*b+a*b)*x-5*a-5*a*b,x)')))

                               [[5, 1]]

Next, we find modular integer roots and their multiplicities.

>> pretty(sym(maple('Roots(x^3-x) mod 6')))

           [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]

>> pretty(sym(maple('Roots(x^3-1) mod 2')))

                               [[1, 1]]

>> pretty(sym(maple('alias(a=RootOf(x^2+x+1))'))) ;

>> pretty(sym(maple('Roots(x^3-1,a) mod 2')))

                         [[a + 1, 1], [1, 1], [a, 1]]

Next we solve a third-degree polynomial with integer coefficients that has 1.2324 as an approximate root:

>> pretty(sym(maple('readlib(lattice) : minpoly(1.234,3)')))
                                       2       3
                     109. 61 _X + 5 _X - 22 _X

Next we generate a Sturm sequence for a given polynomial in order to find the number of roots of the polynomial in the specified ranges:

>> pretty(sym(maple('readlib(sturm): sturmseq(expand((x-1)*(x-2)*(x-3)),x)')))

                  3      2              2
                [x  - 6 x  + 11 x - 6, x  - 4 x + 11/3, x - 2, 1]

>> pretty(sym(maple('sturm(",x,3/2,4)')))

                                  2

>> pretty(sym(maple('sturm("",x,1,2)')))

                                  1

Next we calculate the square and cubic roots of the given polynomials:

>> pretty(sym(maple('readlib(psqrt): psqrt(x^2+2*x*y+y^2)')))

                                x + y

>> pretty(sym(maple('readlib(proot): proot(x^3+3*x^2+3*x+1,3)')))

                                x + 1

EXERCISE 3-7

Find the roots and their multiplicities of the polynomial x4 - 4 in the following cases:

(a) over the field defined by its coefficients

(b) over the algebraic extension Q(√2)

(c) over the algebraic extension Q(√2, i)

(d) over the algebraic extension Q(RootOf(x2- 2))

(e) over the algebraic extension Q(RootOf(x2- 2),RootOf(x2+ 2))

>> pretty(sym(maple('roots(x^4-4)')))

>> pretty(sym(maple('roots(x^4-4,x)')))
>> pretty(sym(maple('roots(x^4-4,sqrt(2))')))
                               1/2         1/2
                            [[2   , 1], [-2   , 1]]

>> pretty(sym(maple('roots(x^4-4, {sqrt(2),I})')))

                   1/2           1/2        1/2         1/2
              [[I 2   , 1], [-I 2   , 1], [2   , 1], [-2   , 1]]

>> pretty(sym(maple('alias(a = RootOf(x^2-2))'))) ;

>> pretty(sym(maple('alias(b = RootOf(x^2+2))'))) ;

>> pretty(sym(maple('roots((x^4-4), x, a)')))

                               [[a, 1], [-a, 1]]

>> pretty(sym(maple('roots(x^4-4, {a, b})')))

                      [[b, 1], [-b, 1], [, 1], [-a, 1]]

EXERCISE 3-8

Find the intervals in which the real roots of the polynomial x8 + 5 x7 - 4 x6 - 20 x5 + 4 x4 + 20 x3 are located, with the following specifications:

(a) intervals with default width

(b) intervals with a width of one unit

(c) intervals with a half-unit width

(d) intervals with a width of one thousandth of a unit

>> pretty(sym(maple('readlib(realroot)')));
>> pretty(sym(maple('realroot(x^8+5*x^7-4*x^6-20*x^5+4*x^4+20*x^3)')))

                 [[0, 0], [0, 8], [- 4, 0], [- 8, - 4]]

We deduce that zero is a root.

>> pretty(sym(maple('realroot(x^8+5*x^7-4*x^6-20*x^5+4*x^4+20*x^3,1)')))

                 [[0, 0], [1, 2], [- 1, - 2] [- 5, - 5]]

We deduce that -5 is another root.

>> pretty(sym(maple('realroot(x^8+5*x^7-4*x^6-20*x^5+4*x^4+20*x^3,1/2)')))

               [[0, 0], [1, 3/2], [-3/2, -1], [-5, -5]]

>> pretty(sym(maple('realroot(x^8+5*x^7-4*x^6-20*x^5+4*x^4+20*x^3,1/1000)')))

                      181  1449    -1449  -181
            [[0, 0], [---, ----], [-----, ----], [-5, -5]]
                      128  1024    1024   128

3-5. Grouping and Ordering Terms

This section presents commands that allow you to group terms into univariate and multivariate polynomials, as well as to manage them according to certain criteria. The syntax of these commands is as follows (after using the maple command):

  • collect(polynomial,variable) organizes the multivariate polynomial, taking the specified variable as the main variable and gathering terms with respect to the same.
  • collect(polynomial,[var1,...,varn]) or collect(polynomial,{var1,...,varn}) gathers terms in the polynomial with respect to the specified variables.
  • sort(polynomial) sorts the univariate polynomial in decreasing order of powers.
  • sort(polynomial) or sort(polynomial, tedeg) sorts the polynomial according to the degree of its monomial multivariate components (in descending order).
  • sort(polynomial, plex) sorts the multivariate polynomial in lexicographical order.
  • sort(poly,[var1,...,varn],option) or sort(poly,{var1,...,varn},option) sorts the polynomial with respect to the specified variable according to the given option (plex or tedeg).

Here are some examples:

>> pretty(sym(maple('collect(x*y+a*x*y+y*x^2-a*y*x^2+x+a*x,[x,y],recursive)')))
                            2
                 (1 - a) y x  + ((1 + a) y + 1 + a) x
>> pretty(sym(maple('collect(x*y+a*x*y+y*x^2-a*y*x^2+x+a*x,[y,x],recursive)')))
                          2
                ((1 - a) x  + (1 + a) x) y + (1 + a) x
>> pretty(sym(maple('collect(x*y+a*x*y+y*x^2-a*y*x^2+x+a*x,[x,y], distributed)')))
                                                     2
                (1 + a) x + (1 + a) x y + (1 - a) y x
>> pretty(sym(maple('collect(x^3*y+x^2*y^3+x+3,y)')))
                          3      2  3
                         x  y + x  y  + x + 3
>> pretty(sym(maple('sort(",y)')))
                          2  3    3
                         x  y  + x  y + x + 3
>> pretty(sym(maple('sort(y^3+y^2*x^2+x^3,[x,y])')))
                            2  2    3    3
                           x  y  + x  + y
>> pretty(sym(maple('sort(y^3+y^2*x^2+x^3,[x,y],plex)')))
                            3    2  2    3
                           x  + x  y  + y
>> pretty(sym(maple('sort(y^3+y^2*x^2+x^3,[x,y],tdeg)')))
                            2  2    3    3
                           x  y  + x  + y

3-6. Handling of Polynomials

This section presents a group of commands that allow you to perform certain manipulations on univariate and multivariate polynomials, such as conversions, compositions, working with their operands, and so on. The syntax of these commands (following prior use of the maple command) is presented below:

  • compoly(poly,variable) determines the possible composition of the polynomial in the specified variable. The result is a list whose first element is the polynomial basis polyb, and whose second element is the polynomial equation eqnc such that sub(eqnc,polyb) = poly.
  • compoly(poly,{var1,...,varn}) determines the possible composition of the polynomial in the variables var1,...,varn.
  • compoly(polynomial) determines the composition of the multivariate polynomial in all its indeterminates.
  • indets(polynomial) determines all the indeterminates of the given polynomial.
  • readlib(student): completesquare(polynomial) transforms quadratic expressions to completed square form.
  • readlib(numaprox): hornerform(polynomial,variable) converts the polynomial in the given variable into Horner form.
  • convert(poly,horner,var) converts the polynomial in the variable var to Horner form.
  • convert(polynomial,horner,{var1,...,varn}) converts the polynomial in the given variables to Horner form without specifying the order.
  • convert(polynomial,horner,[var1,...,varn]) converts the polynomial in the given variables into Horner form in the order specified.
  • convert(polynomial,horner) converts the polynomial in all its variables to Horner form.
  • convert(poly,mathorner,var)converts the polynomial in the given variable into matrix Horner form.
  • convert(poly,sqrfree,var) converts the polynomial in the given variable into a square-free polynomial by factoring it into its square-free factors.
  • content(polynomial,variable) determines the greatest common divisor of the coefficients of the polynomial in the given variable.
  • content(polynomial,[var1,...,varn]) or content(polynomial,{var1,...,varn}) determines the greatest common divisor of the coefficients of the polynomial with respect to the specified variables.
  • content(polynomial) determines the greatest common divisor of the coefficients of the polynomial with respect to all of its variables.
  • Content(polynomial,variable) determines the greatest common divisor of the coefficients of the polynomial in the given variable in inert form.
  • Content(poly,var) mod n determines the greatest common divisor of the coefficients of the polynomial in the given variable modulo n.
  • primpart(polynomial) determines a rational value such that dividing the polynomial by this value yields a primitive polynomial over the integers. If the primitive polynomial is already over the integers, this command is equivalent to content.
  • with(combinat): fibonacci(n,variable) gives the nth Fibonacci polynomial in the given variable.
  • with(combinat): euler(n, var) gives the nth Euler polynomial in the variable var.
  • with(linalg): hermite(M,var) determines the Hermite normal  form of the matrix M of univariate polynomials in the given variable.
  • with(linalg): hermite(M,var) mod n determines the Hermite normal  form of the matrix M of univariate polynomials in the given variable modulo n.
  • with(linalg): smith(M,var) determines the Smith normal form of the matrix M of univariate polynomials in the given variable.
  • with(linalg): smith(M,var) mod n determines the Smith normal form of the matrix M of univariate polynomials in the given variable modulo n.
  • readlib(bernstein): bernstein(n,var->exprvar,variable1) finds the degree n Bernstein polynomial in variable1 that approximates the functional operator var - > exprvar in the interval [0,1].
  • op(polynomial) returns a string with all the operands (monomials) of the polynomial. Any operand can be substituted using subsop.
  • op(n,rationalfunction) gives the first operand (numerator) and the second operand (the inverse of the denominator) of the rational function given as a ratio of two polynomials.

Here are some examples:

>> pretty(sym(maple('compoly( x^2+2*x*y-7*x+y^2-7*y+16 )')))
                                   2
                       16 - 7 y + y , y = y + x
>> pretty(sym(maple('compoly( x^4+4*x^3*y^3+6*x^2*y^6+4*x*y^9+y^12+x+y^3-1, {x,y})')))
                           2      3    4               3
             -1 - 3 y + 6 y  - 4 y  + y , y = x + 1 + y
>> pretty(sym(maple('indets( x*y + z/x )')))
                              {z, y, x}
>> pretty(sym(maple('e:=x^(1/2)+exp(x^2)+ f(9): indets(e), indets(e,function)')))
                            2    1/2                  2
                      {exp(x ), x   , x}, {f(9), exp(x )}
>> pretty(sym(maple('convert(x^2+3*x+4,horner,x)')))
                            4 + (3 + x) x
>> pretty(sym(maple('poly := y^2*x^2 + 2*y^2*x + 2*y*x^2 + 4*y*x + x^2 + 2*x: ')))
>> pretty(sym(maple('convert(poly,horner,x)')))
                    2               2
                (2 y  + 4 y + 2 + (y  + 2 y + 1) x) x
>> pretty(sym(maple('convert(poly,mathorner,x)')))
                       2               2
                    2 y  + 4 y + 2 + (y  + 2 y + 1) x &* x
>> pretty(sym(maple('convert(poly,horner,[x,y])')))
               (2 + (4 + 2 y) y + (1 + (2 + y) y) x) x
>> pretty(sym(maple('convert(x^2+4*x+4,sqrfree,x)')))
                                     2
                               (x + 2)
>> pretty(sym(maple('content(3*x*y+6*y^2,x ), content(3*x*y+6*y^2,[x,y])')))
                                3 y, 3
>> pretty(sym(maple('icontent(3*x*y+6*y^2)')))
                                   3
>> pretty(sym(maple('op(y^2*x^2 + 2*y^2*x + 2*y*x^2 + 4*y*x + x^2 + 2*x)')))
                      2  2     2         2          2
                     y  x , 2 y  x, 2 y x , 4 y x, x , 2 x

EXERCISE 3-9

Transform into square-free form with respect to the variable x the polynomial y2x3+ 2y2x2+ y2x+2yx3+ 4yx2+ 2yx. Also transform the same polynomial into square-free form with respect to the variable y. Finally, find the greatest common divisor of the coefficients of the polynomial with respect to all variables, with respect to the variable x only, and with respect to the variable y only.

>> pretty (sym (maple('poly:= y^2*x^3+2*y^2*x^2+y^2*x+2*y*x^3+4*y*x^2+2*y*x:'))))

>> pretty(sym(maple('convert(poly,sqrfree,x) ')))

                          2                 2
                        (y  + 2 y) x (x + 1)

>> pretty(sym(maple('convert(poly,sqrfree,y)')))

                                3      2    2
                          (x + x  + 2 x ) (y  + 2 y)

>> pretty(sym(maple('content(poly)')))

                                       1

>> pretty(sym(maple('content(poly,x)')))

                                          2
                                   2 y + y

>> pretty(sym(maple('content(poly,y)')))

                                  3      2
                                 x  + 2 x  + x

EXERCISE 3-10

Transform the second degree polynomial 9 x2 + 24 x + 16 into completed square form. Transform  x2 - 2xa + a2 + y2 - 2yb + b2 = 23 into completed square form with respect to the variable x. Transform the same expression into completed square form simultaneously with respect to both variables x and y, and with respect to the variable a.

>> pretty(sym(maple('with(student):completesquare(9*x^2 + 24*x + 16)')))

                                        2
                             9 (x + 4/3)

>> pretty(sym(maple('with(student):completesquare(x^2 - 2*x*a + a^2 +
   y ^ 2-2 * y * b + b ^ 2 = 23, x)')))

                             2    2            2
                      (x - a)  + y  - 2 y b + b  = 23

>> pretty(sym(maple('with(student):completesquare(x^2 - 2*x*a + a^2 +
   y^2-2*y*b + b^2 = 23, [x,y])')))

                              2          2
                       (y - b)  + (x - a)  = 23

>> pretty(sym(maple('with(student):completesquare(x^2 - 2*x*a + a^2 +
   y^2-2*y*b + b^2 = 23, a)')))

                               2    2            2
                        (a - x)  + y  - 2 y b + b  = 23

EXERCISE 3-11

Find the 10th Fibonacci and Euler polynomials in the variable x. Also find the degree 5 Bernstein polynomial in the variable x that approximates the functional operator yÆsin(y) in the interval [0,1].

>> pretty(sym(maple('with(combinat):fibonacci(10,x)')))

                         9      7       5       3
                        x  + 8 x  + 21 x  + 20 x  + 5 x

>> pretty(sym(maple('with(combinat):euler(10,x)')))

                  10      9       7        5        3
                 x   - 5 x  + 30 x  - 126 x  + 255 x  - 155 x

>> pretty(sym(maple('readlib(bernstein):bernstein(5,y->sin(y),x)')))

           2       3       4      5
(5 x - 20 x  + 30 x  - 20 x  + 5 x ) sin(1/5)

         2       3       4       5
  + (10 x  - 30 x  + 30 x  - 10 x ) sin(2/5)

        3       4       5                 4      5             5
 + (10 x  - 20 x  + 10 x ) sin(3/5) + (5 x  - 5 x ) sin(4/5) +x  sin(1)

EXERCISE 3-12

Given the following polynomial matrix:

image

Find its Hermite normal form in the variable x.

Find its Smith normal form in the variable x.

Find its Hermite normal form in the variable y.

Find its Smith normal form in the variable y.

>> maple('p:=x-1;q:=x+1;r:=x^2-1;s:=x^2+1'),
>> maple('M:=[[p,q],[r,s]]') ;
>> pretty(sym(maple('with(linalg):hermite(M,x)')))

                                 [x - 1    1]
                                 [          ]
                                 [  0      x]

>> pretty(sym(maple('with(linalg):smith(M,x)')))

                                 [1      0   ]
                                 [           ]
                                 [      2    ]
                                 [0    x  - x]

>> pretty(sym(maple('with(linalg):hermite(M,y),smith(M,y)')))

                              [1    0]  [1    0]
                              [      ], [      ]
                              [0    1]  [0    1]

3-7. Divisibility and Operations with Polynomials

MATLAB provides various tools for the analysis of divisibility. It can also perform a wide variety of operations on polynomials. We summarize below the commands it provides for these tasks (each of which requires the prior use of the maple command):

  • discrim(polynomial,variable) returns the discriminant of the polynomial with respect to the specified variable.
  • Discrim(polynomial,variable) returns the inert discriminant of the polynomial with respect to the specified variable.
  • Discrim(polynomial,variable) modn returns the inert discriminant of the polynomial with respect to the specified variable modulo n.
  • resultant(poly1,poly2,var) returns the resultant of the given polynomials with respect to the specified variable.
  • Resultant(poly1,poly2,var) returns the inert resultant of the given polynomials with respect to the specified variable.
  • Resultant(poly1,poly2,variable) mod n returns the inert resultant of the given polynomials with respect to the specified variable modulo n.
  • divide(poly1,poly2,name) determines whether poly1 is divisible by poly2, and if so assigns the specified name to the ratio.
  • Divide(poly1,poly2,name) determines whether poly1 is divisible by poly2, and if so assigns the specified name to the inert ratio.
  • Divide(polynomial1,polynomial2,name) mod n determines whether polynomial1 is divisible by polynomial2 modulo n, and if so, assigns the specified name to the inert ratio.
  • quo(poly1,poly2,var) returns the quotient polynomial of the ratio poly1/poly2 with respect to the variable var.
  • quo(poly1,poly2,var,name) returns the quotient polynomial of the ratio poly1/poly2 with respect to the variable var and gives the remainder the name name.
  • Quo(poly1,poly2,var) returns the inert quotient polynomial of the ratio poly1/poly2 with respect to the variable var.
  • Quo(poly1,poly2,var) mod n returns the quotient polynomial of the ratio poly1/poly2 modulo n with respect to the variable var.
  • rem(poly1,poly2,variable) returns the remainder of the division of two polynomials in the given variable.
  • rem(poly1,poly2,var,name) returns the remainder of the division of the two polynomials and gives the quotient polynomial the name name.
  • Rem(poly1,poly2,variable) returns the inert remainder of the division of two polynomials with respect to the given variable.
  • rem(poly1,poly2,var) mod n returns the remainder of the division of two polynomials with respect to the given variable modulo n.
  • readlib(fixdiv): fixdiv(poly,var) computes the fixed divisor of the given polynomial, i.e. the largest integer that divides poly(n) for all integers n.
  • gcd(poly1,poly2) returns the greatest common divisor of two polynomials with rational coefficients.
  • gcd(poly1,poly2,name1,name2) returns the greatest common divisor of two polynomials with rational coefficients and assigns name1 to poly1/gcd(poly1,poly2) and name2 to poly2/gcd(poly1,poly2).
  • gcdex(poly1,poly2,var,name1,name2) returns the greatest common divisor of two polynomials in var with rational coefficients and assigns name1 to poly1/gcd(poly1,poly2) and  name2 to poly2/gcd(poly1,poly2) using the extended Euclidean algorithm.
  • gcdex(poly1,poly2,poly3,var,name1,name2) returns the greatest common divisor of two polynomials in var with rational coefficients and assigns to name1 and name2 expressions such as poly3 = name1 * poly1 + name2 * poly2.
  • Gcd(poly1,poly2) returns the inert form of the greatest common divisor of two polynomials with rational coefficients.
  • Gcd(poly1,poly2) mod n returns the greatest common divisor modulo n of polynomials with rational coefficients.
  • Gcdex(poly1,poly2,var,name1,name2) returns the inert form of the greatest common divisor of the polynomials in var with rational coefficients and assigns name1 to poly1/gcd(poly1,poly2) and  name2 to poly2/gcd(poly1,poly2) using the extended Euclidean algorithm.
  • Gcdex(poly1,poly2,var,name1,name2) mod n returns the greatest common divisor modulo n of polynomials in var with rational coefficients and assigns name1 to poly1/gcd(poly1,poly2) and name2 poly2/gcd(poly1,poly2) using the extended Euclidean algorithm.
  • lcm(poly1,...,polyn) returns the least common multiple of the specified polynomials.
  • ispoly(expression,n,variable) determines whether the expression is a polynomial of degree n in the specified variable. n can be replaced by 'linear', 'quadratic', 'cubic' or 'quartic' for n = 1, 2, 3, 4, respectively.
  • ispoly(expression,n,name0,...,namen) determines whether the expression is a polynomial of degree n in the specified variable and assigns the coefficient of degree i to namei for i = 1... n.
  • norm(polynomial,n,variable) calculates the nth norm of the polynomial, whose value is Σ (abs (c))n, where c = coeffs(polynomial,variable)1/n.
  • norm(polynomial,n) calculates the nth norm of the polynomial with respect to indets(polynomial).
  • norm (poly,infinity,variable) computes the infinity norm of the polynomial in the given variable (the coefficient of the polynomial with greatest absolute value).
  • maxnorm(polynomial) calculates the infinity norm of the fully expanded polynomial.
  • readlib(maxorder): maxorder(RootOfexpression) returns a basis for the  field extension determined by the RootOf expression.
  • readlib (maxorder): maxorder({RootOfexpression1,..., RootOfexpressionn}) returns a basis for the field extension determined by the given set of RootOf expressions.
  • minpoly(algebraicnum,n) computes a polynomial of degree n or less with small integer coefficients; the given algebraic number is one of its roots.
  • readlib(lattice): minpoly(algebraicnum,n,expression) computes a polynomial of degree n or less with small integer coefficients such that the given algebraic number is one of its roots, up to an accuracy given by expression.
  • Nextprime(polynomial,var) the inert command that finds the irreducible polynomial in the variable var, which is the next highest with respect to the given polynomial.
  • Nextprime(poly,var,ext) the inert command that finds the irreducible polynomial in the variable var, over the algebraic extension defined by expr, which is the next highest with respect to the given polynomial.
  • Nextprime(poly,var) mod n the inert command that finds the irreducible polynomial in the variable var, modulo n, which is the next highest with respect to the given polynomial.
  • Prevprime(polynomial,var) the inert command that finds the irreducible polynomial in the variable var which is the next lowest with respect to the given polynomial.
  • Prevprime(poly,var,ext) the inert command that finds the irreducible polynomial in the variable var which is the next lowest with respect to the given polynomial over the algebraic extension defined by expr.
  • Prevprime(poly,var) mod n the inert command that finds the irreducible polynomial, modulo n, in the variable var which is the next lowest with respect to the given polynomial over the algebraic extension defined by expr.
  • modpol(expr,poly,var,p) evaluates the rational expression expr over Q in the variable var with respect to the quotient space Zp[var]/poly(var), where p is prime and poly is a polynomial in var over Q.
  • Power(polynomial,n) returns the nth inert power of the polynomial.
  • Power(polynomial,n) mod m returns the nth inert power of the polynomial modulo m.
  • Powmod(poly1,n,poly2,var) gives the inert remainder Rem((poly1)n, poly2) with respect to var.
  • Powmod(poly1,n,poly2,var) mod n gives the inert remainder ((poly1)n, poly2)with respect to var modulo n.
  • prem(poly1,poly2,var) returns the pseudo-remainder of the quotient of polynomials poly1/poly2 with respect to the variable var.
  • prem(poly1,poly2,var,namen,nameq) returns the value rem that satisfies the condition namen * poly1 = poly2 * nameq + rem.
  • Prem(poly1, poly2,var) gives the inert pseudo-remainder of the quotient of polynomials poly1/poly2 with respect to the variable var.
  • Prem(poly1,poly2,var) mod n gives the pseudo-remainder modulo n of the quotient of polynomials poly1/poly2 with respect to the variable var.
  • sprem(poly1,poly2,var) returns the sparse pseudo-remainder of the quotient of polynomials poly1/poly2 with respect to the variable var.
  • sprem(poly1,poly2,var,namen,nameq) returns the value sprem that fulfills the condition namen* poly1 = poly2 * nameq + sprem.
  • Sprem(poly1,poly2,var) gives the inert sparse pseudo-remainder of the quotient of  polynomials poly1/poly2 with respect to the variable var.
  • Sprem(poly1,poly2,var) mod n gives the inert sparse pseudo-remainder of the quotient, modulo n, of  polynomials poly1/poly2 with respect to the variable var.
  • chrem([poly1,...,polyn],[m1,...,mn]) finds the polynomial p such that p mod mj = polyj j = 1... n.
  • primpart(polynomial,variable) gives the primitive part of the polynomial in the given variable. The primitive part is the polynomial divided by the greatest common divisor of its coefficients.
  • primpart(polynomial) gives the primitive part of the polynomial with respect to all of its variables.
  • primpart(polynomial,{var1,...,varn}) or primpart(polynomial,[var1,...,varn]) gives the primitive part of the polynomial with respect to the specified variables.
  • Primpart(polynomial,variable) gives the primitive part of the polynomial in the variable given in inert form.
  • Primpart(polynomial,variable) mod n gives the primitive part of the polynomial in the given variable in inert form, modulo n.
  • Primitive(polynomial) determines whether the univariate polynomial is primitive.
  • Primitive(polynomial) mod n determines whether the univariate polynomial is primitive modulo n.
  • Primfield({expr1,...,exprn}) gives the inert form of the algebraic extension given by the RootOf expressions expr1,...,exprn.
  • Primfield({expr1,...,expren}) mod n gives the inert form, modulo n, of the algebraic extension given by the RootOf expressions expr1,...,exprn.
  • Primfield(expr1,expr2) gives the primitive element of the extension defined by the first set of RootOf expressions over the extension defined by the second set of RootOf expressions.
  • randpoly(variable) creates a univariate random polynomial of degree 6 in the specified variable.
  • randpoly({variable1,...,variablen}) or randpoly([variable1,...,variablen]) creates a multivariate random polynomial in the variables specified.
  • randpoly(variable,coeffs=rand(a..b)) creates a polynomial whose coefficients are random numbers between a and b.
  • randpoly(variable,expons=rand(n)) creates a polynomial whose exponents are random numbers between 0 and n-1.
  • randpoly(variable,terms=n) creates a random polynomial of n terms.
  • randpoly(variable,dense) creates a dense random polynomial.
  • randpoly(variable,degree=n) creates a dense random polynomial of degree n. In case of conflict, degree takes precedence over terms.
  • Randpoly(n,variable) creates an inert random polynomial of degree n in the given variable.
  • Randpoly(n,variable) mod m creates an inert random polynomial of degree n in the given variable, modulo m.
  • Randprime(n,variable) creates an inert random irreducible and monic polynomial of degree n.
  • Randprime(n,variable) mod p creates an irreducible and monic random polynomial of degree n modulo p (prime).
  • Randprime(n,variable,expr) creates a random irreducible monic polynomial of degree n over the algebraic extension defined by expr.
  • readlib(ratrecon): ratrecon(poly1,poly2,variable,n1,n2,name1,name2) assigns name1 and name2 such that name1/name2 = poly1 mod poly2. If the allocation can be made, the command returns true, and if it can’t, it returns false. The limits of the assigned values are such that degree(name1)≤ n1 and degree(name2) ≤ n2.
  • readlib(iratrecon): iratrecon(m1,m2,n1,n2,name1,name2) assigns name1 and name2 such that name1/name2 = m1 mod m2 with abs(name1)<n1, abs(name2)<n2.
  • Ratrecon(poly1,poly2,variable,n1,n2,name1,name2) assigns in inert form name1 and name2 such that name1/name2 = poly1 mod poly2.
  • Ratrecon(poly1,poly2,variable,n1,n2,name1,name2) mod n assigns, modulo n, name1 and name2 such that name1/name2 = poly1 mod poly2.
  • readlib(recipoly):recipoly(polynomial,variable) determines whether the polynomial is self-reciprocal.
  • readlib(recipoly): recipoly(poly,var,name) assigns the specified name to the polynomial p of degree degree(poly,var)/2 that meets the condition  var ^ (degree(poly,var)/2) * p(var+1/var) = poly.
  • readlib(translate): translate(polynomial,variable,number) translates the polynomial into the polynomial in the new variable given by variable+number.
  • ztrans(expr,var1,var2) finds the z-transform of expr(var1) with respect to var2.
  • readlib(ztrans): invztrans(expression,var1,var2) returns the inverse z-transform of the expression given in the old variable var1, with the result being an expression based on the new variable var2.
  • Eval(poly,var=exp) evaluates in inert form the polynomial with the given variable replaced by expr.
  • Eval(poly,var=exp) mod n evaluates the polynomial with the given variable replaced by expr modulo n.
  • Eval(polynomial,{varible1=expr1,...,variablen=exprn}) evaluates in inert form the polynomial with the given variables replaced by expr1,...,exprn.
  • grading(Fnc(expr1,...,exprn)) evaluates the inert command or function Fnc, whose parameters are the given expressions, over the minimal algebraic closure of the field defined by their coefficients. This applies to inert commands such as Factor, Factors, Afactor, Afactors, Norm, Content, Gcd, Gcdex, Prem, Primfield, Quo, Rem, Resultant, Sprem, Sqrfree, independence, and so on.
  • readlib(evalgf):evalgf(Fnc(expr1,...,exprn),n) evaluates the inert command or function Fnc, whose parameters are the specified expressions, over the minimal algebraic extension of the finite field Zn.

Here are some examples. First, we find the discriminant of the polynomial ax2+ bx:

>> pretty(sym(maple('p := a*x^2 + b*x + c: discrim(p,x)')))
                                     2
                             -4 c + b

Now we calculate the resultant of several polynomials:

>> pretty(sym(maple('resultant(a*x+b,c*x+d,x),   resultant((x+a)^5,(x+b)^5,x)')))
                                              25
                        -c b + d a,   (-a + b)
>> pretty(sym(maple('Resultant(2*x+1, 3*x+4, x) mod 7')))
                                  5
>> pretty(sym(maple('r := x + RootOf(_Z^2-2): s := RootOf(_Z^2-2)*x + 1:
   evala(Resultant(r,s,x))')))
                                  -1

Next we check divisibility among polynomials, and in the positive case, find the ratios:

>> pretty(sym(maple('divide(x^3-y^3, x-y, q),q')))
                                  2          2
                         true,   x  + x y + y
>> pretty(sym(maple('Divide(x^3+x^2+2*x+3,x+2,q) mod 5,q')))
                                 2
                          true, x  + 4 x + 4

Next we find quotients and remainders of division between polynomials:

>> pretty(sym(maple('rem(x^3+x+1, x^2+x+1, x, q), q')))
                             x + 2, x - 1
>> pretty(sym(maple('quo(x^3+x+1, x^2+x+1, x) ')))
                                x - 1
>> pretty(sym(maple('a := x^4+5*x^3+6: b := x^2+2*x+7: r := Rem(a,b,x,q) mod 13, q')))
>> maple r
ans =

5*x+6, x^2+3*x

EXERCISE 3-13

Find the greatest common divisor and least common multiple of the polynomials x2- y2 and x3- y3, and also the polynomials x+2 and x+3 modulo 7. Find the greatest common divisor for each of the sets of polynomials {x3- 1, x2 - 1} and {x2+ x + 1, x2- x + 1}, identifying the elements of Euclid’s algorithm. Also find the greatest common divisor modulo 11 of the polynomials x2 + 3 x + 2 and x2+ 4 x + 3, identifying the elements of Euclid’s algorithm.

>> pretty(sym(maple('gcd(x^2-y^2,x^3-y^3),lcm(x^2-y^2,x^3-y^3)')))

                                  4      3      3    4
                         -y + x, x  - x y  + y x  - y

>> pretty(sym(maple('gcd(x+2,x+3) mod 7, lcm(x+2,x+3) mod 7')))

                                    2
                                1, x  + 5 x + 6

>> pretty(sym(maple('gcdex(x^3-1,x^2-1,x,s,t),s,t')))

                             x - 1,   1,   -x

>> pretty(sym(maple('gcdex(x^2+x+1,x^2-x+1,x,u,v),u,v')))

                          1, 1/2 - 1/2 x, 1/2 + 1/2 x

>> pretty(sym(maple('Gcd(x^2+3*x+2,x^2+4*x+3,f,g) mod 11, f, g')))

                         1 + x,    x + 2,    x + 3

EXERCISE 3-14

Find the 1, 2 and infinity norms of the polynomial x-3y. Also find the third and fourth powers of the polynomial x + 1 modulo 2.

>> pretty(sym(maple('norm(x-3*y,1),norm(x-3*y,2),norm(x-3*y,infinity)')))

                                     1/2
                              4,   10   ,   3

>> pretty(sym(maple('Power(x+1,3) mod 2, Power(x+1,4) mod 2')))

                        3    2           4
                       x  + x  + x + 1, x  + 1

EXERCISE 3-15

Find the polynomials r, m and q in the variable x such that

m(x4+ 1) = q(cx4+1) + r.

There are two solutions to the problem; one via the pseudo-remainder between the polynomial x4+ 1 and cx2+ 1, and the other via the sparse pseudo-remainder between those polynomials.

>> pretty(sym(maple('a := x^4+1: b := c*x^2+1: r := prem(a,b,x,m,q)')))
>> pretty(sym(maple('r,m,q')))

                          2        3   2  2
                      c (c  + 1), c , x  c  - c

>> maple('restart') ;
>> pretty(sym(maple('a := x^4+1: b := c*x^2+1: r := sprem(a,b,x,m,q)')))
>> pretty(sym(maple('r,m,q')))

                          2       2     2
                         c  + 1, c , c x  - 1

EXERCISE 3-16

Find the primitive part of the polynomial 4xy + 6y2 and x/a-1/2 in the variable x. Also find the primitive part of the polynomial x (y+4) + y2 + 4 in the variable x modulo 5.

>> maple ('restart')
>> pretty(sym(maple('primpart(-4*x*y + 6*y^2, x), primpart(x/a - 1/2,x)')))

                                              3, - 2 x, 2 x - a

>> pretty(sym(maple('Primpart(x * (y+4) + y ^ 2 + 4 x) mod 5')))

     x + y + 1

EXERCISE 3-17

Perform the following tasks concerning random polynomials:

Create a random polynomial in x of 6 terms.

Create a random 20 term polynomial in the variables x and y.

Create a random polynomial in x, cos(x) and sin(x).

Create a polynomial with random coefficients between 1 and 100.

Create a polynomial with random exponents between -5 and 5.

>> pretty(sym(maple('randpoly(x)')))

                   5       4       3       2
              -85 x  - 55 x  - 37 x  - 35 x  + 97 x + 50

>> pretty(sym(maple('randpoly([x, y], terms = 20)')))

                                2         5      4       3       2
56 + 49 x + 63 y + 57 x y - 59 x  y + 45 x  - 8 x  - 93 x  + 92 x

           3         2       3         2  2         3      4
     + 43 y  - 62 x y  + 77 x  y + 66 x  y  + 54 x y  - 5 x  y

           3  2       2  3         4       4       5
     + 99 x  y  - 61 x  y  - 50 x y  - 12 y  - 18 y

>> pretty(sym(maple('randpoly([x, sin(x), cos(x)])')))

                                                      2
-47 x - 61 x cos(x) + 41 x sin(x) cos(x) - 58 x cos(x)

                       3            3       2
     - 90 sin(x) cos(x)  + 53 sin(x)  cos(x)

>> pretty(sym(maple('randpoly(x,coeffs=rand(1..100))')))

                  5       4       3       2
              82 x  + 71 x  + 98 x  + 64 x  + 77 x + 39

>> pretty(sym(maple('randpoly(z,expons = rand(-5..5))')))

                      82     23         5
                     ---- + ---- + 104 z  + 88 z
                       5     z
                      Z

EXERCISE 3-18

Change the variable x of the polynomial x2 to the variable x + 1. Make the change of variable x = r1/3 in the expression 3xln(x3) and also the change of variable sin(x) = y in the expression sin(x) / (1-sin(x))1/2.

The first change of variable is a simple translation of a polynomial variable, so it will be done via the command translate, but the other two changes involve general algebraic expressions, so we will use the command subs as described in the previous chapter.

>> pretty(sym(maple('readlib(translate):translate(x^2,x,1)')))

                                            2
                                 1 + 2 x + x

>> pretty(sym(maple('subs(x=r^(1/3), 3*x*log(x^3))')))

                                    1/3
                                 3 r    log(r)

>> pretty (sym (maple ('subs (y = sin (x),sin (x) / (1 - sin (x)) ^(1/2))')))

                                      y
                                  ----------
                                         1/2
                                  (1 - y)

EXERCISE 3-19

Find the reciprocal polynomial of the polynomial x4 + x3 + x + 1. Also calculate the resultant of the polynomial and its reciprocal.

>> pretty(sym(maple('readlib(recipoly):recipoly(x^4+x^3+x+1,x,'p'),p')))

                                            2
                          true,   -2 + x + x

>> pretty(sym(maple('resultant(x^4+x^3+x+1,x^2+x-2,x)')))

                                      28

3-8. Interpolation and Polynomial Fitting

MATLAB provides several commands for polynomial interpolation and fitting that we will study next:

  • polyfit(x,y,n) gives the vector of coefficients of the polynomial p(x) of degree n in x which best fits the data (xi,yi) in the least-squares sense (p(xi) = yi).
  • Yi = interp1(X,Y,Xi,'method') gives the vector Yi such that (Xi,Yi) is the total set of points found by interpolation between the given points (X, Y). The option method can take the values linear, spline, or cubic, depending on whether the interpolation is linear (the default option), staggered, or cubic (for xi uniformly separated). One-dimensional interpolation.
  • Zi = interp2(X,Y,Z,Xi,Yi,'method') gives the vector Zi such that (Xi,Yi,Zi) is the total set of points found by interpolation between the given points (X,Y,Z). The option method can take the value linear or cubic, depending on whether the interpolation is linear (the default) or cubic (for xi uniformly separated). Two-dimensional interpolation.
  • Zi = griddata(X,Y,Z,Xi,Yi) gives the vector Zi that determines the interpolation points (Xi,Yi, Zi) between the given points (X, Y, Z). A method of inverse distance is used to interpolate.
  • Y = interpft(X,n) gives the vector Y containing the values of the periodic function X sampled at n equally spaced points. The original vector x is transformed to the domain of Fourier transform frequencies using the Fast Fourier transform (FFT) algorithm. It satisfies  nlength(X).
  • maple('interp([exprx1,...,exprxn+1],[expry1,...,expryn+1],var)') returns a polynomial in the specified variable of degree at least n that represents the interpolated polynomial for points from [exprx1,expry1] to [exprxn+1,expryn+1]. The coordinates of the points must all be different.
  • maple('Interp([exprx1,...,exprxn+1], [expry1,...,expryn+1], variable)') returns in inert mode a polynomial in the specified variable of degree at least n that represents the interpolated polynomial for points from [exprx1, expry1] to [exprxn+1,expryn+1]. The coordinates of the points must all be different.
  • maple('Interp([exprx1,...,exprxn+1], [expry1,...,expryn+1], variable) mod m') returns a polynomial modulo m in the specified variable of degree at least n that represents the interpolated polynomial for points from [exprx1, expry1] to [exprxn+1,expryn+1]. The coordinates of the points must all be different.
  • maple('readlib(thiele): thiele([exprx1,...,exprxn],[expry1,...,expryn],variable)') finds an expression in the given variable that represents the entire function resulting in Thiele interpolation points (exprxi,expryi) i = 1... n.

EXERCISE 3-20

Calculate the interpolated degree 2 polynomial passing through the points (- 1,4), (0,2) and (1,6) which is the best fit in the least-squares sense.

>> x=[-1,0,1];y=[4,2,6];p=poly2sym(polyfit(x,y,2))

p =

3 * x ^ 2 + x + 2

EXERCISE 3-21

Represent 200 points of cubic interpolation between the points (x,y) given by the values that the exponential function e ^ x takes at 20 equally spaced x values between 0 and 2. Also represent the difference between the function e ^ x and its approximation by interpolation. Use cubic interpolation.

First, we define the 20 given points (x, y), for x values equally spaced between 0 and 2:

>> x = 0:0.1:2;
>> y = exp(x);

Now we find 200 points (xi, yi) using cubic interpolation, equally spaced between 0 and 2, and plot them on a graph, together with the 20 initial points (x, y) (indicated by asterisks). See Figure 3-1:

>> xi = 0:0.01:2;
>> yi = interp1(x,y,xi,'cubic'),
>> plot(x,y,'*',xi,yi)

We now graphically represent the difference between the exact function y = e ^ x and the function obtained by the above interpolation. In the case of zero error, the graph would be a horizontal line coinciding with the x axis. See Figure 3-2.

>> zi=(exp(xi));
>> di=yi-zi;
>> plot(xi,di)

EXERCISE 3-22

Find 25 interpolation points of the parametric function X = cos(t), Y = sin(t), Z = tan(t) for values of t between 0 and π/6, based on the set of points defined for values of t = iπ/6 with 0 ≤ i ≤ 6.

First, we define the 25 given points (x, y, z), equally spaced between 0 and π / 6.

>> t = 0: pi/150: pi/6;
>> x = cos (t); y = sin (t); z = tan (t);

Now we find the 25 points of interpolation (xi, yi, zi), for values of the parameter t equally spaced between 0 and π /6.

>> xi = cos (t); yi = sin (t);
>> zi = griddata(x,y,z,xi,yi);
>> points = [xi, yi, zi']

points =

    1.0000 0      0.0000
    0.9998 0.0209 0.0161
    0.9991 0.0419 0.0367
    0.9980 0.0628 0.0598
    0.9965 0.0837 0.0836
    0.9945 0.1045 0.1057
    0.9921 0.1253 0.1269
    0.9893 0.1461 0.1480
    0.9860 0.1668 0.1692
    0.9823 0.1874 0.1907
    0.9781 0.2079 0.2124
    0.9736 0.2284 0.2344
    0.9686 0.2487 0.2567
    0.9632 0.2689 0.2792
    0.9573 0.2890 0.3019
    0.9511 0.3090 0.3249
    0.9444 0.3289 0.3483
    0.9373 0.3486 0.3719
    0.9298 0.3681 0.3959
    0.9219 0.3875 0.4203
    0.9135 0.4067 0.4452
    0.9048 0.4258 0.4706
    0.8957 0.4446 0.4969
    0.8862 0.4633 0.5236
    0.8763 0.4818 0.5505
    0.8660 0.5000 0.5774

EXERCISE 3-23

Find 30 interpolation points (xi, yi) for the periodic function y = sin(x) for values of x that are equally spaced, interpolating them between values of (x, y) given by y = sin(x) for 20 x values evenly spaced in the interval (0,2π), and using the interpolation method based on the fast Fourier transform (FFT).

First, we define the 20 x values equally spaced between 0 and 2π:

>> x =(0:pi/10:2*pi);

Now we find the 30 interpolation points (x, y).

>> y = interpft(sin(x), 30);
>> points = [y', (asin(y))']

points =

   0.0000 0.0000
   0.1878 0.1890
   0.4499 0.4667
   0.6070 0.6522
   0.7614 0.8654
   0.9042 1.1295
   0.9618 1.2935
   0.9963 1.4848
   0.9913 1.4388
   0.9106 1.1448
   0.8090 0.9425
   0.6678 0.7312
   0.4744 0.4943
   0.2813 0.2852
   0.0672 0.0673
  -0.1640 - 0.1647
  -0.3636 - 0.3722
  -0.5597 - 0.5940
  -0.7367 - 0.8282
  -0.8538 - 1.0233
  -0.9511 - 1.2566
  -1.0035 - 1.5708 - 0. 0837i
  -0.9818 - 1.3799
  -0.9446 - 1.2365
  -0.8526 - 1.0210
  -0.6902 - 0.7617
  -0.5484 - 0.5805
  -0.3478 - 0.3553
  -0.0807 - 0.0808
   0.0086   0.0086

EXERCISE 3-24

Find the degree 3 polynomial that best fits the set of points (i, i2) for 1≤ i ≤ 7, in the least-squares sense. Find the value of the polynomial at x = 10 and graphically represent the fitted curve.

>> x=(1:7);y=[1,4,9,16,25,36,49];p=poly2sym(polyfit(x,y,2))

p =

4503599627370495/4503599627370496 * x ^ 2 +
310800181380337/79228162514264337593543950336 * x-3598276744230861/316912650057057350374175801344

Now we calculate the numerical value of the polynomial p at x = 10.

>> numeric(subs(p,10))

ans =

   100

We can also approximate the coefficients of the polynomial p to 5 digits.

>> vpa(p,5)

ans =

1.00000 * x ^ 2 + 3 9228e-15 * x-1. 1354e-14

Figure 3-3 shows the graph of the fitted curve.

>> ezplot(p,[-5,5])

EXERCISE 3-25

Find the interpolated degree 2 polynomial passing through the points (-1,4), (0,2) and (1,6). Find the interpolated polynomial modulo 3 and, finally, perform Thiele interpolation for this case.

>> interp([-1,0,1],[4,2,6],x);

                                2
                             3 x  + x + 2

>> Interp([-1,0,1],[4,2,6],x) mod 3;

                                x + 2

>> readlib(thiele):thiele([-1,0,1],[4,2,6],x);

                                  x + 1
                          4 + -------------
                              - 1/2 + 3/2 x

3-9. Galois Extensions

The Maple program has commands which enable you to work with the Galois theory of finite fields and their extensions. The syntax of these commands is as follows:

  • maple('galois(polynomial)') returns the Galois group of the given rational univariate irreducible polynomial of degree less than or equal to 8. It returns a list of three expressions: the first is the name of the Galois group and includes a plus sign (+) as the first character if the group is even and (-) if it is odd; the second is an integer representing the order of the group, and the third is a set of strings representing the group generators.
  • maple('readlib(GF):GF(p,n,polynomial)') returns a module of procedures and constants for working in the finite Galois field with pn elements defined by the field extension GF(p)[x]/polynomial. The polynomial is irreducible of degree n modulo p (prime p). Once this has been done one can make use of the operator T to implement various operations in the Galois field.
  • T[input] and T[output] convert between an integer in the range 1.. pn and its corresponding polynomial in the Galois field. Alternatively T[ConvertIn] and T[ConvertOut] convert an element of the Galois field to a Maple sum of products. T['+'], T['-'], T['*'], T['^'], T['inverse'] and T['/'] execute the specified operations in the Galois field. T[random] returns a random element of the Galois field. T[0] and T[1] represent the additive and multiplicative inverse, respectively. T[trace], T[norm] and T[order] compute the trace, norm and order for elements of the Galois field. T[PrimitiveElement] returns a primitive element of the Galois field. T[isPrimitiveElement] determines whether an element is primitive. T[extension] returns the polynomial extension used for the Galois field.

EXERCISE 3-26

Find the Galois group for each of the univariate polynomials x4 + x + 1, t5 - 5t + 12, x5 + 2 and x7 + 4x5 - 3x2 + 5.

First, we check if the polynomials are irreducible; if so, we will calculate the Galois groups.

>> pretty(sym(maple('irreduc(x^4+x+1),irreduc(t^5-5*t+12),irreduc(x^5+2),         irreduc(x^7+4*x^5- 3*x^2+5)')))

                        true, true, true, true

>> pretty(sym(maple('galois(x^4+x+1)')))

                      S4, 24, {(1 2 3 4), (1 2)}

>> pretty(sym(maple('galois(t^5-5*t+12)')))

                  +D5, 10, {(1 2 3 4 5), (2 5)(3 4)}

>> pretty(sym(maple('galois(x^5+2)')))

                  F20, 20, {(1 2 3 4 5), (2 3 5 4)}

>> pretty(sym(maple('galois(x^7+4*x^5-3*x^2+5)')))

                  S7, 5040, {(1 2 3 4 5 6 7), (1 2)}

EXERCISE 3-27

Consider the polynomial q = α4 + α + 1. Verify that it is irreducible over the integers and over the integers modulo 2. Consider the finite Galois field GF(24) and the Galois extension GF(2)[x]/(q). Perform the operations 3 + 4, 3 * 4 and 34 in this field. Convert the integer 12Œ[0,24- 1] to the corresponding element in the finite Galois field GF(24), and then do the reverse conversion. Convert the polynomial α to a Maple sum of products ‘a’ in the finite Galois field GF(24). Calculate α2 and α4 and check if a is a primitive element in GF(24). Find the corresponding value of x =a8 in the interval [0,24- 1] and its polynomial form in the Galois extension.

>> pretty(sym(maple('irreduc(alpha^4+alpha+1)')))

                                 true

>> pretty(sym(maple('Irreduc(alpha^4+alpha+1) mod 2')))

                                 true

>> pretty(sym(maple('readlib(GF):')))
>> pretty(sym(maple('G16 := GF(2,4,alpha^4+alpha+1):')))
>> pretty(sym(maple('G16[`+`](3,4),   G16[`*`](3,4),   G16[`^`](3,4)')))

                               5,   4,   3

>> pretty(sym(maple('G16[input](12)')))

                            1000100000000

>> pretty(sym(maple('G16[output](")')))

                                  12

>> pretty(sym(maple('a := G16[ConvertIn](alpha)')))
>> pretty(sym(maple('a')))

                                10000

>> pretty(sym(maple('G16[`*`](a,a),   G16[`^`](a,4)')))

                           100000000,  10001

>> pretty(sym(maple('G16[isPrimitiveElement](a)')))

                                 true

>> pretty(sym(maple('x := G16[`^`](a,8)')))
>> pretty(sym(maple('x')))

                             100000001

>> pretty(sym(maple('G16[output](x)')))

                                  5

>> pretty(sym(maple('G16[ConvertOut](x)')))

                                   2
                              Alpha + 1

EXERCISE 3-28

Consider the polynomial q = b5 + 7b4 + b2 + b+1. Check that it is irreducible over the integers and over the integers modulo three. Consider the finite Galois field GF(35) and the Galois extension GF(3)[x]/(q). Calculate the product (b5+ 1)(b3+ b2+ 1) in the Galois extension and calculate its inverse.

First, we check that the polynomial is irreducible over the integers and over the integers modulo 3.

>> pretty(sym(maple('irreduc(b^5+7*b^4+b^2+b+1),irreduc(b^5+7*b^4+ b^2+b+1) mod 3')))

                                 true, true

Then we transform the given polynomial to its corresponding value in the Galois field GF(35) and find the stated product in this field.

>> pretty(sym(maple('readlib(GF):')))
>> pretty(sym(maple('G243 := GF(3,5,b^5+7*b^4+b^2+b+1):')))
>> pretty(sym(maple('a1:=G243[ConvertIn](b^5+1)')))
>> pretty(sym(maple('a1')))

                                 20000000200020000

>> pretty(sym(maple('a2:=G243[ConvertIn](b^3+b^2+1)')))
>> pretty(sym(maple('a2')))

                                 1000100000001

>> pretty(sym(maple('prod1:=G243[`*`](a1,a2)')))
>> pretty(sym(maple('prod1')))

                                 20000000100000001

Finally, we convert the value to its corresponding value in the extension GF(3)[x]/(q).

>> pretty(sym(maple('prod2:=G243[ConvertOut](prod1)')))
>> pretty(sym(maple('prod2')))

                                   4    2
                                2 b  + b  + 1

To find the inverse of the product, we first convert it to the corresponding element in the Galois field GF(35). After finding the inverse we find the corresponding element in the extension GF(3)[x]/(q).

>> pretty(sym(maple('inv1:=G243[inverse](prod1)')))
>> pretty(sym(maple('inv1')))

                         20000000200010001

>> pretty(sym(maple('G243[`*`](prod1,inv1)')))

                                  1

>> pretty(sym(maple('inv2:=G243[ConvertOut](inv1)')))
>> pretty(sym(maple('inv2')))

                                   4      2
                                2 b  + 2 b  + b + 1

3-10. Gröbner Bases

Gröbner bases are used in the solution and analysis of solutions of systems of polynomial equations. The related MATLAB commands are as follows:

  • maple('with(groebner)') loads into memory the MATLAB package that contains commands for working with Gröbner bases.
  • maple('finduni(variable,[polynomial1,...,polynomin],[var1,...,varn])') finds the univariate polynomial in the given variable of least degree in the ideal generated by the specified set of polynomials for the given variables.
  • maple('finduni(variable,[variable],[poly1,...,polym])') constructs the Gröbner basis for the given polynomials in all of their variables.
  • maple('finite([polynomial1,...,polynomialm],[variable1,...,variablen])') determines whether the specified set of polynomials has a finite number of solutions for the set of specified variables. If the answer is True, one can apply the command finduni.
  • maple('finite([poly1,..,polyn])') determines whether the specified set of polynomials has a finite number of solutions with regard to all its variables.
  • maple('solvable([poly1,...,polym],[var1,...,varn])') determines whether the given system of polynomials is solvable (algebraically consistent) with respect to the given set of variables.
  • maple('solvable([poly1,...,polym])') determines whether the given system of polynomials is solvable with respect to all of its variables.
  • maple('solvable([poly1,...,polym,],[var1,...,varn],tdeg)') determines whether the given system of polynomials is solvable with respect to the set of variables using total degree.
  • maple('gsolve([poly1,..., polym])') or maple('gsolve({poly1,...,polym})')) gives a reduced Gröbner basis for the given set of polynomials with respect to all of the variables. Returns a list of lists where each list is a small subsystem of polynomials identical to the original system roots. It can be applied to each reduced basis solve. Essentially, gsolve prepares the algebraic system for solution.
  • maple('gsolve([poly1,...,polym],{polyr1,...,polyrn})') prevents the roots of the second set of polynomials from being considered in the computation of Gröbner bases.
  • maple('gsolve([poly1,...,polyn],[var1,...,varn],{polyr1,...,polyrn})') specifies that the presentation of the specified variables will be used in the computation of Gröbner bases.
  • maple('gbasis([poly1,...,polym],[var1,...,varn])') returns a minimal reduced Gröbner basis for the specified polynomials in the given variables. The result is a list of polynomials.
  • maple('gbasis([poly1,...,polym],[var1,...,varn],plex)') gives a Gröbner basis in which the polynomial terms are sorted lexicographically.
  • maple('gbasis([poly1,...,polym],[var1,...,varn],tdeg)') gives a Gröbner basis in which the polynomial terms are arranged by total degree.
  • maple('normalf(polynomial,[poly1,...,polym],[var1,...,varn])') gives the full reduced form of the given polynomial with respect to the Gröbner basis represented by the given polynomials in the specified variables. You can use the plex option to sort the results into lexicographic order.
  • maple('leadmon(polynomial,[var1,...,varn])') returns the leading monomial of the given polynomial with respect to the specified variables. It produces a list of two elements. The first element is the coefficient of the monomial and the second is the rest of the monomial. You can use the Plex option to sort the results into lexicographic order.
  • maple('spoly(poly1,poly2,[var1,...,varn])') returns the s-polynomial of poly1 and poly2 with respect to the given variables.

EXERCISE 3-29

Consider the following system of three polynomials: x2 - 2xz + 5, xy2 + yz3, 3y2 - 8z3.  Test whether the system is solvable with respect to its three variables and has a finite number of solutions. Find a Gröbner basis for such a system and from that try to solve it. Also find a minimal reduced Gröbner basis in lexicographical order and total order.

First, we try to solve the system directly, but we find that this is not possible; only an approximate solution can be found.

>> pretty(sym(maple('solve({x^2-2*x*z+5=0,x*y^2+y*z^3=0,3*y^2-8*z^3=0})')))

              2
{x = RootOf(_Z + 5), y = 0, z = 0}, {}
                2          5        4
    x = - 3/4 %1 - 9/20% 1 + 12/5% 1,

              2        2      3
    y = 2/5 %1 (- 16% 1 + 3% 1 + 5), z = 2 %1}

                  3          5       6
%1: = RootOf(30 _Z + 25-48 _Z + 9 _Z)

>> pretty(sym(maple('allvalues({x^22*x*z+5=0,x*y^2+y*z^3=0,3*y^28*z^3=0})')))

           2                     2    3         2    3
        { x – 2 z x + 5 = 0, x y + y z = 0, 3 y - 8 z = 0}

Now we confirm that the system is solvable with a finite number of solutions.

>> pretty(sym(maple('with(grobner):F:=[x^2-2*x*z+5,x*y^2+y*z^3,3*y^2-8*z^3]: ')))
>> pretty(sym(maple('solvable(F);  finite(F)')))

                               true, true

Then we find a Gröbner basis for the system with the command gsolve, and subsequently try to solve it with the command solve.

>> pretty(sym(maple('gsolve(F)')))

         2                  5       4       2
[[y, z, x  + 5], [80 y - 3 z  + 32 z  - 40 z ,

         4              5        2       3              5      6
    -96 z  + 640 x + 9 z  + 120 z , 240 z  + 1600 - 96 z  + 9 z ]]

A solution of the system could be obtained with solve in the following way:

>> pretty(sym(maple('solve({y=0, z=0, x^2 + 5=0})')))

                               2
                 {x = RootOf(_Z + 5), y = 0, z = 0}

>> pretty(sym(maple('allvalues(")')))

                      1/2                          1/2
       {y = 0, x = I 5   , z = 0}, {y = 0, x = -I 5   , z = 0}

The rest of the solutions can be found as follows:

>> pretty(sym(maple('solve({80*y-3*z^5+32*z^4-40*z^2=0, 96 * z ^ 4 + 640 * x + 9 * z ^ 5 +
   120 * z ^ 2 = 0, 240 * z ^ 3 + 1600-96 * z ^ 5 + 9 * z ^ 6 = 0}) ')))

           2        2       3
{y = 2/5 %1  (-16 %1  + 3 %1  + 5), z = 2 %1,

                 2        2       3
    x = - 3/20 %1  (-16 %1  + 3 %1  + 5)}

                  3             5       6
%1 := RootOf(30 _Z  + 25 - 48 _Z  + 9 _Z )

>> pretty(sym(maple('allvalues(")')))

{x = -.9186354143 + 1.100517108 I, y = 2.449694438 - 2.934712287 I,

    z = -1.576863306 - .7885511972 I},

   {x = -.9186354143 - 1.100517108 I, y = 2.449694438 + 2.934712287 I,

    z = -1.576863306 + .7885511972 I},

   {x = .2580043290 + 1.169756595 I, y = -.6880115440 - 3.119350920 I,

    z = .5785194088 - 1.453171854 I},

   {x = .2580043290 - 1.169756595 I, y = -.6880115440 + 3.119350920 I,

    z = .5785194088 + 1.453171854 I},

    {x = 2.058161202, y = -5.488429872, z = 2.243757078},

    {z = 10.41959738, x = 20.59643412, y = -54.92382432}

Then we find a minimal reduced Gröbner basis, first in lexicographical order and then in order of total degree.

>> pretty(sym(maple('gbasis(F,[y,x,z],plex)')))

    2      3        3      8       7       5   2
[3 y  - 8 z , 80 y z  - 3 z  + 32 z  - 40 z , x  - 2 x z + 5,

         7      8        5        3
    -96 z  + 9 z  + 120 z  + 640 z  x,

         6         3       8      9
    240 z  + 1600 z  - 96 z  + 9 z ]

>> pretty(sym(maple('gbasis(F,[x,y,z],tdeg) ')))

  2                  2      3       2      3     4         3        2
[x  - 2 x z + 5, -3 y  + 8 z , 8 x y  + 3 y , 9 y  + 48 z y  + 320 y  ]

3-11. The mod Operator: Modular Operations with Polynomials

The operator mod evaluates an expression modulo m for a non-zero natural number m. MATLAB uses two representations for an integer modulo m. The positive  mod m representation is an integer between 0 and m-1. The symmetric mod m representation is an integer between -floor((abs(m)-1)/2) and floor(abs(m)/2). The first operand of the mod operator generally tends to be an expression that will be evaluated by MATLAB over the ring of integers modulo n. For polynomials, MATLAB reduces the coefficients modulo m. When the first operand is a power, MATLAB uses the inert representation of the power, for example, i & ^ j mod m is calculated as ij mod m. Among the commands that use the mod operator with polynomials are, in addition to those we’ve already seen, the following (all require the prior use of the maple command):

  • 'mod'(expr,m) is equivalent to expr mod m (expr can be a polynomial).
  • modp1(Fnc(expr1,...,exprn),m) (m is a positive integer) uses efficient arithmetic methods to calculate the inert command or function Fnc modulo m. The n given expressions are univariate polynomials expressed in modp1 format. To express any standard polynomial in the form modp1 modulo m it is necessary to use the command modp1(convertIn). Here  modp1 refers to univariate polynomials with the operator mod in its positive representation.
  • modp1(Add(polyp11,...,polyp1n),m) adds polynomials in the form modp1.
  • modp1(Coeff(polyp1,n),m) returns the coefficient of  xn of the polynomial,  in the form modp1.
  • modp1(Degree(polyp1),m) returns the degree of the polynomial, in the form modp1.
  • modp1(Det(M),m) returns the determinant of the matrix M whose elements are polynomials, in the form modp1.
  • modp1(Gausselimin(M),m) applies Gauss elimination to the matrix M whose elements are polynomials, in the form modp1.
  • modp1(Gaussjord(M),m) returns the reduced Gauss-Jordan form for the matrix M whose elements are polynomials, in the form modp1.
  • modp1(Lcoeff(polyp1),m) returns the leading coefficient of the polynomial polyp1 in the form modp1.
  • modp1(Lcm(polyp1,polyp2),m) finds the least common multiple of the polynomials polyp1 and polyp2, in the form modp1.
  • modp1(Subtract(polyp1,polyp2),m) finds the difference polyp1-polyp2 of the given polynomials , in the form modp1.
  • modp1(Multiply(polyp1,poly2),m) finds the product polyp1*polyp2 of the polynomials in the form modp1.
  • modp1(Ldegree(polyp1),m) returns the smallest degree of the polynomial polyp1 in modp1 form.
  • modp1(Power(polyp1,n),m) returns the n th power of the polynomial polyp1 in the form modp1. With modp1 you can also use inert commands such as Tcoeff, Chrem, Diff, divided, Embedded, Eval, Factors, Gcd, Gcdex, Interp, Irreduc, Powmod, Prem, Quo, Rem, spot, Root, Smith, Sgrfr, Vnormal, and so on.
  • modp1(ConvertIn(polynomial,variable),m) converts the given univariate polynomial with integer coefficients in the given variable to the format modp1 modulo m. This operation takes precedence over any of the operating commands modp1. Any polynomial that is an argument of any operational function modp1 should be previously transformed with modp1(ConvertIn).
  • modp1(ConvertOut(polynomial1,variable),m) converts the specified polynomial in the form modp1 to standard format.
  • modp1(ConvertOut(poly1),m) gives the list of coefficients of the polynomial converted to standard format.
  • modp1(Constant(expr),m) represents the constant expression as a polynomial modulo m in the format modp1.
  • modp1(One(),m) represents the polynomial 1 modulo m in modp1 format.
  • modp1(Zero(),m) represents the polynomial 0 modulo m in modp1 format.
  • modp1(Randpoly(n),m) creates a random polynomial modulo m of degree n in modp1 format.
  • modp2(Fnc(expr1,..,exprn),m) (positive whole m) uses efficient arithmetic methods to calculate the inert command or function Fnc modulo m. The n expressions specified as arguments of the command Fnc are bivariate polynomials expressed in modp2 format modulo m. The term modp2 indicates bivariate polynomials with the operator mod in its finite representation. To express any standard polynomial in the form modp2 it is necessary to use the command modp2(ConvertIn). Such a transformation must be done prior to the application of Fnc to any polynomial.
  • modp2(Add(polyp21,...,polyp2n),m) adds polynomials in the form modp2.
  • modp2(Degree(polyp2,i),m) returns the degree of the specified bivariate polynomial modulo m in format modp2 and with reference to its ith variable.
  • modp2(Diff(polyp2,i),m) returns the derivative of the bivariate polynomial modulo m specified in the format modp2 and with reference to its i th variable.
  • modp2(FielMultiply(polyp2,k),m) returns the product of the scalar k and the specified polynomial in the format modp2.
  • modp2(Lcm(polyp21,polyp22),m) finds the least common multiple of polynomials in the form modp2.
  • modp2(Multiply(polyp21,polyp22),m) returns the product of the polynomials in the form modp2.
  • modp2(Power(polyp2,n),m) returns the nth power of the polynomial in the form modp2.
  • modp2(TotalDegree(polyp2),m) returns the total degree of the polynomial modulo m in the format modp2 in both variables. The inert commands can also be used with modp2, including Coeff, Content, divided, Eval, Factors, Gcd, Prim, Primport, RingMultiply, Sqrfree, Unit, Var-Swap, and so on.
  • modp2(ConvertIn(polynomial,var1,var2),m) converts the given polynomial with integer coefficients in the variables var1, var2 into standard polynomial format modp2 modulo m. This conversion must be applied to any polynomial that will be an argument of any modp2command.
  • modp2(ConvertOut(polyp2,var1,var2),m) converts the polynomial modulo m in format modp2 to its standard format.
  • modp2(ConvertOut(polyp2),m) returns the list of coefficients of the polynomial into its standard format.
  • modp2(Constant(expr),m) represents the constant expression as a bivariate polynomial modp2 modulo m.
  • modp2(One(),m) gives 1 modulo the polynomial m in format modp2.
  • modp2(Zero(),m) gives  the  polynomial  0  modulo  m  in  modp2 format.
  • modp2(Rootpoly(r,s),m) creates a random bivariate polynomial in the format modp2 modulo m of degree r and s for its respective variables.

Here are some examples:

>> pretty(sym(maple('p:= 11: a:= x^4-1')))
>> pretty(sym(maple('a := modp1(ConvertIn(a,x),p)')))
>> pretty(sym(maple('a')))

              a := 1000000000000000000000000000000000010

>> pretty(sym(maple('modp1(ConvertOut(a,x),p),modp1(ConvertOut(a),p)')))
                        4
                      x  + 10, [10, 0, 0, 0, 1]
>> pretty(sym(maple('b:=modp1(Randpoly(3),p):c:=modp1(Rem(a,b),p):
   d:=modp1(Roots(a),p)')))
>> pretty(sym(maple('b,c,d')))
 7000400010008, 400050001, [[1, 1], [10, 1]]
>> pretty(sym(maple('modp1(Factors(a),p)')))
  [1, [[1000000001, 1], [1000000010, 1], [1000000000000000001, 1]]]
>> pretty(sym(maple('a:=x^4*y^2-1:b := modp2(ConvertIn(a,x,y),p)')))
>> pretty(sym(maple('b')))

[10 0 0 0 100000000]

EXERCISE 3-30

Consider the matrix M = [[a, b, c], [d, e, f], [g, h, k]] whose elements are, respectively, the following univariate modp1 modulo 5 polynomials: [[1, x + 1, x - 1], [2, x2 + 1, x2 - 1], [x, (x + 1)2,(x - 1)2]]. Find the following:

- The sum, product, and least common multiple of a and b modp1 modulo 5.

- The fourth power of the polynomial k modp1 modulo 5.

- M2, the determinant of M, the inverse of M and the Jordan diagonal form of M.

We begin by transforming the given format polynomials modp1 modulo 5.

>> maple('a:=modp1(ConvertIn(1,x),5):b:=modp1(ConvertIn(x+1,x),5):
c:=modp1(ConvertIn(x-1,x),5):d:=modp1(ConvertIn(2,x),5):
e:=modp1(ConvertIn(x^2+1,x),5):f:=modp1(ConvertIn(x^2-1,x),5):
g:=modp1(ConvertIn(x,x),5):h:=modp1(ConvertIn(x^2+2*x+1,x),5):
k:=modp1(ConvertIn(x^2-2*x+1,x),5):')

Then we perform the operations requested on the variables a and b.

>> pretty(sym(maple('modp1(Add(a,b),5)')))

10002

>> pretty(sym(maple('modp1(Multiply(a,b),5)')))

10001

>> pretty(sym(maple('modp1(Lcm(a,b),5)')))

10001

>> pretty(sym(maple('modp1(Power(k,4),5)')))

100020003000400000004000300020001

Now we define the matrix M and carry out the specified matrix operations.

>> maple('M: = matrix([[a,b,c],[d,e,f],[g,h,k]])')

M := matrix([[1, 10001, 10004], [2, 100000001, 100000004], [10000, 100020001, 100030001]])

>> pretty(sym(maple('multiply(M,M)')))

           [    100060003        2000700110006        2000800180012]
           [                                                       ]
           [1000200040004    20002000700100007    20003001000140016]
           [                                                       ]
           [1000500060002    20007001100080002    20008001700180005]

>> pretty(sym(maple('det(M)')))

                                -1999599949997

>> pretty(sym(maple('inverse(M)')))

               [-999699949997     -200050003        299970000  ]
               [-------------    -------------    -------------]
               [1999599949997    1999599949997    1999599949997]
               [                                               ]
               [-999799979998        9999           99979996   ]
               [-------------    -------------    -------------]
               [1999599949997    1999599949997    1999599949997]
               [                                               ]
               [999799969998         10001          -99979999  ]
               [-------------    -------------    -------------]
               [1999599949997    1999599949997    1999599949997]

>> pretty(sym((maple('evalf(jordan(M))'))))

         [                                    9                     ]
         [.20002500462526246741730553617573 10  ,        0 ,       0]
         [                                                          ]
         [                                                 -24      ]
         [0 , 5000.3739380021880602966411765771 - .86603 10    i , 0]
         [                                                          ]
         [                                                     -24  ]
         [0 ,  0 ,  -1.9992004696053658328169045771 + .86603 10    i]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset