Sub topic 12
Predicting the degree of a result
You can often tell the degree of a sum, difference, or product before you do any of the algebra. This chapter gives the rules, explains why they hold, and shows the cases where a rule gives only a bound instead of an exact answer. It assumes you can already add, subtract, and multiply polynomials. It also assumes you know what a term, a coefficient, and a leading term are.
Degree, restated precisely
The degree of a nonzero polynomial is the largest exponent that appears on a term with a nonzero coefficient. The leading term is the term with that exponent.
4x^3 - x + 9has degree 3 and leading term4x^3.- A nonzero constant such as
7has degree 0. - The zero polynomial has no degree. Some books call it undefined and others call it negative infinity. Both conventions make the rules below work.
"Nonzero coefficient" matters. The expression 0x^5 + 2x has degree 1, not 5, because the x^5 term is not really there.
Sums and differences: the maximum is an upper bound
When you add or subtract, terms of different powers never interact. Only like terms combine. So the highest power in either polynomial is the only candidate for the highest power in the result.
Rule: deg(p ± q) ≤ max(deg p, deg q).
There are two cases.
- The degrees are different. The higher-degree polynomial owns a power that the other one lacks, so nothing can cancel it. The degree of the result is exactly the larger degree.
- The degrees are equal. The two leading terms are like terms and combine. If their coefficients sum to zero, the leading term vanishes and the degree drops.
Here are examples of each case.
(x^3 + 2x + 1) + (x^2 + 4)has degrees 3 and 2. The result isx^3 + x^2 + 2x + 5, with degree exactly 3.(3x^2 + 2x + 1) + (x^2 - 4x + 5)has equal degrees, and3 + 1 ≠ 0. The result is4x^2 - 2x + 6, with degree 2.(x^3 + 2x + 1) - (x^3 - x^2 + 5)has equal degrees. The leading terms cancel, so the result isx^2 + 2x - 4, with degree 2.
Subtraction is the case where cancellation is most likely, because you are deliberately matching a polynomial against a similar one. The sum (x^2 + 3x) + (-x^2 + 4) also cancels. It gives 3x + 4, with degree 1.
For sums and differences you can only promise "at most the larger degree." You can promise equality only when the degrees differ.
Products: degrees add
Multiplication works differently. Every term of one factor multiplies every term of the other, and the product rule for exponents adds the exponents. The highest power in the result must come from the two highest powers:
(a·x^m)(b·x^n) = ab·x^(m+n)
Rule: deg(p · q) = deg p + deg q, when both p and q are nonzero.
This is an equality, not a bound. The product's leading term is the product of the leading terms, and its coefficient is a·b. Over the integers and real numbers, the product of two nonzero numbers is never zero. The leading term therefore cannot cancel.
Why can nothing else produce x^(m+n)? Any other pair of terms has at least one exponent below its factor's maximum. Its exponent total is then strictly less than m + n. The leading terms are the only pair that reaches the top power.
| Operation | Degrees of p and q | Degree of result |
|---|---|---|
| `p + q` or `p - q` | 3 and 2 | exactly 3 |
| `p + q` or `p - q` | 3 and 3 | 3 or less |
| `p · q` | 3 and 2 | exactly 5 |
| `p · q` | 3 and 3 | exactly 6 |
| `p · p` (a square) | 4 | exactly 8 |
A useful consequence: deg(p^n) = n · deg p. For example, (x + 3)^2 has degree 2 · 1 = 2, and (x^2 - 1)^3 has degree 3 · 2 = 6.
A worked prediction
Predict the degree and leading term of (x^3 - 2x + 1)(2x^2 + x), then expand it to check.
The degrees are 3 and 2, so the product has degree 5. The leading term is x^3 · 2x^2 = 2x^5.
Now expand by distributing each term of the first factor over the second:
x^3 · (2x^2 + x) = 2x^5 + x^4-2x · (2x^2 + x) = -4x^3 - 2x^21 · (2x^2 + x) = 2x^2 + x
Add the three rows and combine like terms. The -2x^2 and 2x^2 cancel, and the result is 2x^5 + x^4 - 4x^3 + x. The degree is 5 and the leading term is 2x^5, as predicted.
The middle x^2 term vanished, but that did not affect the degree. Cancellation can remove interior terms from a product freely. It cannot remove the leading term. Difference of squares shows the same thing: (x - 3)(x + 3) = x^2 - 9. The x term cancels, and the degree is still 1 + 1 = 2.
Checking the rules in code
A polynomial stored as a coefficient list, with the constant term first, makes the degree easy to compute. You scan from the end and skip trailing zeros. This program tests each rule on the examples from this chapter.
def degree(p):
# Returns None for the zero polynomial, which has no degree.
for i in range(len(p) - 1, -1, -1):
if p[i] != 0:
return i
return None
def add(p, q):
n = max(len(p), len(q))
p = p + [0] * (n - len(p))
q = q + [0] * (n - len(q))
return [a + b for a, b in zip(p, q)]
def subtract(p, q):
return add(p, [-c for c in q])
def multiply(p, q):
result = [0] * (len(p) + len(q) - 1)
for i, a in enumerate(p):
for j, b in enumerate(q):
result[i + j] += a * b
return result
# Different degrees: the sum has exactly the larger degree.
p = [1, 2, 0, 1] # x^3 + 2x + 1
q = [4, 0, 1] # x^2 + 4
print(degree(add(p, q))) # 3
# Equal degrees with cancellation: the degree drops.
r = [5, 0, -1, 1] # x^3 - x^2 + 5
print(subtract(p, r)) # [-4, 2, 1, 0]
print(degree(subtract(p, r))) # 2
# Products: degrees add, even though x^2 cancels inside the result.
f = [1, -2, 0, 1] # x^3 - 2x + 1
g = [0, 1, 2] # 2x^2 + x
prod = multiply(f, g)
print(prod) # [0, 1, 0, -4, 1, 2]
print(degree(prod)) # 5
print(degree(f) + degree(g)) # 5The list [-4, 2, 1, 0] ends with a zero. That trailing zero is the 0x^3 term left behind by cancellation, and degree correctly ignores it. A result that is stored with leftover zeros is still the same polynomial. Always trim, or use a function like degree, before you read off the length.
Common errors
- Adding degrees in a sum.
(x^2 + 1) + (x^3 + 2)has degree 3, not 5. Adding degrees is the rule for products only. - Taking the larger degree in a product.
(x^2)(x^3)has degree 5, not 3. - Assuming equal degrees stay equal. After subtracting two cubics, check whether the
x^3coefficients matched. If they did, look at the next power down. - Reading degree from an unsimplified expression.
x^4 - x^4 + 3xhas degree 1. Combine like terms first, then look for the largest remaining exponent. - Forgetting the zero polynomial.
p - pis the zero polynomial, which has no degree. A formula such asmax(deg p, deg q)gives only an upper bound there.
The product rule's equality depends on working with integers or real numbers. In modular arithmetic it can fail. Modulo 6, (2x)(3x) = 6x^2, and the coefficient 6 equals 0. The leading term disappears. You do not need to worry about this for ordinary algebra, but it is why the rule's statement includes "nonzero coefficients that multiply to a nonzero number."
Using the rules
Degree prediction is a fast sanity check. If you expand (x + 2)(x^2 + 3x + 1) and your answer has degree 4, you know something went wrong before you recheck any arithmetic. The correct result is x^3 + 5x^2 + 7x + 2, and its degree is 1 + 2 = 3. You can also use the leading-term rule to check the first and last terms of a product. The leading term is the product of the leading terms, and the constant term is the product of the constants.
Exercise
Let p = 2x^4 - x + 3 and q = -2x^4 + 5x^2. Give the degree of p + q, the degree of p - q, and the degree of p · q.
Show answer
p + q = 5x^2 - x + 3, so the degree is 2, because the x^4 terms cancel. p - q = 4x^4 - 5x^2 - x + 3, so the degree is 4, because 2 - (-2) = 4 is nonzero. p · q has degree 4 + 4 = 8, with leading term (2x^4)(-2x^4) = -4x^8.
Exercise
A polynomial f has degree 3 and a polynomial g has degree 5. What is the exact degree of f + g, f - g, and f · g, and what is the degree of (f · g)^2?
Show answer
The degrees differ, so f + g and f - g both have degree exactly 5. The product f · g has degree 3 + 5 = 8. Squaring doubles the degree, so (f · g)^2 has degree 16.
Exercise
Without expanding, find the degree and leading term of (3x^2 + x)(x^3 - 4)(2x + 1). Then explain why the degree of (x + 5)(x - 5) is 2 even though the expansion x^2 - 25 has no x term.
Show answer
The degrees are 2, 3, and 1, so the product has degree 6. The leading term is (3x^2)(x^3)(2x) = 6x^6. For (x + 5)(x - 5), the degree is 1 + 1 = 2 because the leading terms x and x multiply to x^2, and that term cannot cancel. The 5x and -5x terms cancel, but they are interior terms of lower degree.