Sub topic 11
Multiplying larger polynomials
What this chapter assumes
You should already be able to multiply two binomials with FOIL, combine like terms, and apply the product rule for exponents (x^a · x^b = x^(a+b)). This chapter generalizes FOIL to polynomials with any number of terms. It also covers the errors that show up once the expressions get long.
The one rule behind every product
FOIL is not a separate method. It is the distributive property applied to two terms on each side. For larger polynomials the rule is the same:
Multiply every term of the first polynomial by every term of the second, then combine like terms.
If the first polynomial has m terms and the second has n terms, you get m × n partial products before combining. A trinomial times a trinomial gives 9 products. A binomial times a four-term polynomial gives 8. Counting the products before you start tells you whether you have missed any.
A worked example
Multiply (x² + 2x − 3)(x³ − x + 4).
The first factor has 3 terms and the second has 3 terms, so expect 9 partial products. Distribute one term of the first factor at a time.
- x² · (x³ − x + 4) = x⁵ − x³ + 4x²
- 2x · (x³ − x + 4) = 2x⁴ − 2x² + 8x
- −3 · (x³ − x + 4) = −3x³ + 3x − 12
Now group by exponent and combine:
| Power | Contributions | Combined |
|---|---|---|
| x⁵ | x⁵ | x⁵ |
| x⁴ | 2x⁴ | 2x⁴ |
| x³ | −x³ and −3x³ | −4x³ |
| x² | 4x² and −2x² | 2x² |
| x¹ | 8x and 3x | 11x |
| x⁰ | −12 | −12 |
The product is x⁵ + 2x⁴ − 4x³ + 2x² + 11x − 12.
The nine partial products collapsed into six terms because x³, x², and x each received two contributions. That is what combining like terms does.
Three ways to organize the work
All three methods produce the same partial products. They differ only in bookkeeping.
Row-by-row distribution
This is the method used above. Take each term of the first factor in turn and distribute it across the whole second factor. It works well on paper and scales to any size.
The grid (box) method
Put the terms of one factor along the top and the terms of the other down the side. Each cell holds the product of its row and column terms.
| Row | x³ | −x | 4 |
|---|---|---|---|
| **x²** | x⁵ | −x³ | 4x² |
| **2x** | 2x⁴ | −2x² | 8x |
| **−3** | −3x³ | 3x | −12 |
Like terms often sit on diagonals, which makes combining easier to see. The grid also makes it obvious when a cell is missing.
Vertical (column) layout
Write one polynomial under the other and multiply as you would multi-digit numbers. Align columns by power of x, and leave a gap or write 0x² for a missing power. This layout is the most error-prone for beginners because the alignment is easy to break.
Edge cases
Missing terms
x³ − x + 4 has no x² term. When you write it in a table or a coefficient list, treat the x² coefficient as 0. Skipping the placeholder shifts every later power by one, which is the most common bug in the coefficient-list approach described below.
Negative signs travel with the term
When you distribute −3, the sign belongs to the 3. Multiplying −3 by −x gives +3x, not −3x. A reliable habit is to write each partial product with its sign before combining anything.
More than two factors
Multiply two factors first, simplify, then multiply the result by the third. Take (x + 1)(x − 1)(x + 2):
- (x + 1)(x − 1) = x² − 1
- (x² − 1)(x + 2) = x³ + 2x² − x − 2
Multiplication is associative, so any pairing gives the same final answer. Pick the pairing that simplifies earliest. Here the first pair is a difference of squares, which leaves only two terms.
Powers of a polynomial
(x + 1)³ means (x + 1)(x + 1)(x + 1). It does not equal x³ + 1. Expanding one pair at a time:
- (x + 1)(x + 1) = x² + 2x + 1
- (x² + 2x + 1)(x + 1) = x³ + 3x² + 3x + 1
The middle terms exist because every cross-product contributes. Dropping them is the same mistake as writing (a + b)² = a² + b².
Predicting the shape of the answer
Before you multiply, you can predict three things about the product:
- Degree. The degree of the product is the sum of the degrees of the factors. In the worked example, 2 + 3 = 5.
- Leading term. Multiply the leading terms of the factors: x² · x³ = x⁵.
- Constant term. Multiply the constant terms: (−3)(4) = −12.
If your final answer disagrees with any of these, you have an error. These checks cost seconds and catch many mistakes.
The number of terms is different. The product has at most (degree of product + 1) terms, but cancellation can produce fewer. For example, (x − 1)(x² + x + 1) = x³ − 1, where the x² and x terms cancel completely.
Checking by substitution
Pick a value for x, evaluate the factored form, then evaluate your expanded answer. The two numbers must match.
For x = 2 in the worked example:
- Factors: (4 + 4 − 3) · (8 − 2 + 4) = 5 · 10 = 50
- Expanded: 32 + 32 − 32 + 8 + 22 − 12 = 50
For x = −1: the factors give (−4) · 4 = −16, and the expansion gives −1 + 2 + 4 + 2 − 11 − 12 = −16.
Choose the test value with care:
- Avoid x = 0. It only tests the constant term.
- Be careful with x = 1. It tests the sum of the coefficients, which is a useful check. In this example, though, the first factor equals 0 at x = 1. Both sides then become 0, and several kinds of mistakes can hide behind that zero.
- Use two values. x = 2 and x = −1 together catch most errors. A single matching value does not prove the expansion is right, but a mismatch proves it is wrong.
The same computation in code
A polynomial can be stored as a list of coefficients, starting with the constant term. The coefficient at index k belongs to xᵏ. The double loop below is the grid method: each cell (i, j) adds a · b to the coefficient of x^(i+j).
def multiply(p, q):
# Each pair of terms a*x^i and b*x^j contributes a*b to the coefficient of x^(i+j).
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
def evaluate(p, x):
return sum(c * x**i for i, c in enumerate(p))
first = [-3, 2, 1] # x^2 + 2x - 3
second = [4, -1, 0, 1] # x^3 - x + 4 (note the 0 placeholder for x^2)
product = multiply(first, second)
print(product) # [-12, 11, 2, -4, 2, 1]
for x in (2, -1):
print(evaluate(first, x) * evaluate(second, x), evaluate(product, x))
# 50 50
# -16 -16
# Three factors: (x + 1)(x - 1)(x + 2)
print(multiply(multiply([1, 1], [-1, 1]), [2, 1])) # [-2, -1, 2, 1]
# (x + 1)^3
cube = multiply(multiply([1, 1], [1, 1]), [1, 1])
print(cube) # [1, 3, 3, 1]Three things to notice:
- The result list has length len(p) + len(q) − 1, which is the degree rule in code: degrees add, so the list length is the sum of the degrees plus one.
- The
0insecondis the placeholder for the missing x² term. Remove it and the list[4, -1, 1]becomes a different polynomial, x² − x + 4. - The code never "combines like terms" as a separate step. Adding into
result[i + j]does it automatically.
Common errors
| Error | Example | Fix |
|---|---|---|
| Missing a partial product | Only 6 products for a 3 × 3 problem | Count m × n before combining |
| Sign slip | (−3)(−x) written as −3x | Write the sign with each term before multiplying |
| Combining unlike terms | 4x² + 8x written as 12x³ | Only add coefficients when the exponents match |
| Adding exponents when adding terms | x² + x² written as x⁴ | Adding changes the coefficient: x² + x² = 2x² |
| Multiplying exponents when multiplying | x² · x³ written as x⁶ | Product rule: add the exponents to get x⁵ |
| Treating a power as distributing | (x + 1)³ written as x³ + 1 | Expand one product at a time |
Exercises
Exercise
Expand (x² − x + 2)(x² + 3x − 1). How many partial products are there before combining, and what is the degree of the result? Check your answer at x = 2.
Show answer
There are 3 × 3 = 9 partial products, and the degree is 2 + 2 = 4. Distributing: x²(x² + 3x − 1) = x⁴ + 3x³ − x²; −x(x² + 3x − 1) = −x³ − 3x² + x; 2(x² + 3x − 1) = 2x² + 6x − 2. Combining gives x⁴ + 2x³ − 2x² + 7x − 2. Check at x = 2: the factors give (4 − 2 + 2)(4 + 6 − 1) = 4 · 9 = 36, and the expansion gives 16 + 16 − 8 + 14 − 2 = 36.
Exercise
A student expands (x + 2)(x³ + x + 1) using the coefficient lists [2, 1] and [1, 1, 1], leaving out the x² term of the second factor. What is wrong, and what is the correct product?
Show answer
The second factor is x³ + 0x² + x + 1, so its list must be [1, 1, 0, 1]. Using [1, 1, 1] represents x² + x + 1, which is a different polynomial. The correct product is x⁴ + 2x³ + x² + 3x + 2, which is the list [2, 3, 1, 2, 1]. Check at x = 1: (3)(3) = 9, and 1 + 2 + 1 + 3 + 2 = 9.