Sub topic 2
Subtracting Polynomials and Multiplying Monomials
This chapter assumes you can evaluate algebraic expressions, compute with negative integers, read exponents such as x^3, and apply the distributive property.
Subtracting polynomials and distributing the negative
Subtracting a polynomial means subtracting every term inside it. The negative sign applies to each term of the second polynomial:
(3x^2 + 2x + 1) - (x^2 - 4x + 5) = 3x^2 + 2x + 1 - x^2 + 4x - 5 = 2x^2 + 6x - 4
After distributing, combine like terms. A common error is flipping the sign of only the first term, which turns +4x into -4x instead of +4x.
def subtract(p, q):
# Coefficients run from the constant term upward: [1, 2, 3] means 1 + 2x + 3x^2.
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)]
print(subtract([1, 2, 3], [5, -4, 1])) # [-4, 6, 2] -> 2x^2 + 6x - 4The product rule for exponents
When you multiply powers with the same base, add the exponents: x^a · x^b = x^(a+b). For example, x^2 · x^3 = x^5.
The rule applies only to a shared base. You cannot combine x^2 · y^3 into a single power.
Multiplying monomials
A monomial is a single term, such as 4x^2y. To multiply two monomials, multiply their coefficients, then apply the product rule to each variable separately.
- (3x^2)(4x^3) = 12x^5
- (2xy^2)(5x^2y) = 10x^3y^3
Multiplying a monomial by a polynomial
Use the distributive property to multiply the monomial by each term of the polynomial:
3x^2(4 + 2x) = 3x^2 · 4 + 3x^2 · 2x = 12x^2 + 6x^3
Write the result in standard form, with powers in descending order: 6x^3 + 12x^2.
def multiply_monomial(c, e, poly):
# Multiplying by x^e shifts each coefficient up e places; then scale by c.
return [0] * e + [c * a for a in poly]
print(multiply_monomial(3, 2, [4, 2])) # [0, 0, 12, 6] -> 6x^3 + 12x^2Exercise
Subtract (5x^2 - 3x + 2) from (x^2 + 4x - 7).
Show answer
-4x^2 + 7x - 9