math.wiki
Algebra › Expressions › Factoring by grouping
Open on the map
Algebra 1 · A.SSE.A.2

Factoring by grouping

Four terms share no factor, all four together. Can the sum still be written as a product?

Where you are 12 in Expressions

When you reach for it

Taking out the greatest common factor works when one monomial divides every term. Now take

xy + 2x + 5y + 10

The four terms share no factor except 1: the first two contain x, the last two do not, and 10 has nothing in common with xy. Yet this polynomial is a product. It equals (x + 5)(y + 2), as multiplying the two binomials confirms. Factoring by grouping is the way back from the four terms to that product. Reach for it when a polynomial has four terms, no factor common to all of them, but pairs of terms that do share a factor.

The procedure

A bracket can be the common factor

Look at

x(y + 2) + 5(y + 2)

It has two terms, and both contain the factor (y + 2). The distributive property says aB + cB = (a + c)B for any numbers a, c and B, and nothing stops B from being the number y + 2. So

\begin{aligned} &x(y + 2) + 5(y + 2) \\ &= (x + 5)(y + 2) \end{aligned}

This is exactly the move of taking out a monomial. The only difference is that the shared factor is a binomial, kept whole inside its brackets, and what is left of each term, x and 5, forms the other bracket.

Making the bracket appear

Back to xy + 2x + 5y + 10. Addition can be grouped any way we like (the associative property), so split the four terms into two pairs and take out each pair’s greatest common factor:

\begin{aligned} &(xy + 2x) + (5y + 10) \\ &= x(y + 2) + 5(y + 2) \end{aligned}

The two brackets are the same, so the bracket is now a common factor of two terms, and it comes out as above, so xy + 2x + 5y + 10 is (x + 5)(y + 2).

The match is what decides success. If the pairs had left x(y + 2) + 5(y + 3), there would be no common factor and nothing more to take out. When the brackets do not match at first, three rewrites can repair it, and each one changes the form of the expression but never its value.

A negative factor. If the second pair starts with a minus sign, taking out a negative number flips every sign inside its bracket, which is often what makes it match the first (Example 3).

Opposite brackets. a - b and b - a are opposites, because b - a = -(a - b). So 5(2 - x) is the same as -5(x - 2), and a bracket can be turned round at the cost of a sign.

Another order. Addition is commutative, so the four terms may be reordered and paired differently (Example 4).

The picture

An aquarium’s floor plan is a rectangle, divided into four rectangular sections by one wall running across and one running along. Across, the sections are 3x and 2 meters wide; along, they are y and 4 meters deep. The four areas are 3xy, 12x, 2y and 8 square meters, so the whole floor has area

3xy + 12x + 2y + 8
3xy
2y
12x
8
3x
2
y
4
3x + 2
y + 4
Figure 1The aquarium floor. The shaded column is 3x(y + 4), the other column is 2(y + 4), and together they make (3x + 2)(y + 4).

Pair the two sections in the left column: 3xy + 12x = 3x(y + 4), a strip 3x wide and y + 4 deep. The right column is 2y + 8 = 2(y + 4), a strip 2 wide and the same depth. The shared bracket y + 4 is that shared depth, and the two strips side by side make one rectangle:

\begin{aligned} &3x(y + 4) + 2(y + 4) \\ &= (3x + 2)(y + 4) \end{aligned}

Pairing the rows instead, 3xy + 2y = y(3x + 2) and 12x + 8 = 4(3x + 2), gives (y + 4)(3x + 2), the same product. Grouping is reading four pieces of a rectangle as two strips.

Checking

Multiply the factors back out. If the expansion gives the original four terms, the factoring is right. Multiplying never needs a guess, so this check always settles the question.

Worked examples

Example 1

A bracket as the common factor

Factor (a) 3a(b - 4) + 7(b - 4) \qquad (b) 2p(p + 5) - (p + 5) \qquad (c) 6x(x - 2) + 5(2 - x)

Solution

(a) Both terms contain (b - 4). Taking it out leaves 3a from the first term and 7 from the second:

3a(b - 4) + 7(b - 4) = (b - 4)(3a + 7)

(b) The second term is -(p + 5), which is -1 \cdot (p + 5). Writing the hidden 1 shows that this term leaves -1 behind, not nothing:

2p(p + 5) - 1(p + 5) = (p + 5)(2p - 1)

