Sub topic 3
Multiplying two binomials with FOIL
This chapter assumes you can evaluate expressions, work with negative integers, and apply the distributive property and the product rule for exponents (x^a · x^b = x^(a+b)).
FOIL for two binomials
A binomial has two terms, such as (x + 2). To multiply two binomials, multiply each term of the first by each term of the second. FOIL is a memory aid for the four products: First, Outer, Inner, Last.
For example, (x + 2)(x + 3) gives x² + 3x + 2x + 6, which simplifies to x² + 5x + 6.
Multiplying larger polynomials
FOIL works only for two binomials. For a polynomial with more terms, apply the same idea: every term of one factor multiplies every term of the other. The product of a trinomial and a binomial has up to six products before you combine like terms.
Predicting the degree of a result
The degree of a polynomial is its highest exponent. When you multiply polynomials, the degrees add. A degree 1 binomial times a degree 2 trinomial yields a degree 3 result. Addition and subtraction do not add degrees. They keep the larger degree, unless the leading terms cancel.
Special products
Some binomial products appear often and follow fixed patterns:
- Perfect square: (x + 3)² = x² + 6x + 9
- Difference of squares: (x − 3)(x + 3) = x² − 9
Coefficient lists in code
You can store a polynomial as a list of coefficients, starting with the constant term. The list [1, 2, 3] means 1 + 2x + 3x².
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
def evaluate(p, x):
return sum(c * x**i for i, c in enumerate(p))
print(multiply([2, 1], [1, 3, 1])) # [2, 7, 5, 1] -> x^3 + 5x^2 + 7x + 2
print(multiply([3, 1], [3, 1])) # [9, 6, 1] -> x^2 + 6x + 9
print(multiply([-3, 1], [3, 1])) # [-9, 0, 1] -> x^2 - 9
# Checking by substitution at x = 2
print(evaluate([2, 1], 2) * evaluate([1, 3, 1], 2)) # 44
print(evaluate([2, 7, 5, 1], 2)) # 44Checking your answer by substitution
Pick a value for x, such as 2. Evaluate both factors and multiply the results. Then evaluate the expanded polynomial at the same value. If the two numbers match, the expansion is very likely correct. A single match does not prove the expansion, so test a second value when the stakes are high.
> Note: this check catches most sign and arithmetic errors, but it does not catch every error. Use a second value of x.
Exercise
Expand (x + 3)² and check your answer by substituting x = 2.
Show answer
x² + 6x + 9. At x = 2, both (2 + 3)² and 4 + 12 + 9 equal 25.