Polynomial Addition and Multiplication

Kenneth Levasseur
Mathematical Sciences
UMass Lowell
Kenneth_Levasseur@uml.edu

Calculations done here use AbstractAlgebra a Mathematica package available at http://www.central.edu/eaam/index.asp

Needs["AbstractAlgebra`Master`"];
SwitchStructureTo[Ring];

You add and  multiply polynomials over an arbitrary ring the same way you learned to do it for polynomials over the real number in high school algebra.  The only thing you have to keep in mind is that the coefficient operations use the underlying operations for the ring over which you are working.  For example,  if you working with polynomials over (Subscript[ℤ, 3])  then adding 2  x + 1   and 2  x + 2 involved adding "like terms" and the result is  (2 + 2) x  +  (2  + 1)  =  1 x  +  
            0  =  x.

Addition

Given two polynomials

	a(x) =(Subscript[a, 0])+(Subscript[a, 1]) x+(Subscript[a, 2]) (x^2)+(Subscript[a, 3]) (x^3)+…
	
	b(x) =(Subscript[b, 0])+(Subscript[b, 1]) x+(Subscript[b, 2]) (x^2)+(Subscript[b, 3]) (x^3)+…

Their sum is the polynomial

	a(x)  +  b(x) =((Subscript[a, 0]) + (Subscript[b, 0]))+((Subscript[a, 1]) + (Subscript[b, 1])) x+((Subscript[a, 2]) + (Subscript[b, 2])) (x^2)+((Subscript[a, 3]) + (Subscript[b, 3])) (x^3)+…

You just add corresponding coefficients to add.   Notice that we didn't specify exactly where either two of a(x)  and b(x) "stop" but eventually the coefficients of both are zero and the number of additions in the underlying ring is no more than the largest degree of the two addends.

Example

P = PolynomialsOver[Z[5]]
a = 
      Poly[Z[5],   2 + 4  x + 3  (x^2) + (x^3)]
b = Poly[Z[5], 1 + 2  x + 4  (x^3) +  4 (x^4)]

Addition[P][a, b]

Multiplication

Given two polynomials of degree m and  n, respectively

	a(x)  = 
        (Subscript[a, 0]) + (Subscript[a, 1]) x + (Subscript[a, 2]) (x^2) +  ⋯ + (Subscript[a, m]) (x^m)
	
	b(x)  = 
        (Subscript[b, 0]) + (Subscript[b, 1]) x + (Subscript[b, 2]) (x^2) + ⋯ + (Subscript[b, n]) (x^n)

Their product is the polynomials is computed by multiplying all of the terms in the first polynomial by each term in the second.  This involves multiplying powers of the indeterminate x, which follows the rule   (x^j) (x^k) =  (x^(j + k)), where the addition i + j is of integers, not in the underlying ring.   If we organize our results the product follows a regular pattern, but somewhat more complicated than for addition.

	a(x)  b(x) =((Subscript[a, 0])·(Subscript[b, 0]))+((Subscript[a, 0])·(Subscript[b, 1]) + (Subscript[a, 1])·(Subscript[b, 0])) x+((Subscript[a, 0])·(Subscript[b, 2]) + (Subscript[a, 1])·(Subscript[b, 1]) + 
                    (Subscript[a, 2])·(Subscript[b, 0]))(x^3)+((Subscript[a, 0])·(Subscript[b, 3]) + (Subscript[a, 1])·(Subscript[b, 2]) + 
                    (Subscript[a, 2])·(Subscript[b, 1]) + (Subscript[a, 3])·(Subscript[b, 0]))(x^3)\(\(+⋯\)


                \(\(=\)\(\ \)\(∑\+\(k = 0\)\%\(m + n\)\((∑\+\(j = 0\)\%k a\_j·b\_\(k - j\))\) x\^k\)\)\)

In both of the formulae above it should be understood that coefficients with index higher than the respective degrees are equal to the zero of the underlying ring.    Notice that for each term in the product the coefficient of (x^k) is the sum of products of coefficients whose indices add up to k.   

In multiplying polynomials of degree m and n, the number of multiplications involving nonzero coefficients can be as high as (m + 1) (n + 1)

Example

This product isn't as easy to see as the sum above.  Work out a few coefficients to check the result.

P
{a, b}
Multiplication[P][a, b]

Here's why we will usually work with polynomials over a field.  The following strange things don't happen if a ring doesn't have zero divisors as (Subscript[ℤ, 4]) has.

Q = PolynomialsOver[Z[4]]

s = Poly[Z[4], 2 x]
t = Poly[Z[4], 2  x + 1]

A zero divisor among the polynomials

Multiplication[Q][s, s]

Here we see that t is a unit, which isn't bad; but normally we expect the degree of a product to be the sum of degrees, but not in this polynomial ring.

Multiplication[Q][t, t]

Over a field this strange result never occurs — the product of two linear polynomials is always a quadratic polynomial.