Check: (p + 5)(2p - 1) expands to 2p^2 - p + 10p - 5, which is 2p^2 + 9p - 5, and the original expands to 2p^2 + 10p - p - 5, the same.

(c) The brackets x - 2 and 2 - x are opposites. Rewrite 5(2 - x) as -5(x - 2), which is allowed because -5 \cdot x = -5x and -5 \cdot (-2) = 10:

\begin{aligned} &6x(x - 2) + 5(2 - x) \\ &= 6x(x - 2) - 5(x - 2) \\ &= (x - 2)(6x - 5) \end{aligned}
Example 2

Four terms

Factor (a) mn + 6m + 2n + 12 \qquad (b) 2x^3 + 6x^2 + 5x + 15

Solution

(a) No factor divides all four terms. The first pair shares m and the second shares 2:

\begin{aligned} &(mn + 6m) + (2n + 12) \\ &= m(n + 6) + 2(n + 6) \\ &= (n + 6)(m + 2) \end{aligned}

Check: (n + 6)(m + 2) expands to mn + 2n + 6m + 12, the original terms in another order.

(b) The greatest common factor of 2x^3 and 6x^2 is 2x^2, and that of 5x and 15 is 5:

\begin{aligned} &2x^2(x + 3) + 5(x + 3) \\ &= (x + 3)(2x^2 + 5) \end{aligned}

Each pair needs its greatest common factor. Taking only x out of the first pair would leave x(2x^2 + 6x), whose bracket can never match x + 3.

Example 3

A negative factor to take out

Factor (a) x^3 - 4x^2 - 3x + 12 \qquad (b) 5ab - 15a - b + 3 \qquad (c) ac - bc + 2b - 2a

Solution

(a) The first pair gives x^2(x - 4). Taking 3 out of -3x + 12 gives 3(-x + 4), which does not match. Take out -3 instead: -3 \cdot x = -3x and -3 \cdot (-4) = 12, so -3x + 12 = -3(x - 4). Now

\begin{aligned} &x^3 - 4x^2 - 3x + 12 \\ &= x^2(x - 4) - 3(x - 4) \\ &= (x - 4)(x^2 - 3) \end{aligned}

Check: (x - 4)(x^2 - 3) expands to x^3 - 3x - 4x^2 + 12. The bracket x^2 - 3 has no factor with integer coefficients, since 3 is not a perfect square, so it is left as it is.

(b) The first pair gives 5a(b - 3). The second pair, -b + 3, has no common factor other than \pm 1, and it is the -1 that makes it match: -b + 3 = -1(b - 3). So

\begin{aligned} &5ab - 15a - b + 3 \\ &= 5a(b - 3) - 1(b - 3) \\ &= (b - 3)(5a - 1) \end{aligned}

(c) Taking out c and then 2 gives c(a - b) + 2(b - a): opposite brackets. Taking out -2 from the second pair instead turns its bracket round, since -2 \cdot a = -2a and -2 \cdot (-b) = 2b:

\begin{aligned} &ac - bc + 2b - 2a \\ &= c(a - b) - 2(a - b) \\ &= (a - b)(c - 2) \end{aligned}

Check: (a - b)(c - 2) expands to ac - 2a - bc + 2b, the same four terms.

Example 4

Pairing in another order

Factor ab + 21 + 3a + 7b.

Solution

Paired as written, (ab + 21) + (3a + 7b), neither pair has a common factor other than 1. That does not end the matter, because which terms are paired is a choice. Addition is commutative, so put terms that share a letter next to each other:

\begin{aligned} &ab + 3a + 7b + 21 \\ &= a(b + 3) + 7(b + 3) \\ &= (b + 3)(a + 7) \end{aligned}

The order ab + 7b + 3a + 21 works too: b(a + 7) + 3(a + 7), which is (a + 7)(b + 3), the same product with its factors swapped, which multiplication allows.

Example 5

When no pairing works

Factor xy + 2x + 3y + 5, or show that it cannot be done.

Solution

Four terms split into two pairs in exactly three ways, decided by which term goes with xy:

xy with 2x gives x(y + 2) + (3y + 5).

xy with 3y gives y(x + 3) + (2x + 5).

xy with 5 gives (xy + 5) + (2x + 3y).

In the first two the second pair has no common factor and its bracket does not match; in the third neither pair has a common factor. No reordering helps, since these are all the pairings there are. Grouping fails.

