One expression, written two ways
Suppose you are told that for every value of x, and you are asked for a and b. Expand the left side first: .
So for every x. The two sides are the same expression, written in two ways: one with letters in its coefficients, and one with numbers.
Why each part must match
An equation such as 2x + 5 = 11 is true for one value of x only. This statement is stronger, because it holds for every x, and that forces the two sides to agree part by part.
Substitution shows it. Put x = 0 into both sides: every term with an x becomes 0, which leaves ab = 12. So the constant terms match. Now put x = 1 into both sides, which gives 1 + (a + b) + ab = 1 + 7 + 12. The terms both give 1, and ab is 12, so what is left must be equal too: a + b = 7. The x terms match.
This is matching coefficients. When two expressions are equal for every x, the terms are equal, the x terms are equal and the constant terms are equal. One statement becomes one equation for each part.
Two equations, two unknowns
Matching gives a + b = 7 and ab = 12. You need two numbers that add to 7 and multiply to 12: 3 and 4. So a = 3 and b = 4, or the other way round. Check: .
the middle term is the sum of the two strips: 2x + 3x = 5x
Find the split whose strips make 7x and whose corner makes 12
The rectangle is (x + a) by (x + b). Drag its corner to change a and b. The two strips make the x term, (a + b)x, and the corner makes the constant term, ab. Only a = 3 and b = 4 make 7x and 12 at once.
Find one letter, then the next
Suppose p(x + 3) = 4x + q for every x. Expand the left side: px + 3p = 4x + q.
Match the x terms: px = 4x, so p = 4. Then match the constant terms: 3p = q. Since p = 4, q = 3 × 4 = 12. So 4(x + 3) = 4x + 12, which is true for every x.
Matching the constants before finding p gives only 3p = q, which has two unknowns. Match the part with one unknown first, and use its value in the next.
The usual mistakes
Matching before expanding. In p(x + 3) = 4x + q, the constant on the left is not 3 but 3p, and that only shows once the bracket is multiplied out.
Matching the parts of an ordinary equation. 5x + 2 = 3x + 8 is true only when x = 3, not for every x, so its x terms do not have to match. Matching works only when the two sides are equal for every value of x.