Sub topic 4
Adding Polynomials
Prerequisites
You should be comfortable with integer arithmetic, negative numbers, exponents such as \(x^3\), and the distributive property. A polynomial is an expression made from terms such as \(4x^2\), \(-3x\), and \(7\). A coefficient is the number multiplying a variable. Terms with the same variable part and exponent are like terms.
The working model
To add polynomials:
- Write both polynomials in standard form, with powers descending.
- Align like terms by their powers.
- Add the coefficients of corresponding powers.
- Write the result in standard form.
For example:
\[ (3x^2+2x+1)+(x^2-4x+5) \]
Group terms with matching powers:
\[ (3x^2+x^2)+(2x-4x)+(1+5) \]
Add the coefficients:
\[ 4x^2-2x+6 \]
The variable parts do not change. Only the coefficients are added.
Missing terms and subtraction signs
A polynomial can omit a power. Treat the missing term as having coefficient zero.
Consider:
\[ (5x^3-2x+4)+(x^3+3x^2-7) \]
The first polynomial has no \(x^2\) term. Rewrite it as:
\[ (5x^3+0x^2-2x+4)+(x^3+3x^2+0x-7) \]
Now add matching powers:
\[ (5+1)x^3+(0+3)x^2+(-2+0)x+(4-7) \]
So the sum is:
\[ 6x^3+3x^2-2x-3 \]
A negative coefficient is included in the addition. For instance, adding \(2x\) and \(-5x\) gives \(-3x\).
Degree of a sum
The degree of a nonzero polynomial is its greatest exponent. The degree of a sum is at most the larger degree of the two original polynomials.
For example:
\[ (4x^3+x)+(2x^2-5) \]
has degree 3. However, leading terms can cancel:
\[ (4x^3+x)+(-4x^3+2)=x+2 \]
The original polynomials have degree 3, but the sum has degree 1. Therefore, the larger degree predicts an upper bound, not always the exact result.
A coefficient-list view
A polynomial can also be represented by a list whose first entry is the constant coefficient. The list [1, 2, 3] represents \(1+2x+3x^2\).
def add(p, q):
# Coefficients go from the constant term upward.
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)]
p = [1, 2, 3] # 3x^2 + 2x + 1
q = [5, -4, 1] # x^2 - 4x + 5
print(add(p, q)) # [6, -2, 4]The output represents \(4x^2-2x+6\). Padding with zeros handles missing powers.
Exercise
Find the sum: (7x^3 - 2x^2 + x - 5) + (-3x^3 + 6x^2 - 4x + 9).
Show answer
4x^3 + 4x^2 - 3x + 4