Grouping failing is not yet a proof that no factors exist (see Boundaries), so here is the argument. Suppose xy + 2x + 3y + 5 were a product of two polynomials with integer coefficients. The letter x appears only to the first power. If both factors contained x, multiplying them would make an x^2 term, so at most one factor contains x. The same holds for y. That leaves two cases.

One factor contains no letter at all. Then it is an integer that divides every coefficient, 1, 2, 3 and 5, so it is 1 or -1, and writing the polynomial as 1 or -1 times something is not a real factorization.

Otherwise one factor contains x but not y, and the other contains y but not x, so the product is (mx + p)(ny + q) with integers m, n, p and q. Its xy term is mnxy, so mn = 1, and m and n are both 1 or both -1. If both are -1, take -1 out of each factor; since (-1)(-1) = 1 this changes nothing. Either way the product can be written as (x + p)(y + q). But

(x + p)(y + q) = xy + qx + py + pq

Matching the x and y terms forces q = 2 and p = 3, and then the constant would be pq = 6, not 5. So xy + 2x + 3y + 5 is not a product of polynomials with integer coefficients. It is exactly 1 less than (x + 3)(y + 2).

Example 6

Counting pots

A plant nursery fills seed trays on Monday and Tuesday. Every tray holds a pots of basil and c pots of chives, and every tray is filled. On Monday r trays are filled, on Tuesday s trays. Kit counts the pots as ra + rc + sa + sc. Factor the count and say what each factor means, then find the count when a = 8, c = 4, r = 15 and s = 20.

Solution

Each term is a number of pots: ra is Monday’s basil pots, trays times basil pots per tray. Pair the terms by day:

\begin{aligned} &ra + rc + sa + sc \\ &= r(a + c) + s(a + c) \\ &= (r + s)(a + c) \end{aligned}

The middle form reads as Monday’s pots plus Tuesday’s, since a + c is the number of pots in one tray. The product reads as the trays filled over both days, r + s, times the pots per tray, a + c.

With the numbers, r + s = 35 and a + c = 12, so the count is 35 \cdot 12 = 420 pots. Check from the four terms: 120 + 60 + 160 + 80 = 420. The factored form needs one multiplication where the original needs four.

Boundaries

The brackets must be identical. After every allowed rewrite (a negative factor, an opposite bracket turned round, another order), the two brackets must be the same expression. If they never are, grouping does not apply.

Grouping failing does not prove a polynomial has no factors. In x^3 + 2x^2 + 3x + 2 the three pairings give x^2(x + 2) + (3x + 2), then x(x^2 + 3) + 2(x^2 + 1), then (x^3 + 2) + x(2x + 3), and none match. Yet

\begin{aligned} &x^3 + 2x^2 + 3x + 2 \\ &= (x + 1)(x^2 + x + 2) \end{aligned}

Grouping is one method among several. Showing that no factorization exists takes an argument of its own, like the one in Example 5.

A factor common to all four terms comes out first. Grouping 2xy + 4x + 6y + 12 directly gives 2x(y + 2) + 6(y + 2), which is (2x + 6)(y + 2): true but unfinished, since 2x + 6 = 2(x + 3). Taking out 2 first gives 2(x + 3)(y + 2).

Factors here have integer coefficients. x^2 - 3 equals \displaystyle (x - \sqrt{3})(x + \sqrt{3}) over the real numbers, but with integer coefficients it has no factors, so Example 3 stops at (x - 4)(x^2 - 3).

The picture needs positive lengths; the algebra does not. A section -2 meters wide cannot be drawn, but every step uses only the distributive, associative and commutative properties, which hold for all numbers.

Where this goes next

A trinomial has only three terms, but splitting its middle term into two makes four, which can then be grouped: that is how trinomials with a leading coefficient other than one are factored. A bracket that grouping leaves behind may factor again: x^3 - 3x^2 - 4x + 12 becomes (x - 3)(x^2 - 4), and x^2 - 4 is a difference of squares, so the whole is (x - 3)(x - 2)(x + 2). Pressing on until no factor breaks down further is factoring completely. Once a polynomial is a product, an equation such as (x - 4)(x^2 - 3) = 0 splits into one equation per factor, by the zero product property.

Exercises

A bracket as the common factor

  1. 4x(y + 3) + 5(y + 3)
  2. 7k(k - 2) - 3(k - 2)
  3. a(2a + 1) + (2a + 1)

Four terms

  1. pq + 5p + 3q + 15
  2. 3x^3 + 12x^2 + 2x + 8
  3. 6uv + 4u + 9v + 6

