Sub topic 8
Perfect square trinomials
This chapter assumes you can multiply binomials with FOIL, factor out a greatest common factor, factor x^2 + bx + c, and factor a difference of squares. A perfect square trinomial is a trinomial that is the square of a binomial. Because it follows a fixed pattern, you can recognize it quickly and factor it without searching for number pairs.
Where the pattern comes from
Square a binomial by writing it as a product of two identical factors and multiplying:
(a + b)^2 = (a + b)(a + b)
= a^2 + ab + ab + b^2
= a^2 + 2ab + b^2
(a - b)^2 = (a - b)(a - b)
= a^2 - ab - ab + b^2
= a^2 - 2ab + b^2Reading these right to left gives the two factoring rules:
| Pattern | Factored form |
|---|---|
| a^2 + 2ab + b^2 | (a + b)^2 |
| a^2 - 2ab + b^2 | (a - b)^2 |
The middle term is twice the product of the two square roots. The sign of the middle term decides the sign inside the binomial. The last term b^2 is positive in both cases, because a square is never negative.
A three-part test
A trinomial is a perfect square trinomial when all three conditions hold:
- The first term is a perfect square, a^2.
- The last term is a perfect square, b^2.
- The middle term is 2ab or -2ab. That is, its absolute value is twice the product of the square roots of the first and last terms.
Condition 3 is the one that matters. Many trinomials have perfect square first and last terms but a different middle term, and those are not perfect squares.
Worked example: x^2 + 6x + 9
- The first term x^2 is the square of x, so a = x.
- The last term 9 is the square of 3, so b = 3.
- Twice the product is 2 x 3 = 6x, which matches the middle term.
All three conditions hold, and the middle term is positive:
x^2 + 6x + 9 = (x + 3)^2
Check: (x + 3)(x + 3) = x^2 + 3x + 3x + 9 = x^2 + 6x + 9Worked example: x^2 - 10x + 25
Here a = x and b = 5. Twice the product is 2 x 5 = 10x. The middle term is -10x, so the binomial uses a minus sign:
x^2 - 10x + 25 = (x - 5)^2Worked example with a larger leading coefficient: 4x^2 + 12x + 9
- 4x^2 is the square of 2x, so a = 2x.
- 9 is the square of 3, so b = 3.
- 2 (2x) 3 = 12x, which matches.
4x^2 + 12x + 9 = (2x + 3)^2
Check: (2x + 3)(2x + 3) = 4x^2 + 6x + 6x + 9 = 4x^2 + 12x + 9You could also factor this trinomial with the ac method from the previous chapter. The result is the same. The pattern is faster once you see it.
Worked example with two variables: 9x^2 - 30xy + 25y^2
Here a = 3x and b = 5y. Twice the product is 2 3x 5y = 30xy. The middle term is -30xy, so:
9x^2 - 30xy + 25y^2 = (3x - 5y)^2When the test fails
Consider x^2 + 8x + 9. The first term is x^2 and the last term is 9 = 3^2. If it were a perfect square, the middle term would be 2 x 3 = 6x. The actual middle term is 8x, so the trinomial is not a perfect square.
That does not tell you whether it factors some other way. Try the usual method: look for two integers with product 9 and sum 8. The pairs are 1 and 9 (sum 10) and 3 and 3 (sum 6). Neither sums to 8, so x^2 + 8x + 9 does not factor over the integers. That makes it a prime polynomial, a topic a later chapter covers.
Now compare x^2 + 10x + 9. Here 1 and 9 multiply to 9 and add to 10, so it factors as (x + 1)(x + 9). It is not a perfect square, but it is still factorable.
Pattern or ordinary trinomial?
For x^2 + bx + c, the two numbers that multiply to c and add to b are identical exactly when the trinomial is a perfect square. In x^2 + 6x + 9 the numbers are 3 and 3. In x^2 - 10x + 25 they are -5 and -5. So the monic method from the earlier chapter already finds perfect squares, and you can treat the pattern as a way to spot this case early.
The pattern also helps when the coefficients are large. For 49x^2 - federal-size numbers you might not want to list factor pairs, but a quick check works: 49x^2 - 42x + 9 has a = 7x, b = 3, and 2 7x 3 = 42x, so it equals (7x - 3)^2.
Perfect squares inside a larger problem
Pull out a common factor first
Always look for a greatest common factor before applying any pattern. Consider 3x^2 + 18x + 27.
3x^2 + 18x + 27
= 3(x^2 + 6x + 9)
= 3(x + 3)^2Without the GCF step, the coefficients 3 and 27 are not both perfect squares, and you might wrongly decide the pattern does not apply. The same happens with 50x^2 - 20x + 2. Factor out 2 first:
50x^2 - 20x + 2 = 2(25x^2 - 10x + 1) = 2(5x - 1)^2If you work with a negative leading coefficient, factor out -1 first. For -x^2 + 4x - 4:
-x^2 + 4x - 4 = -(x^2 - 4x + 4) = -(x - 2)^2Combine with a difference of squares
Some polynomials need the perfect square pattern and then the difference of squares. Take x^2 + 6x + 9 - y^2. Group the first three terms, which form a perfect square:
x^2 + 6x + 9 - y^2
= (x + 3)^2 - y^2
= ((x + 3) - y)((x + 3) + y)
= (x + 3 - y)(x + 3 + y)Here the perfect square trinomial turns a four-term polynomial into a difference of squares, where a = x + 3 and b = y. This is an alternative to factoring by grouping, and it works when grouping pairs does not.
A fourth-degree example
The pattern applies when the variable part is any perfect square power. For x^4 + 4x^2 + 4, let a = x^2 and b = 2. Then 2ab = 4x^2, which matches:
x^4 + 4x^2 + 4 = (x^2 + 2)^2The factor x^2 + 2 is a sum of squares with no common factor, so it cannot be factored further over the integers. The factorization is complete.
Reading the pattern in reverse
Recognizing perfect squares helps in other places. Two common uses:
- Checking a square. To expand (4x - 7)^2 you can write 16x^2 - 56x + 49 directly: square the first term, double the product, square the last term.
- Solving equations. If x^2 - 8x + 16 = 0, the trinomial is (x - 4)^2, so (x - 4)^2 = 0. The zero product property gives x - 4 = 0 twice, so x = 4. The solution x = 4 is a repeated root because the factor appears twice.
A decision flow
The diagram shows how to test a trinomial for the perfect square pattern, then fall back on other methods.
Common errors
| Error | Example | Correction |
|---|---|---|
| Skipping the middle-term test | x^2 + 8x + 16 treated as (x + 4)^2 | 2 * x * 4 = 8x, so this one is correct. But x^2 + 6x + 16 is not (x + 4)^2, because 2 * x * 4 = 8x, not 6x. |
| Using the wrong sign | x^2 - 6x + 9 written as (x + 3)^2 | The middle term is negative, so the answer is (x - 3)^2. |
| Forgetting to square the coefficient | 4x^2 + 12x + 9 written as (4x + 3)^2 | The square root of 4x^2 is 2x, so the answer is (2x + 3)^2. |
| Treating a sum of squares as a pattern | x^2 + 9 written as (x + 3)^2 | x^2 + 9 has no middle term and is prime over the integers. |
| Stopping before the GCF | 2x^2 + 12x + 18 left alone | Factor 2 first: 2(x + 3)^2. |
Checking with SymPy
SymPy can confirm your work. The factor function recognizes perfect squares and returns them in power form.
from sympy import symbols, factor, expand
x, y = symbols('x y')
examples = [
x**2 + 6*x + 9,
4*x**2 + 12*x + 9,
3*x**2 + 18*x + 27,
9*x**2 - 30*x*y + 25*y**2,
x**2 + 8*x + 9,
]
for expr in examples:
factored = factor(expr)
print(expr, "->", factored, expand(factored) == expr)The last example, x^2 + 8x + 9, comes back unchanged. That is how SymPy reports that the polynomial does not factor over the integers. Each line ends with True because expanding the result gives back the original expression.
Exercises
Exercise
Factor 16x^2 + 40x + 25 completely and verify your answer by expanding.
Show answer
The first term is (4x)^2 and the last term is 5^2. The middle term should be 2 4x 5 = 40x, which matches and is positive. So 16x^2 + 40x + 25 = (4x + 5)^2. Check: (4x + 5)(4x + 5) = 16x^2 + 20x + 20x + 25 = 16x^2 + 40x + 25.
Exercise
Is x^2 - 12x + 25 a perfect square trinomial? If not, can it be factored over the integers?
Show answer
No. The first term is x^2 and the last term is 5^2, so a perfect square would need a middle term of -2 x 5 = -10x. The actual middle term is -12x. To factor with the general method, look for two integers with product 25 and sum -12. The pairs are -1 and -25 (sum -26) and -5 and -5 (sum -10). None gives -12, so the trinomial is prime over the integers.
Exercise
Factor 12x^2 - 36x + 27 completely.
Show answer
Factor out the GCF 3: 3(4x^2 - 12x + 9). Inside, 4x^2 = (2x)^2 and 9 = 3^2, and 2 2x 3 = 12x, so with the negative sign 4x^2 - 12x + 9 = (2x - 3)^2. The complete answer is 3(2x - 3)^2.
Exercise
Factor x^2 - 10x + 25 - 4y^2 using the perfect square pattern followed by a difference of squares.
Show answer
The first three terms are a perfect square: x^2 - 10x + 25 = (x - 5)^2. The expression becomes (x - 5)^2 - (2y)^2. Apply the difference of squares: ((x - 5) - 2y)((x - 5) + 2y) = (x - 5 - 2y)(x - 5 + 2y).
Exercise
Solve x^2 + 14x + 49 = 0.
Show answer
The trinomial is a perfect square: x^2 + 14x + 49 = (x + 7)^2, because 2 x 7 = 14x. So (x + 7)^2 = 0, which gives x + 7 = 0 and x = -7. This is a repeated root, since the factor x + 7 appears twice.