Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Factor by Grouping

Split four terms into two pairs and factor each pair. If the two brackets that appear are the same, that bracket is a common factor of the whole expression.

Recognize the task

Four terms with no common factor overall: x3+3x2+2x+6x^3 + 3x^2 + 2x + 6, 2ax−6a+bx−3b2ax - 6a + bx - 3b, x3−5x2−4x+20x^3 - 5x^2 - 4x + 20. Also the middle step of the ac method for trinomials.
The lesson section is Factoring by Grouping; each pair is factored by its greatest common factor.

Steps

StepOn x3+3x2+2x+6x^3 + 3x^2 + 2x + 6
1Group the terms in two pairs. Usually the first two and the last two.(x3+3x2)+(2x+6)(x^3 + 3x^2) + (2x + 6)
2Factor the GCF out of each pair. If the second pair starts with a minus, factor out a negative so the brackets match.x2(x+3)+2(x+3)x^2(x + 3) + 2(x + 3)
3Factor out the common bracket. If the brackets differ, regroup the four terms in another order.(x+3)(x2+2)(x + 3)(x^2 + 2)
4Factor further and check by expanding. A leftover difference of squares, for instance, still factors.Distribute every term ↗x2+2x^2 + 2 does not factor; expanding gives back the original ✓

Worked examples

Example 1 · two letters

basic
2ax−6a+bx−3b=2a(x−3)+b(x−3)2ax - 6a + bx - 3b = 2a(x - 3) + b(x - 3)
(x−3)(2a+b)(x - 3)(2a + b)

Example 2 · a negative second pair

factor out −4
x3−5x2−4x+20=x2(x−5)−4(x−5)x^3 - 5x^2 - 4x + 20 = x^2(x - 5) - 4(x - 5)
take −4-4 out of the second pair
(x−5)(x2−4)=(x−5)(x−2)(x+2)(x - 5)(x^2 - 4) = (x - 5)(x - 2)(x + 2)
difference of squares left

Example 3 · regroup first

brackets did not match
ax+by+bx+ayax + by + bx + ay: pairs (ax+by)(ax + by), (bx+ay)(bx + ay) share nothing
(ax+ay)+(bx+by)=a(x+y)+b(x+y)=(a+b)(x+y)(ax + ay) + (bx + by) = a(x + y) + b(x + y) = (a + b)(x + y)
swap the middle terms

See it happen

FOIL, generalized. Multiply each term of the left polynomial by each term of the right — that's the grid. Group cells with the same power of x into like-term buckets, then sum each bucket.
Pick an example or build your own
Left polynomial — P(x)
x2 − 3x + 2
x
x
x
Right polynomial — Q(x)
2x + 5
x
x
0 / 6 cells
P(x) · Q(x) — pairwise products and collection
Left has 3 terms, right has 2 terms. Distributing gives 3 × 2 = 6 pairwise products. Each cell's exponent is the sum of its row and column exponents — that's how products group into like-term buckets.
2x5
x22x35x2
−3x−6x2−15x
24x10
x3 termsexp = 3
(empty)
sum: 0
x2 termsexp = 2
(empty)
sum: 0
x termsexp = 1
(empty)
sum: 0
constantsexp = 0
(empty)
sum: 0
Result (pending)
P(x) · Q(x) = ?
Multiplying (x+3)(x2+2)(x + 3)(x^2 + 2) in a grid gives four cells, x3x^3, 2x2x, 3x23x^2 and 66, one per pair of terms. Grouping reads that grid backwards: two cells share the row x2x^2, two share the row 22, and the common column is (x+3)(x + 3).

Common mistakes

Losing the sign in the second pair

✗ x3−5x2−4x+20=x2(x−5)−4(x+5)x^3 - 5x^2 - 4x + 20 = x^2(x - 5) - 4(x + 5)
✓ −4x+20=−4(x−5)-4x + 20 = -4(x - 5)

Stopping when the brackets differ

✗ "it does not factor"
✓ try another grouping of the four terms

Writing the common bracket twice

✗ (x+3)(x2+2)(x+3)(x + 3)(x^2 + 2)(x + 3)
✓ factor it out once: (x+3)(x2+2)(x + 3)(x^2 + 2)