Taking out a negative

  1. x^3 - 2x^2 - 7x + 14
  2. 4rs - 8r - s + 2
  3. 2a^3 - a^2 - 10a + 5

Making the brackets match

  1. xy + 18 + 6x + 3y
  2. 2x^3 + 15 + 5x^2 + 6x
  3. 3m(n - 5) + 8(5 - n)
  4. pr - qr + 4q - 4p
  5. Factor ab + 3a + 4b + 10 by grouping, or show that no pairing works and that it has no factors with integer coefficients.

In context

  1. A second aquarium floor is a rectangle split, like the one above, into four rectangular sections with areas 2xy, 10x, 3y and 15 square meters. Write its total area as a product of two side lengths, and find the area when x = 4 and y = 3.
  2. In Example 6, pair Kit’s count as (ra + sa) + (rc + sc) instead. Factor it, say what each part of the middle form counts, and find both parts for the numbers in Example 6.

Reasoning

  1. Show that both pairings (ac + ad) + (bc + bd) and (ac + bc) + (ad + bd) give the same product, and explain with a rectangle cut into four pieces why they must.
  2. Consider the claim: “x^3 + 3x^2 + 4x + 2 has no factors, because no pairing of its terms gives a shared bracket.” Check the three pairings, then multiply out (x + 1)(x^2 + 2x + 2). What is wrong with the reasoning in the claim?
Answers
  1. (y + 3)(4x + 5). Both terms contain (y + 3); 4x and 5 are left.
  2. (k - 2)(7k - 3). The terms leave 7k and -3.
  3. (2a + 1)(a + 1). The second term is 1(2a + 1), so it leaves 1.
  4. (q + 5)(p + 3). p(q + 5) + 3(q + 5).
  5. (x + 4)(3x^2 + 2). 3x^2(x + 4) + 2(x + 4).
  6. (3v + 2)(2u + 3). 2u(3v + 2) + 3(3v + 2).
  7. (x - 2)(x^2 - 7). x^2(x - 2) - 7(x - 2), taking out -7 from the second pair.
  8. (s - 2)(4r - 1). 4r(s - 2) - 1(s - 2).
  9. (2a - 1)(a^2 - 5). a^2(2a - 1) - 5(2a - 1).
  10. (y + 6)(x + 3). Reorder to xy + 6x + 3y + 18, which is x(y + 6) + 3(y + 6).
  11. (2x + 5)(x^2 + 3). Reorder by powers to 2x^3 + 5x^2 + 6x + 15, which is x^2(2x + 5) + 3(2x + 5).
  12. (n - 5)(3m - 8). 8(5 - n) = -8(n - 5), so the sum is 3m(n - 5) - 8(n - 5).
  13. (p - q)(r - 4). r(p - q) + 4(q - p), which is r(p - q) - 4(p - q).
  14. No factors. The pairings give a(b + 3) + 2(2b + 5), b(a + 4) + (3a + 10) and (ab + 10) + (3a + 4b), and none match. By the argument of Example 5, a factorization would have to be (a + p)(b + q), which expands to ab + qa + pb + pq, with q = 3 and p = 4, so the constant would be 12, not 10.
  15. (2x + 3)(y + 5) square meters, from 2x(y + 5) + 3(y + 5). At x = 4, y = 3 the area is 11 \cdot 8 = 88 square meters; check, 24 + 40 + 9 + 15 = 88.
  16. a(r + s) + c(r + s), which is (r + s)(a + c), the same product. a(r + s) is the basil pots over both days and c(r + s) the chive pots: 8 \cdot 35 = 280 and 4 \cdot 35 = 140, which add to 420.
  17. a(c + d) + b(c + d) is (a + b)(c + d), and c(a + b) + d(a + b) is (c + d)(a + b), equal because multiplication is commutative. Draw a rectangle with widths a, b across and heights c, d down. The first pairing reads it as two columns, the second as two rows; both are the same (a + b) by (c + d) rectangle.
  18. The pairings give x^2(x + 3) + 2(2x + 1), x(x^2 + 4) + (3x^2 + 2) and (x^3 + 2) + x(3x + 4), and none match. But (x + 1)(x^2 + 2x + 2) expands to x^3 + 2x^2 + 2x + x^2 + 2x + 2, which is x^3 + 3x^2 + 4x + 2. The pairings show only that grouping fails, not that the polynomial has no factors.
kg1128 · updated 2026-10-10 · CC-BY-SA-4.0