Sub topic 4
Adding polynomials
This chapter assumes you can evaluate algebraic expressions, do integer arithmetic with negatives, read exponents such as x^3, and write a polynomial in standard form (terms ordered from highest degree to lowest). It covers the working model for addition, the errors that come up most often, and how the same operation looks in code.
The working model
A polynomial is a sum of terms. Each term is a coefficient times a product of variable powers. To add two polynomials, you collect all the terms from both and merge the like terms. Two terms are like terms when they have exactly the same variables raised to exactly the same exponents. Merging means adding their coefficients and keeping the variable part unchanged.
The rule rests on the distributive property. For example, 3x^2 + 4x^2 = (3 + 4)x^2 = 7x^2. You are factoring out the shared variable part and adding what is left. This is also why unlike terms cannot merge: 3x^2 + 4x has no common factor that would let you collapse it into one term.
The steps are:
- Write both polynomials in standard form.
- Group terms with the same variable part.
- Add each group's coefficients.
- Drop any term whose coefficient is 0, and write the result in standard form.
A first worked example
Add (3x^2 + 2x + 1) and (x^2 - 4x + 5).
- Both are already in standard form.
- Group like terms: (3x^2 + x^2), (2x - 4x), (1 + 5).
- Add the coefficients: 3 + 1 = 4, then 2 + (-4) = -2, then 1 + 5 = 6.
- The result is 4x^2 - 2x + 6.
The most common form of error is a sign slip in step 3. Write the coefficient with its sign attached, such as +2 and -4, so you add signed numbers rather than subtracting by accident.
Recognizing like terms precisely
Like terms must match in every variable and every exponent. The coefficient is the only part allowed to differ. Constants are like terms with each other, because each has no variable part.
| Terms | Like terms? | Reason |
|---|---|---|
| 5x^2 and -2x^2 | Yes | Same variable, same exponent |
| 5x^2 and 5x | No | Exponents differ |
| 7 and -3 | Yes | Both are constants |
| 4xy and 9yx | Yes | Multiplication is commutative, so xy = yx |
| 4xy and 4x | No | The second term has no y |
| 2x^2y and 2xy^2 | No | Exponents sit on different variables |
The last row catches many learners. Both terms use the same variables and the same total degree, but the exponents are attached to different variables, so the terms are not like.
A multi-variable example: add (3x^2y + 2xy - 4) and (x^2y - 5xy + y).
- The x^2y terms give 3 + 1 = 4, so 4x^2y.
- The xy terms give 2 - 5 = -3, so -3xy.
- The y term has no partner, so it stays as y.
- The constant -4 has no partner, so it stays.
The sum is 4x^2y - 3xy + y - 4. A term with no partner is not an error. It is copied into the result unchanged.
Missing terms and the column method
When one polynomial lacks a power that the other has, treat the missing coefficient as 0. This matters most in the column method, where you stack the polynomials and align powers vertically:
5x^3 + 0x^2 - 2x + 7
+ -5x^3 + 1x^2 + 4x - 1
------------------------
0x^3 + 1x^2 + 2x + 6Writing the placeholder 0x^2 keeps the columns aligned, so you can't accidentally add an x term to an x^2 term. The sum is x^2 + 2x + 6. The x^3 terms cancelled, so the result has degree 2 even though both inputs had degree 3. The next section explains why this matters.
Predicting the degree of a sum
The degree of a polynomial is the highest exponent among its terms with nonzero coefficients. For a sum, the rule is:
- If the two polynomials have different degrees, the sum has the larger degree. Nothing can cancel the leading term.
- If they have the same degree, the sum has that degree or lower. The leading coefficients may cancel, as in the example above.
So the degree of a sum is at most the larger of the two input degrees. Knowing this upper bound lets you sanity-check an answer. If you add two quadratics and get a cubic, you made an error.
A special case: adding a polynomial to its own negative gives 0, which is the zero polynomial. Its degree is conventionally left undefined, because it has no nonzero term.
Common errors
- Merging unlike terms. Writing 3x^2 + 4x = 7x^3 is wrong. Merging changes only the coefficient, never the exponent. Adding exponents belongs to multiplication, which a later chapter covers.
- Adding the exponents of like terms. For x^2 + x^2 the answer is 2x^2, not x^4.
- Losing a term with no partner. Every term from both polynomials must appear in the result, either merged or copied.
- Dropping the 1 coefficient. The term x is 1x, and -x is -1x. So (x^2 + x) + (3x^2 - x) = 4x^2 + 0x = 4x^2.
- Keeping zero terms. Writing 4x^2 + 0x + 6 is not wrong in value, but standard form omits terms with zero coefficients.
- Sign errors with negative coefficients. Adding 2 and -4 gives -2, not 2.
Checking by substitution
You can verify a sum by choosing a value for x and evaluating both sides. If the original sum and your simplified answer give the same number, the answer is very likely correct. Take x = 2 for the first example.
- The first polynomial gives 3(4) + 2(2) + 1 = 17.
- The second gives 4 - 8 + 5 = 1.
- Their total is 18.
- Our answer, 4x^2 - 2x + 6, gives 16 - 4 + 6 = 18.
The values match. Avoid x = 0 and x = 1 as the only test values. At x = 0 every non-constant term vanishes, and at x = 1 every power equals 1, so errors in exponents go undetected. A single matching value does not prove the answer is right, but a mismatch proves it is wrong.
Polynomials as coefficient lists
A single-variable polynomial can be stored as a list of coefficients, with the constant term first. Position i holds the coefficient of x^i. Under this representation, adding polynomials is adding lists position by position. Shorter lists are padded with zeros, which is the same idea as the placeholder 0x^2 in the column method.
def add(p, q):
# Coefficients are listed 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)]
def trim(p):
# Remove trailing zeros so the list length reflects the true degree.
p = list(p)
while len(p) > 1 and p[-1] == 0:
p.pop()
return p
p = [1, 2, 3] # 3x^2 + 2x + 1
q = [5, -4, 1] # x^2 - 4x + 5
print(add(p, q)) # [6, -2, 4] -> 4x^2 - 2x + 6
a = [7, -2, 0, 5] # 5x^3 - 2x + 7
b = [-1, 4, 1, -5] # -5x^3 + x^2 + 4x - 1
print(add(a, b)) # [6, 2, 1, 0]
print(trim(add(a, b))) # [6, 2, 1] -> x^2 + 2x + 6The trim function does what step 4 of the working model does. Without it, the list [6, 2, 1, 0] has length 4, which wrongly suggests degree 3. Code that reads the degree as len(p) - 1 must trim first.
Note that p + [0] * (n - len(p)) builds a new list, so the caller's input lists are not modified.
Summary of the method
Adding polynomials is combining coefficients of matching variable parts. Everything else is bookkeeping: standard form to keep things organized, placeholders for missing powers, and a final cleanup of zero terms. The degree of the result is at most the larger input degree, and substitution gives a quick test of your answer.
Exercise
Add (2x^3 - x + 4) and (-2x^3 + 3x^2 + 5x - 9). State the degree of each input and of the result, and explain why the result's degree differs from the inputs'.
Show answer
Group like terms: x^3 terms give 2 + (-2) = 0. x^2 terms give 0 + 3 = 3. x terms give -1 + 5 = 4. Constants give 4 + (-9) = -5. The sum is 3x^2 + 4x - 5. Both inputs have degree 3 and the result has degree 2, because the leading terms have opposite coefficients and cancel.
Exercise
Add (4a^2b - 3ab + 2) and (-a^2b + ab^2 + 6ab - 5). Which terms are copied without merging?
Show answer
The a^2b terms give 4 + (-1) = 3, so 3a^2b. The ab terms give -3 + 6 = 3, so 3ab. The constants give 2 + (-5) = -3. The term ab^2 has no like term (the exponent is on b, not a), so it is copied. The sum is 3a^2b + ab^2 + 3ab - 3.
Exercise
A student adds (x^2 + 3x) and (2x^2 + x) and writes 3x^4 + 4x^2. Identify both mistakes and give the correct sum. Then check it with x = 2.
Show answer
The first mistake is adding the exponents of the x^2 terms to get x^4, when only the coefficients are added: x^2 + 2x^2 = 3x^2. The second is writing 4x^2 for 3x + x, when the exponent of x stays 1: 3x + x = 4x. The correct sum is 3x^2 + 4x. Check at x = 2: the inputs give (4 + 6) + (8 + 2) = 20, and the answer gives 12 + 8 = 20.
Exercise
In Python, using the coefficient-list form with the constant term first, add [3, 0, -2] and [1, 5, 2, 4]. Give the trimmed result and the corresponding polynomial.
Show answer
Pad the first list to [3, 0, -2, 0]. Adding position by position gives [4, 5, 0, 4]. The last entry is nonzero, so trimming changes nothing. The polynomial is 4x^3 + 5x + 4, and the x^2 term is absent because its coefficient is 0.