Here is a technique that looks like magic the first time you see it, and then becomes the most reliable tool in your algebra kit. Problems that look like they need clever guessing collapse into routine linear systems once you see the trick.

The setup is always the same. Somebody writes down an identity — an equation in x that is supposed to hold for every value of x — and leaves some unknown constants (usually called A, B, C, k, and so on) sitting inside it. You have to find those constants.

The technique: compare coefficients. The constant term on the left must equal the constant term on the right. The coefficient of x on the left must equal the coefficient of x on the right. The coefficient of x² on the left must equal the coefficient of x² on the right. And so on, power by power.

One equation-in-x becomes several equations in the unknown constants. Linear system. Solve. Done.

Why coefficient comparison works

This is not a convention or a trick of notation — it is a theorem. Here is why it is true.

Suppose p(x) and q(x) are polynomials, and suppose p(x) = q(x) for every real number x. Consider their difference, r(x) = p(x) - q(x). Since p and q agree everywhere, r(x) = 0 for every x.

Now, the only polynomial that equals zero for every x is the zero polynomial — the one where every single coefficient is 0. (A non-zero polynomial of degree n can have at most n roots; it cannot vanish at infinitely many points.)

So every coefficient of r = p - q must be zero. But the coefficient of x^k in p - q is just (coefficient of x^k in p) - (coefficient of x^k in q). If their difference is zero, they are equal.

Conclusion: if p(x) = q(x) for all x, then coefficient-by-coefficient, p and q match. That is your license. Whenever you see "for all x," you may compare coefficients.

The partial-fraction decomposition problem

Here is the classic application. You will meet this when you learn integration.

Problem: find constants A and B such that

1 / ((x-1)(x+2)) = A/(x-1) + B/(x+2).

Multiply both sides by (x-1)(x+2) to clear denominators:

1 = A(x+2) + B(x-1).

Expand the right-hand side:

1 = Ax + 2A + Bx - B = (A + B)x + (2A - B).

The left-hand side is just the constant 1 — you can read it as 0·x + 1. Now compare coefficients:

This is a simple two-variable linear system. Adding the equations: 3A = 1, so A = 1/3. And then B = -A = -1/3.

Two unknowns found, cleanly, with no guessing.

A cleaner example

Find A, B, C such that x² + 1 = A(x-1)² + B(x-1) + C for all x.

Expand the right-hand side:

A(x² - 2x + 1) + B(x - 1) + C = Ax² + (-2A + B)x + (A - B + C).

Compare coefficients:

Answer: A = 1, B = 2, C = 2. Three unknowns, three equations, all determined.

Alternative — substitute specific values

There is a sister technique that you should also know: plug in clever values of x.

Take the same identity x² + 1 = A(x-1)² + B(x-1) + C.

Set x = 1. The (x-1) factors kill the A and B terms:

1 + 1 = 0 + 0 + C, so C = 2.

One unknown, one substitution. This is lightning-fast when the identity contains factors with clean zeros that knock out most of the right-hand side.

When coefficient comparison beats substitution

When substitution beats coefficient comparison

The two techniques are not rivals; they are partners. A strong student carries both and picks whichever is shorter for the problem at hand.

Applications

Coefficient comparison is not a party trick. You will use it constantly:

Worked example — partial fractions

Decompose (3x + 5) / ((x+1)(x+2)) into simpler fractions:

(3x + 5) / ((x+1)(x+2)) = A/(x+1) + B/(x+2).

Multiply both sides by (x+1)(x+2):

3x + 5 = A(x+2) + B(x+1).

Expand the right-hand side:

3x + 5 = (A + B)x + (2A + B).

Compare coefficients:

Subtract the first from the second: A = 2. Then B = 3 - A = 1.

So (3x + 5) / ((x+1)(x+2)) = 2/(x+1) + 1/(x+2). You can check by combining the right side — the numerator rebuilds to 3x + 5. It works.

Why the technique is reliable

Here is the guarantee. If you expand the right-hand side fully, you get a polynomial with coefficients that are linear combinations of your unknown constants. You get one equation for each distinct power of x appearing anywhere.

If you have k unknowns and the expanded polynomial has degree at least k - 1, you get at least k equations — enough to pin down all the unknowns (provided the system is not degenerate, which well-posed textbook problems will not be).

Coefficient comparison never asks you to guess. It does not require hunting for lucky substitution values. It is a mechanical procedure: expand, group by powers, match, solve.

Recognition drill

For each identity, name what you would compare:

When you see the phrase "for all x" attached to a polynomial equation with unknown constants inside, that is your cue. Translate it instantly: "coefficient comparison is legal here."

Closing

"Equal for all x" is not just a piece of Latin decoration. It is a license. It lets you replace one polynomial identity by n linear equations in the unknown constants — one equation per power of x.

Every single time you see an identity with letters floating inside it, ask: expand, then match. The mess of x's disappears and you are left with a system of numbers. Linear algebra finishes the job.

That is the whole trick. Simple to state, endlessly useful, and a permanent resident of your algebra toolkit.