Sub topic 6
When the variable appears in several terms: collect and factor
What you need before this chapter
This chapter assumes you can do the following:
- Solve a simple linear equation such as 3x + 2 = 11.
- Use inverse operations on both sides of an equation.
- Undo operations in reverse order when a variable appears once.
- Work with fractions and negative numbers.
Earlier chapters isolated a variable that appears in exactly one place. Undoing operations one at a time works there because the target sits at the end of a single chain of operations. This chapter covers the case where the target appears in two or more terms. No single chain exists, so you need a different move: gather the terms that contain the target, factor it out, and then divide.
Why undoing operations stops working
Take the formula 2x + 5 = 9 − x. The variable x appears on both sides. If you subtract 5, you get 2x = 4 − x. If you then divide by 2, you get x = (4 − x)/2, and x is still on the right side. You have not isolated anything. You have only rewritten the equation.
The problem is structural. Inverse operations peel layers off an expression one at a time, but the target is buried in several layers at once. To fix that, you must first combine the occurrences into one.
The three-step method
- Collect. Use addition and subtraction on both sides to move every term containing the target to one side. Move every other term to the opposite side.
- Factor. Pull the target out of the collected terms, so the target appears exactly once, multiplied by a group of other symbols.
- Divide. Divide both sides by that group.
The fourth box is not optional. Step 3 divides by an expression, and division by zero is undefined. Every time you use this method, record the condition under which the final formula is valid.
Worked example 1: numbers and one letter
Solve a·x + b = c·x + d for x, where a, b, c, and d are constants.
- Collect. Subtract c·x from both sides and subtract b from both sides: a·x − c·x = d − b.
- Factor. The left side is (a − c)·x, so (a − c)·x = d − b.
- Divide. x = (d − b)/(a − c).
The restriction is a ≠ c. If a = c, the left side becomes 0·x, and the equation reads 0 = d − b. Then there are two cases:
- If d = b, every x satisfies the equation.
- If d ≠ b, no x satisfies it.
Neither case gives a single value of x, so the formula correctly breaks down.
You can confirm the result with SymPy, a Python library for symbolic algebra:
from sympy import symbols, Eq, solve
a, b, c, d, x = symbols('a b c d x')
# a*x + b = c*x + d -> (a - c)*x = d - b -> x = (d - b)/(a - c)
print(solve(Eq(a*x + b, c*x + d), x))SymPy returns a list containing an expression equivalent to (d − b)/(a − c). It may display the signs differently, for example as (b − d)/(c − a). These forms are the same, because the numerator and denominator are both negated.
Worked example 2: a formula from finance
Simple interest with a deposit is often written as A = P + P·r·t, where A is the final amount, P is the principal (the starting deposit), r is the annual rate, and t is the time in years. Solve for P.
P appears in two terms. Do not try to move P·r·t around as if it were a separate quantity. Factor instead:
- Factor. A = P(1 + r·t).
- Divide. P = A/(1 + r·t).
The restriction is 1 + r·t ≠ 0. For realistic values, r and t are non-negative, so 1 + r·t is at least 1 and the restriction never fails. The restriction still belongs in a complete answer, because the algebra alone does not know that r and t are non-negative.
Check with numbers. Deposit 1000 at r = 0.05 for t = 2 years. Then A = 1000 + 1000·0.05·2 = 1100. Using the rearranged formula, P = 1100/(1 + 0.05·2) = 1100/1.1 = 1000. This matches.
Worked example 3: terms on both sides, with several letters
Solve for y in m·y + n = p − q·y.
- Collect. Add q·y to both sides: m·y + q·y + n = p.
- Subtract n from both sides: m·y + q·y = p − n.
- Factor. (m + q)·y = p − n.
- Divide. y = (p − n)/(m + q).
The restriction is m + q ≠ 0. Notice that the sign matters: the term −q·y moved across the equals sign and became +q·y. A common error is to leave it as −q·y, which gives m − q in the denominator.
Factoring when the target is inside a product
Sometimes the target appears in a term that is already a product of several letters. For example, solve for x in:
a·x + b·x·c = k
Both terms contain x. Factor it out of both terms: x(a + b·c) = k. Then x = k/(a + b·c).
The rule is that you factor out only the target. Other letters stay inside the parentheses, even if they are shared by some terms.
Distribution works in the other direction too
Some formulas arrive with parentheses already present. You have two options, and the better one depends on where the target is.
Consider the formula P = 2(L + W). To solve for L, the target appears once, so undo in reverse order: divide by 2, then subtract W. This gives L = P/2 − W.
Now consider a formula where the target appears both inside and outside parentheses: 3(x + a) = b − x. The target now appears twice, so you must distribute first:
- Distribute: 3x + 3a = b − x.
- Collect: 3x + x = b − 3a.
- Factor: 4x = b − 3a, so x = (b − 3a)/4.
Here the factoring step is trivial because the coefficients are numbers. With letters in place of the numbers, it is the step that matters.
A harder case: fractions mixed with several occurrences
When the target appears in several terms and some of them are fractions, clear the fractions first. Multiply every term on both sides by the common denominator. Then collect and factor.
Solve for x in x/a + x/b = 1, where a and b are nonzero.
- Clear fractions. Multiply every term by a·b: b·x + a·x = a·b.
- Factor: (a + b)·x = a·b.
- Divide: x = a·b/(a + b).
There are two restrictions here: a ≠ 0 and b ≠ 0 (the original formula needs them), and a + b ≠ 0 (the final division needs it). Keep both in your answer.
The pitfall is multiplying only some of the terms. Multiplying by a·b must reach every term, including the 1 on the right side. If you forget it, the equation is no longer balanced.
Restrictions: why the grouped coefficient can be zero
Dividing by a grouped coefficient is the only place this method can go wrong in a structural way. The table summarizes the cases from this chapter.
| Equation | Rearranged formula | Restriction | What happens when it fails |
|---|---|---|---|
| a·x + b = c·x + d | x = (d − b)/(a − c) | a ≠ c | Either all x work or none do |
| A = P(1 + r·t) | P = A/(1 + r·t) | 1 + r·t ≠ 0 | No valid P unless A = 0 |
| m·y + n = p − q·y | y = (p − n)/(m + q) | m + q ≠ 0 | Either all y work or none do |
| x/a + x/b = 1 | x = a·b/(a + b) | a + b ≠ 0 | With b = −a, the equation becomes 0 = a·b, which fails |
Be careful with the last row. When b = −a, clearing fractions gives 0·x = a·b = −a², which is nonzero for a ≠ 0. So there is no solution at all. This matches the original equation: x/a − x/a = 0, which is never equal to 1.
Common errors
- Dividing term by term. From (a − c)·x = d − b, writing x = d/(a − c) − b is wrong. Divide the entire right side by (a − c), or divide each term separately: x = d/(a − c) − b/(a − c).
- Cancelling inside a sum. In x = (d − b)/(a − c), you cannot cancel a letter that appears in only one term of the numerator against the denominator.
- Moving a term without changing its sign. Moving a term across the equals sign means adding or subtracting it from both sides, which flips the sign.
- Leaving the target on both sides. If your final answer still has the target on the right side, you have not finished. Return to the collect step.
- Forgetting the restriction. The final formula looks complete but is silently false when the divisor is zero.
A numeric check you can run
You can check any rearranged formula by choosing numbers for the constants, computing the target from your formula, and then substituting it back into the original equation. This function does that for the first worked example:
def solve_linear(a, b, c, d):
# a*x + b = c*x + d -> x = (d - b) / (a - c)
if a == c:
raise ValueError("a must differ from c; otherwise there is no single solution")
return (d - b) / (a - c)
a, b, c, d = 5, 3, 2, 12
x = solve_linear(a, b, c, d)
print(x) # 3.0
print(a * x + b == c * x + d) # TrueHere a·x + b = 18 and c·x + d = 18, so both sides agree. A single successful test does not prove the formula, but a failure proves it is wrong. Try at least two different sets of values, and avoid values that make the check trivial, such as zero or one.
Exercises
Exercise
Solve for t in s = v·t + w·t − 4. State the restriction.
Show answer
Add 4 to both sides: s + 4 = v·t + w·t. Factor: s + 4 = (v + w)·t. Divide: t = (s + 4)/(v + w). The restriction is v + w ≠ 0.
Exercise
Solve for r in A = P + P·r·t, with P and t nonzero. Then say why you cannot simply write r = A − P·t.
Show answer
Subtract P: A − P = P·r·t. Divide by P·t: r = (A − P)/(P·t). The tempting answer r = A − P·t is wrong because it treats P·r·t as if r were a separate term, and the division by P·t must apply to the whole of A − P. The restriction is P ≠ 0 and t ≠ 0.
Exercise
Solve for x in 2(x + k) = m − 3x. Check your answer with k = 1 and m = 12.
Show answer
Distribute: 2x + 2k = m − 3x. Collect: 5x = m − 2k. So x = (m − 2k)/5. With k = 1 and m = 12, x = 10/5 = 2. Check: 2(2 + 1) = 6 and 12 − 3·2 = 6. Both sides match.
Exercise
Solve for x in x/p − x/q = 1, with p and q nonzero. When does the final formula fail?
Show answer
Multiply every term by p·q: q·x − p·x = p·q. Factor: (q − p)·x = p·q. Divide: x = p·q/(q − p). It fails when q = p. In that case the original equation reads 0 = 1, which has no solution.