Sub topic 3
Undoing operations with inverses
This chapter assumes you can do arithmetic with integers, fractions, and decimals, and that you know the order of operations. It also assumes you know a variable is a letter standing for a number, and that you have seen the balance principle: doing the same thing to both sides of an equation keeps the solution unchanged. Here you learn which operation to apply, and in what order, so that the variable ends up alone.
What an inverse operation is
An inverse operation undoes another operation. If you start with a number, apply an operation, and then apply its inverse, you get the original number back.
| Operation | Inverse | Example of undoing |
|---|---|---|
| Add n | Subtract n | (x + 5) - 5 = x |
| Subtract n | Add n | (x - 5) + 5 = x |
| Multiply by n (n ≠ 0) | Divide by n | (3x) / 3 = x |
| Divide by n (n ≠ 0) | Multiply by n | (x / 3) * 3 = x |
Addition and subtraction are inverses of each other, and so are multiplication and division. The two pairs do not mix: subtracting never undoes a multiplication.
Why this isolates the variable
The goal of solving is to get an equation of the form x = number. The variable starts out with operations attached to it, such as "times 3" or "plus 5". Each inverse removes one of them. Because you apply the inverse to both sides, every new equation is equivalent to the one before it, so the solution never changes.
Take x + 5 = 12. Subtracting 5 from the left side leaves x, because x + 5 - 5 = x. Subtracting 5 from the right side gives 7. The result is x = 7.
Inverses as identity elements
Each inverse works because it brings the number back to a neutral value.
- Adding a number and then its opposite adds 0, and adding 0 changes nothing. The opposite of 5 is -5, called the additive inverse.
- Multiplying by a number and then dividing by it multiplies by 1, and multiplying by 1 changes nothing. Dividing by n is the same as multiplying by 1/n, called the reciprocal or multiplicative inverse.
So "subtract 5" and "add -5" are the same step. "Divide by 3" and "multiply by 1/3" are also the same step. Pick whichever form is easier to carry out.
Undo in reverse order
An equation such as 3x + 5 = 17 builds the result in two stages. Starting from x, you first multiply by 3, then add 5. To get back to x you must undo the last operation first. This is like taking off your shoes before your socks, when you put the socks on first.
If you divide by 3 first, you must divide every term on the left, including the 5. That gives x + 5/3 = 17/3, which is correct but leaves messy fractions. Undoing in reverse order keeps the arithmetic clean. A useful rule is to undo operations in the opposite order from the order of operations: addition and subtraction first, then multiplication and division.
Worked examples
An addition and a multiplication
Solve 3x + 5 = 17.
- Subtract 5 from both sides: 3x = 12.
- Divide both sides by 3: x = 4.
Check: 3(4) + 5 = 17.
A division and a subtraction
Solve x/4 - 2 = 6.
- Add 2 to both sides: x/4 = 8.
- Multiply both sides by 4: x = 32.
Check: 32/4 - 2 = 8 - 2 = 6.
A coefficient that is a fraction
Solve (2/3)x = 10.
The variable is multiplied by 2/3. The inverse is multiplying by the reciprocal, 3/2.
- Multiply both sides by 3/2: x = 10 * 3/2 = 15.
Check: (2/3)(15) = 10. Multiplying by the reciprocal is faster than dividing by 2/3 and then simplifying.
Negative coefficients
Solve -x + 3 = 10.
- Subtract 3 from both sides: -x = 7.
- Divide both sides by -1, which is the same as multiplying by -1: x = -7.
The term -x means "-1 times x". The inverse is dividing by -1, so the sign of the right side flips. A common error is stopping at -x = 7 and reporting 7.
Letting a program undo the steps
You can model an equation as a list of operations applied to x, then undo the list in reverse using the inverse table. The program uses Fraction so that results stay exact.
from fractions import Fraction
INVERSE = {"+": "-", "-": "+", "*": "/", "/": "*"}
def apply(op, value, n):
if op == "+":
return value + n
if op == "-":
return value - n
if op == "*":
return value * n
if op == "/":
return value / n
raise ValueError(f"unknown operation: {op}")
def forward(steps, x):
"""Apply the steps to x in order and return the result."""
value = Fraction(x)
for op, n in steps:
value = apply(op, value, Fraction(n))
return value
def undo_steps(steps, result):
"""Find x such that applying the steps to x gives result."""
value = Fraction(result)
for op, n in reversed(steps):
n = Fraction(n)
if op in ("*", "/") and n == 0:
raise ValueError("multiplying or dividing by 0 cannot be undone")
value = apply(INVERSE[op], value, n)
return value
# 3x + 5 = 17
steps = [("*", 3), ("+", 5)]
x = undo_steps(steps, 17)
print(x) # 4
print(forward(steps, x)) # 17
# x/4 - 2 = 6
steps = [("/", 4), ("-", 2)]
x = undo_steps(steps, 6)
print(x) # 32
print(forward(steps, x)) # 6
# 3x - 5 = 2
steps = [("*", 3), ("-", 5)]
x = undo_steps(steps, 2)
print(x) # 7/3
print(forward(steps, x)) # 2The key line is for op, n in reversed(steps). It applies the inverse of the last operation first. Calling forward on the answer is the same as checking by substitution.
Edge cases and common errors
Multiplying or dividing by zero
Zero has no multiplicative inverse. Dividing by 0 is undefined, so you can never use it as a step. Multiplying both sides by 0 is allowed in arithmetic, but it destroys information. From x = 3, multiplying by 0 gives 0 = 0, which is true for every x. The new equation is not equivalent to the old one. This is why the table above requires n ≠ 0.
The same caution applies to variable expressions. Dividing both sides by an expression containing x is only valid when the expression cannot be 0, and it can silently drop solutions. For example, dividing x(x - 1) = 0 by x loses the solution x = 0. Later chapters use only constant divisors in linear equations, so this matters mainly when you move on to other equation types.
Operations that are not reversible
Inverses only undo operations that can be reversed without ambiguity. Squaring is not one of them: both 3 and -3 square to 9, so "undoing" a square gives two candidates. The extension chapter on absolute value equations has the same feature, since |x| = 5 has two solutions. For linear equations in one variable, every step in this chapter is reversible.
Frequent mistakes
- Applying an inverse to only one side. The balance principle requires both sides.
- Undoing in the wrong order, such as dividing before subtracting, and forgetting to divide every term.
- Mixing up the pairs, such as dividing to undo an addition.
- Dropping a negative sign when dividing by a negative coefficient.
- Subtracting a negative incorrectly. Subtracting -4 from both sides means adding 4.
Summary of the method
- Identify the operations attached to the variable, in the order they were applied.
- Undo the last operation first, using the inverse on both sides.
- Repeat until the variable stands alone.
- Substitute the answer into the original equation to check it.
Exercise
Solve 5x - 7 = 18 by undoing operations in reverse order. Name each inverse step, then check the answer.
Show answer
The operations on x were "multiply by 5", then "subtract 7". Undo the subtraction first by adding 7 to both sides: 5x = 25. Then undo the multiplication by dividing both sides by 5: x = 5. Check: 5(5) - 7 = 25 - 7 = 18, which matches the right side.
Exercise
Solve (3/4)x + 2 = 11. Which reciprocal do you use, and why is multiplying by it a valid inverse?
Show answer
Subtract 2 from both sides: (3/4)x = 9. The variable is multiplied by 3/4, so multiply both sides by its reciprocal, 4/3: x = 9 * 4/3 = 12. Multiplying by 4/3 is valid because (4/3)(3/4) = 1, and multiplying by 1 leaves x unchanged. Check: (3/4)(12) + 2 = 9 + 2 = 11.
Exercise
A student solves 2x = 0 by multiplying both sides by 0 and writes 0 = 0, concluding that every number is a solution. What went wrong, and what is the correct solution?
Show answer
Multiplying by 0 is not reversible, so the new equation 0 = 0 is not equivalent to 2x = 0. It is true for all x, but 2x = 0 is true only for x = 0. The correct step is to divide both sides by 2, which is allowed because 2 is not 0. That gives x = 0.