Two tanks
At a school in Lilongwe, two rainwater tanks stand side by side. In the morning the first holds litres and is being used to water the vegetable garden, losing litres a minute. The second holds litres and is being filled from the roof gutters at litres a minute. When will the two tanks hold the same amount?
After minutes the first tank holds litres and the second litres. We want the value of that makes
We could guess: after minutes the tanks hold and litres; after minutes, and . So the answer lies somewhere between. Guessing works here, but it is slow, it is hopeless when the answer is , and it can never tell us that there is no answer. This lesson develops a method that always works — and proves why it works.
Keeping the balance
An equation is like a balance in equilibrium: the two sides weigh the same. If we take the same amount off both pans, or double both pans, the balance stays level. Try it: each box weighs units, and the goal is to get one box alone on one side.
x on both sides
Get one x alone. Every legal move keeps the scale level.
- x (unknown weight)
- 1 (unit weight)
3x + 1 = x + 9
Do the same thing to both sides. Try to get x on its own.
The scale is still level: both sides changed by the same amount.
Your steps
- 3x + 1 = x + 9
Make your own equation
Left side
Right side
Equations, solutions and equivalence
Definition— equation and solution
An equation in a variable is a statement that two algebraic expressions are equal, such as . A solution is a value of that makes the statement true. The solution set is the set of all solutions. To solve an equation means to find its solution set — all of the solutions, and nothing else.
Definition— equivalent equations
Two equations are equivalent if they have exactly the same solutions.
Definition— linear equation
A linear equation in is one that can be written as for numbers : the variable appears only to the first power, multiplied by numbers.
So and are linear; and are not.
Definition— inequality
An inequality compares two expressions with , , or . Its solutions are the values of the variable that make it true. For example, the solutions of are all the numbers greater than — infinitely many.
Throughout, the variable can be any rational number (see rational numbers) unless we say otherwise. This matters: has the solution among the rational numbers but no solution among the integers.
Why the balance method works
Theorem— moves that give equivalent equations
For all numbers , and :
- if and only if ;
- if , then if and only if .
Consequently, adding the same number to both sides of an equation, or multiplying both sides by the same non-zero number, gives an equivalent equation.
Proof
- If , then and are the same number, so they are equal. Conversely, if , add to both sides: .
- If , then . Conversely, if and , multiply both sides by , which exists because : .
For an equation in , apply this to each value of separately, with and the values of the two sides: makes the old equation true exactly when it makes the new one true.
∎
Subtracting is adding , and dividing by is multiplying by , so these moves are covered too. We may also add an expression such as to both sides: for each value of , that just adds a number.
The proof shows exactly where is used: to undo the multiplication. Multiplying by cannot be undone. The equation has one solution, but is true for every — multiplying by zero has thrown the information away.
So solving an equation is building a chain of equivalent equations, ending with one whose solutions we can read off. Because every link is an "if and only if", the last equation has exactly the same solutions as the first. Checking the answer by substitution is still a good habit: it catches arithmetic slips.
Theorem— the three outcomes for ax = b
For numbers and , the equation has
- exactly one solution, , if ;
- no solution, if and ;
- every number as a solution, if and .
Proof
If , multiplying both sides by gives the equivalent equation , whose only solution is . If , the left side is for every , so the equation says : never true if , always true if .
∎
Every linear equation can be brought into this form. Subtracting from both sides of gives the equivalent equation
Theorem— no linear equation has exactly two solutions
If two different numbers both solve , then every number solves it.
Proof
Both numbers solve the standard form: and . Subtracting, . Since , we can divide by it, so , and then . So the standard form reads , which every number satisfies.
∎
A linear equation therefore has exactly one solution, no solution, or infinitely many — nothing in between.
Worked examples
Example— The variable on both sides
Solve .
Check: and . ✓
Example— The two tanks
. Add to both sides: . Subtract : . Divide by : . After minutes both tanks hold litres ().
Example— Negative coefficients and brackets
- . Subtract : . Divide by : . Check: . ✓
- . Expand carefully — the minus sign in front of the second bracket multiplies both terms: , so and . Check: . ✓
Example— Fractions
Solve .
Multiply both sides by , the least common multiple of , and — and multiply every term:
Check: and . ✓
Example— No solution, and every number a solution
- expands to . Subtracting leaves , which is false whatever is. No solution.
- expands to . Subtracting leaves , true whatever is. Every number is a solution: the equation is an identity.
When the variable disappears, do not panic — read the statement that remains.
Example— Modelling: three consecutive numbers
Three consecutive integers add up to . What are they? Call the smallest ; the others are and . Then , so , and . The numbers are — and indeed they add to . Choosing what the variable stands for is the most important step in modelling.
Inequalities, and why they flip
Inequalities are solved with the same moves — with one twist. We use the basic facts about order: means that is positive; the sum and the product of two positive numbers are positive; and the product of a positive and a negative number is negative.
Theorem— moves for inequalities
For all numbers , and :
- if and only if ;
- if , then if and only if ;
- if , then if and only if — the inequality reverses.
The same holds with in place of .
Proof
- , so one difference is positive exactly when the other is.
- If and , then is a product of positive numbers, so it is positive: .
- If and , then , so . But . So , which says .
Each move can be undone (by adding , or multiplying by , which has the same sign as ), which gives the "if and only if".
∎
Here is the picture behind part 3. Multiplying by reflects the number line in : , but , because the reflection swaps left and right. Multiplying by any negative number is a stretch followed by this reflection.
Example— Solving an inequality
Solve .
Check with test values: gives , true; gives , true; gives , false. ✓
Example— Modelling: how many notebooks?
Mariam, a student in Fez, has dirhams. She needs a book costing dirhams and wants as many notebooks as possible at dirhams each. With notebooks she needs , so and But counts notebooks, so it is a whole number: the solutions are , and she can buy at most . (Thirteen would cost dirhams — one too many!)
Equivalent equations in Lean
In Lean we work with the rational numbers Rat. "Two equations are equivalent" becomes a statement with ↔ ("if and only if") that holds for every x. First the two basic moves; each proof undoes the move, just as in the human proof:
/-- Adding the same number `c` to both sides gives an equivalent equation:
`p = q ↔ p + c = q + c`. Forwards, equal numbers plus `c` are equal. Backwards, the move can
be **undone**: subtract `c` again, `p = (p + c) − c = (q + c) − c = q`. -/
theorem add_both_sides (p q c : Rat) : p = q ↔ p + c = q + c := by
constructor
· intro h
rw [h]
· intro h
calc p = p + c - c := Rat.add_sub_cancel.symm
_ = q + c - c := by rw [h]
_ = q := Rat.add_sub_cancel/-- Multiplying both sides by a **non-zero** number `c` gives an equivalent equation:
`p = q ↔ c·p = c·q`. Backwards, the move is undone by dividing by `c`, which is only possible
because `c ≠ 0` (`Rat.mul_div_cancel`). -/
theorem mul_both_sides (p q c : Rat) (hc : c ≠ 0) : p = q ↔ c * p = c * q := by
constructor
· intro h
rw [h]
· intro h
calc p = c * p / c := by rw [Rat.mul_comm, Rat.mul_div_cancel hc]
_ = c * q / c := by rw [h]
_ = q := by rw [Rat.mul_comm, Rat.mul_div_cancel hc]Without the hypothesis c ≠ 0 the second move fails, and Lean can prove that it fails:
/-- Why `c ≠ 0` is needed: multiplying both sides by `0` cannot be undone. `0 · 0 = 0 · 1` is
true, but `0 = 1` is false, so "`0·p = 0·q` implies `p = q`" fails. -/
theorem mul_zero_not_reversible : ¬ ∀ p q : Rat, 0 * p = 0 * q → p = q := by
intro h
have h01 : (0 : Rat) = 1 := h 0 1 (by rw [Rat.zero_mul, Rat.zero_mul])
exact absurd h01 (by decide)Multiplying or dividing by an expression that can be zero is just as dangerous: it can add a solution, or lose one.
/-- Multiplying both sides by an *expression that can be zero* can add solutions. The
equation `x = 3` has only the solution `3`, but after multiplying both sides by `x − 2` the
new equation `(x − 2)·x = (x − 2)·3` is also solved by `x = 2`. -/
theorem extra_solution : ∃ x : Rat, (x - 2) * x = (x - 2) * 3 ∧ x ≠ 3 :=
⟨2, by grind, by decide⟩/-- Dividing by an expression that can be zero can *lose* solutions: `x² = 2x` has the two
solutions `0` and `2`, but "dividing by `x`" leaves only `x = 2`. Proof: `x² − 2x = x(x − 2)`,
and a product is zero exactly when a factor is (`Rat.mul_eq_zero`). -/
theorem square_eq_double_iff (x : Rat) : x * x = 2 * x ↔ x = 0 ∨ x = 2 := by
constructor
· intro h
have hfac : x * (x - 2) = 0 := by grind
rcases Rat.mul_eq_zero.mp hfac with h0 | h2
· exact Or.inl h0
· right
grind
· rintro (rfl | rfl) <;> grind/-- The worked example `3x + 1 = x + 9`, solved by a chain of equivalent equations, exactly as
in the lesson: subtract `x + 1` from both sides, then multiply both sides by `1/2`. Every step
is an `↔`, so the final answer `x = 4` is not just *a* solution: it is the only one. -/
theorem solve_both_sides (x : Rat) : 3 * x + 1 = x + 9 ↔ x = 4 :=
calc (3 * x + 1 = x + 9)
↔ (3 * x + 1) + (-x - 1) = (x + 9) + (-x - 1) := add_both_sides _ _ _
_ ↔ 2 * x = 8 := by
rw [show (3 * x + 1) + (-x - 1) = 2 * x by grind,
show (x + 9) + (-x - 1) = (8 : Rat) by grind]
_ ↔ (1 / 2) * (2 * x) = (1 / 2) * 8 := mul_both_sides _ _ _ (by grind)
_ ↔ x = 4 := by
rw [show (1 / 2 : Rat) * (2 * x) = x by grind, show (1 / 2 : Rat) * 8 = 4 by grind]/-- An equation with fractions: `x/3 + 1/2 = (x − 1)/4`. Multiplying both sides by `12`, the
least common multiple of the denominators, clears the fractions: `4x + 6 = 3x − 3`, so
`x = −9`. -/
theorem solve_fractions (x : Rat) : x / 3 + 1 / 2 = (x - 1) / 4 ↔ x = -9 :=
calc (x / 3 + 1 / 2 = (x - 1) / 4)
↔ 12 * (x / 3 + 1 / 2) = 12 * ((x - 1) / 4) := mul_both_sides _ _ _ (by decide)
_ ↔ 4 * x + 6 = 3 * x - 3 := by
rw [show 12 * (x / 3 + 1 / 2) = 4 * x + 6 by grind,
show 12 * ((x - 1) / 4) = 3 * x - 3 by grind]
_ ↔ x = -9 := by
constructor <;> intro h <;> grindNow the general theory: every linear equation has a standard form, the three outcomes for , and the theorem that two solutions force infinitely many.
/-- Every linear equation `a·x + b = c·x + d` is equivalent to one of the form `A·x = B`:
subtract `c·x + b` from both sides to get `(a − c)·x = d − b`. -/
theorem to_standard_form (a b c d x : Rat) :
a * x + b = c * x + d ↔ (a - c) * x = d - b := by
rw [add_both_sides (a * x + b) (c * x + d) (-(c * x) - b)]
rw [show a * x + b + (-(c * x) - b) = (a - c) * x by grind,
show c * x + d + (-(c * x) - b) = d - b by grind]/-- The three possible outcomes for `a·x = b`:
* if `a ≠ 0` there is exactly one solution, `x = b / a`;
* if `a = 0` and `b ≠ 0` there is no solution (`0·x` is always `0`);
* if `a = 0` and `b = 0` every number is a solution. -/
theorem ax_eq_b_trichotomy (a b : Rat) :
(a ≠ 0 → ∀ x, a * x = b ↔ x = b / a) ∧
(a = 0 → b ≠ 0 → ∀ x, a * x ≠ b) ∧
(a = 0 → b = 0 → ∀ x, a * x = b) := by
refine ⟨?_, ?_, ?_⟩
· intro ha x
constructor
· intro h
calc x = a * x / a := by rw [Rat.mul_comm, Rat.mul_div_cancel ha]
_ = b / a := by rw [h]
· intro h
rw [h, Rat.mul_comm, Rat.div_mul_cancel ha]
· intro ha hb x h
rw [ha, Rat.zero_mul] at h
exact hb h.symm
· intro ha hb x
rw [ha, hb, Rat.zero_mul]/-- A linear equation never has exactly two solutions: if two *different* numbers solve
`a·x + b = c·x + d`, then every number does. In standard form `(a − c)·x = d − b`; two
solutions give `(a − c)(x₁ − x₂) = 0` with `x₁ − x₂ ≠ 0`, so `a − c = 0`, then `d − b = 0`. -/
theorem two_solutions_all (a b c d x₁ x₂ : Rat) (hne : x₁ ≠ x₂)
(h₁ : a * x₁ + b = c * x₁ + d) (h₂ : a * x₂ + b = c * x₂ + d) :
∀ x, a * x + b = c * x + d := by
rw [to_standard_form] at h₁ h₂
have hprod : (a - c) * (x₁ - x₂) = 0 := by grind
have hac : a - c = 0 := by
rcases Rat.mul_eq_zero.mp hprod with h | h
· exact h
· exact absurd (by grind) hne
intro x
rw [to_standard_form]
grind/-- `2(x + 3) = 2x + 5` has no solution: expanding gives `2x + 6 = 2x + 5`, and subtracting
`2x` from both sides leaves the false statement `6 = 5`. -/
theorem no_solution_example : ¬ ∃ x : Rat, 2 * (x + 3) = 2 * x + 5 := by
intro ⟨x, h⟩
have h65 : (6 : Rat) = 5 := by grind
exact absurd h65 (by decide)/-- `3(x − 2) + x = 4x − 6` is true for every `x`: expanding the left side gives
`3x − 6 + x = 4x − 6`. Every number is a solution. -/
theorem identity_example (x : Rat) : 3 * (x - 2) + x = 4 * x - 6 := by
grind/-- The two rainwater tanks of the lesson: one holds `500 − 20t` litres after `t` minutes,
the other `100 + 30t`. They hold the same amount exactly when `t = 8`. -/
theorem tanks_meet (t : Rat) : 500 - 20 * t = 100 + 30 * t ↔ t = 8 := by
constructor
· intro h
grind
· intro h
rw [h]
grindFor inequalities, the first two moves are already in core Lean's library, so we simply apply them. The reversal for negative numbers is proved here, following the human proof line by line:
/-- Adding the same number to both sides of an inequality keeps it true, and in the same
direction: `p < q ↔ p + c < q + c`. This applies core Lean's `Rat.add_lt_add_right`. -/
theorem ineq_add_both_sides (p q c : Rat) : p < q ↔ p + c < q + c :=
Rat.add_lt_add_right.symm/-- Multiplying both sides of an inequality by a **positive** number keeps its direction:
for `c > 0`, `p < q ↔ c·p < c·q`. This applies core Lean's `Rat.mul_lt_mul_left`. -/
theorem ineq_mul_pos (p q c : Rat) (hc : 0 < c) : p < q ↔ c * p < c * q :=
(Rat.mul_lt_mul_left hc).symm/-- Multiplying both sides of an inequality by a **negative** number reverses it:
if `c < 0` and `p < q` then `c·q < c·p`. The human proof: `q − p` is positive and `−c` is
positive, so their product `(−c)(q − p) = c·p − c·q` is positive, which says `c·q < c·p`. -/
theorem ineq_mul_neg (p q c : Rat) (hc : c < 0) (h : p < q) : c * q < c * p := by
have h1 : 0 < q - p := (Rat.lt_iff_sub_pos p q).mp h
have h2 : 0 < -c := by grind
have h3 : 0 < -c * (q - p) := Rat.mul_pos h2 h1
have h4 : -c * (q - p) = c * p - c * q := by grind
rw [h4] at h3
exact (Rat.lt_iff_sub_pos (c * q) (c * p)).mpr h3/-- The reversal is an equivalence: for `c < 0`, `p < q ↔ c·q < c·p`. Backwards: if `p < q`
failed, then `q = p` (so `c·q = c·p`) or `q < p` (so `c·p < c·q` by `ineq_mul_neg`); either
way `c·q < c·p` would be impossible. -/
theorem ineq_mul_neg_iff (p q c : Rat) (hc : c < 0) : p < q ↔ c * q < c * p := by
constructor
· exact ineq_mul_neg p q c hc
· intro h
by_cases hpq : p < q
· exact hpq
· exfalso
rcases Rat.le_iff_lt_or_eq.mp (Rat.not_lt.mp hpq) with hlt | heq
· -- `q < p`, so `c·p < c·q`, contradicting `c·q < c·p`.
have h' : c * p < c * q := ineq_mul_neg q p c hc hlt
grind
· -- `q = p`, so `c·q < c·p` would say `c·p < c·p`.
rw [heq] at h
exact Rat.lt_irrefl h/-- The worked example `7 − 3x ≤ 19`: subtracting `7` gives `−3x ≤ 12`, and dividing by `−3`
**reverses** the inequality, giving `x ≥ −4`. Here `grind` checks the linear arithmetic of both
directions. -/
theorem ineq_example (x : Rat) : 7 - 3 * x ≤ 19 ↔ -4 ≤ x := by
constructor <;> intro h <;> grind/-- Whole-number solutions: with `200` dirhams, a `45`-dirham book and `n` notebooks at `12`
dirhams each are affordable exactly when `n ≤ 12`, since `45 + 12n ≤ 200 ↔ 12n ≤ 155` and
`155 / 12 ≈ 12.9`. (`omega` decides such statements about whole numbers.) -/
theorem notebooks (n : Nat) : 45 + 12 * n ≤ 200 ↔ n ≤ 12 := by
omegaSome short steps above are finished by the tactics grind (which rearranges sums and products and decides linear arithmetic over the rationals) and omega (which decides linear arithmetic over whole numbers). They are decision procedures: they check the step completely, they do not guess. What is formalised: every theorem of this lesson, for the rational numbers.
Solving, counting and testing by computer
"""Solving linear equations exactly, and testing the rules for inequalities.
Part 1 solves every equation a*x + b = c*x + d from the lesson exactly, with
Python's Fraction type, by reducing it to the standard form (a - c)x = d - b,
and checks each answer by substituting it back. Part 2 counts, over ALL
equations with small integer coefficients, how many test values satisfy
each one: always 0, 1 or all of them, never exactly 2 - as the lesson's
theorem predicts. Part 3 tests the rule "multiplying an inequality by a
negative number reverses it" on random fractions, and compares the right
and the wrong ("forgot to flip") answers to 7 - 3x <= 19.
"""
import random
from fractions import Fraction as F
#: (description, a, b, c, d) meaning a*x + b = c*x + d.
LESSON_EQUATIONS = [
("3x + 1 = x + 9", 3, 1, 1, 9),
("500 - 20t = 100 + 30t", -20, 500, 30, 100),
("x/3 + 1/2 = (x - 1)/4", F(1, 3), F(1, 2), F(1, 4), F(-1, 4)),
("5 - 2x = 11", -2, 5, 0, 11),
("2(x + 3) = 2x + 5", 2, 6, 2, 5),
("3(x - 2) + x = 4x - 6", 4, -6, 4, -6),
]
def solve_linear(a, b, c, d):
"""Solve a*x + b = c*x + d exactly.
Returns ("one", x), ("none", None) or ("all", None), following the
standard form (a - c) x = d - b.
"""
coeff, rhs = F(a) - F(c), F(d) - F(b)
if coeff != 0:
return "one", rhs / coeff
if rhs != 0:
return "none", None
return "all", None
def satisfies(a, b, c, d, x):
"""Does x satisfy a*x + b = c*x + d (exact arithmetic)?"""
return F(a) * x + b == F(c) * x + d
def solution_counts(coeffs, values):
"""For every (a, b, c, d) with entries in coeffs, count solutions in values.
Returns a dict {number of solving values: number of equations}.
"""
counts = {}
for a in coeffs:
for b in coeffs:
for c in coeffs:
for d in coeffs:
k = sum(1 for x in values if satisfies(a, b, c, d, x))
counts[k] = counts.get(k, 0) + 1
return counts
def flip_trials(trials, seed=2024):
"""Random p < q and c < 0 (fractions). Count how often c*q < c*p holds."""
rng = random.Random(seed)
flipped = 0
for _ in range(trials):
p, q = sorted(F(rng.randint(-99, 99), rng.randint(1, 9)) for _ in "pq")
if p == q:
q += 1
c = -F(rng.randint(1, 99), rng.randint(1, 9))
flipped += c * q < c * p
return flipped
def inequality_table(values):
"""Values x with 7 - 3x <= 19, and the two candidate answers."""
true_set = [x for x in values if 7 - 3 * x <= 19]
right = [x for x in values if x >= -4]
wrong = [x for x in values if x <= -4]
return true_set, right, wrong
def main():
print("1. Exact solutions via the standard form (a - c)x = d - b")
for text, a, b, c, d in LESSON_EQUATIONS:
kind, x = solve_linear(a, b, c, d)
if kind == "one":
ok = "checks" if satisfies(a, b, c, d, x) else "FAILS"
result = f"solution {x} (substituting back: {ok})"
elif kind == "none":
result = "no solution: reduces to 0x = " + str(F(d) - F(b))
else:
result = "every number is a solution: 0x = 0"
print(f" {text:<24} {result}")
print()
values = range(-5, 6)
counts = solution_counts(range(-3, 4), values)
print("2. All 2401 equations ax + b = cx + d with a, b, c, d in -3..3:")
print(" how many of the 11 values -5..5 solve each equation?")
for k in sorted(counts):
print(f" {k:>2} solving value(s): {counts[k]:>4} equations")
print(" Never 2 to 10: two solutions force every number to be one.")
print()
trials = 10_000
flipped = flip_trials(trials)
print(f"3. {trials} random fractions p < q and c < 0:")
print(f" c*q < c*p (reversed) in {flipped} cases;"
f" c*p < c*q in {trials - flipped}.")
true_set, right, wrong = inequality_table(range(-8, 3))
print(" 7 - 3x <= 19 for x in -8..2 is true at", true_set)
print(" answer x >= -4 picks", right)
print(" answer x <= -4 (forgot to flip) picks", wrong)
print()
print("Epistemic status: part 1 is exact rational arithmetic, and each")
print("answer is checked by substitution. Part 2 is an exhaustive check of")
print("2401 equations on 11 values - finite evidence for the lesson's theorem,")
print("which proves it for all equations and all numbers. Part 3 is a random")
print("experiment; only the proof shows the reversal rule always holds.")
if __name__ == "__main__":
main()Part 2 is a nice example of a computation and a proof working together. The computer checked equations on values each and never found an equation with between and solving values — exactly as the theorem predicts. The computation alone covers only those equations and values; the theorem covers them all. In part 3, notice how badly the "forgot to flip" answer does: it shares only the boundary point with the true solution set.
Explore: equations as meeting points
The two sides of are two straight lines, and . A solution is an where the lines are at the same height: where they meet. Move the sliders and watch the three outcomes appear.
Where do the two sides agree?
Starts at 3x + 1 = x + 9, solved by x = 4.
- left side y = ax + b
- right side y = cx + d
- left side y = ax + b: y = 4
- right side y = cx + d: y = 10
Things to try:
- Make but : the lines are parallel and never meet — no solution.
- Make and : the lines lie on top of each other — every is a solution.
- Can you make two straight lines meet in exactly two points? (The theorem says no.)
And on the balance: what happens here, where the same number of boxes sits on each side?
Balance the equation
Can you make this scale level?
- x (unknown weight)
- 1 (unit weight)
x + 2 = x + 5
This scale can never balance: both sides have the same number of x's but different numbers of 1s. The equation has no solution.
Your steps
- x + 2 = x + 5
Make your own equation
Left side
Right side
Exercises
1. Linear equations and inequalities
Warm-upHumanSolve .
2. Linear equations and inequalities
CoreHumanSolve .
3. Linear equations and inequalities
CoreHumanWhich of these equations have no solution? (Choose all that apply.)
4. Linear equations and inequalities
CoreHumanRavi starts with the equation . He multiplies both sides by , gets , and concludes that every number is a solution. What went wrong?
5. Linear equations and inequalities
CoreHumanSolve .
6. Linear equations and inequalities
CoreHumanIn Manila, one phone-repair shop charges pesos plus pesos per hour of work. Another charges pesos plus pesos per hour. For how many hours of work do the two shops charge the same?
7. Linear equations and inequalities
CoreHumanAma has cedis. She buys a bus ticket for cedis and wants to spend the rest on mangoes at cedis each. What is the largest number of mangoes she can buy?
8. Linear equations and inequalities
CoreFormalWhich Lean statement correctly says "multiplying both sides of an inequality by a negative number reverses it"?
9. Linear equations and inequalities
StretchComputationalWrite solve_linear(a, b, c, d) for the equation with integer coefficients. Return the solution as a Fraction if there is exactly one, the string "none" if there is no solution, and "all" if every number is a solution.
10. Linear equations and inequalities
StretchHumanKwame claims he has found a linear equation whose solutions are exactly and . Which argument shows this is impossible?
Common misconceptions
Misconception
"Multiplying both sides by the same thing is always safe." Only if the thing cannot be zero. Multiplying by gives , true for every . Multiplying by an expression that can be zero can add solutions: is also solved by . Dividing by such an expression can lose them: "dividing" by gives and loses the solution . Safe moves are the ones you can undo.
Misconception
Forgetting to reverse the inequality. Dividing by gives , not . Test a value to check: satisfies , so the answer must include .
Misconception
Doing the move to only one term. From , dividing "both sides" by gives , not . A move applies to a whole side. Likewise, when clearing fractions, multiply every term by the common denominator.
Misconception
"." The minus sign multiplies both terms in the bracket: .
Misconception
" as an answer means no solution." The equation has the solution . "No solution" means that no number works, as in .
Other ways of seeing
Geometry— Meeting points and reflections
Solving is finding where two lines in the coordinate plane cross. Two lines either cross once, never (parallel), or coincide — which is the geometric face of the theorem "one, none or infinitely many". The flip of an inequality is geometry too: is the reflection of the number line in , and a reflection turns "left of" into "right of". The next lesson, linear relationships, builds on these pictures.
Algebra— Why we need inverses
The proof that the moves work used two things: every number has an additive inverse , and every non-zero number has a multiplicative inverse . A number system with both is called a field; the rational numbers are one. In the integers, has no multiplicative inverse, and has no integer solution. In clock arithmetic with hours, though, leaves remainder , so acts as , and the "linear equation" is solved by . The trails below explore this.
Logic— Implies versus if and only if
Each step of a solution should be an equivalence (), not just an implication (). Squaring both sides, or multiplying by an expression that can be zero, is only an implication: every solution of the old equation solves the new one, but the new one may have extra solutions (logicians would say the new equation is weaker). That is why such steps must always be followed by a check in the original equation. Lean makes the difference visible: our worked example is proved with ↔, so its answer is both necessary and sufficient.
Wonder Trails
Why can we always divide by a non-zero rational number, but not by in the integers? And what does solving equations look like on a clock?
Wonder Trail · Optional · never gradedInverses and structureEvery integer can be added to another integer to get . So why can almost no integer be multiplied by another integer to get ?Follow the trail Wonder Trail · Optional · never gradedClock arithmeticIt's 9 o'clock. What time will it be in 5 hours — and in 29 hours? Can a clock teach us a whole new kind of arithmetic?Follow the trailHistory and global context
- The Rhind papyrus (Egypt, copied by the scribe Ahmes around 1550 BCE) contains linear problems such as Problem 24: "a quantity and its seventh, added together, become 19". It was solved by false position: guess , which gives ; since must become , scale the guess by , giving .
- Chapter 7 of the Chinese Nine Chapters on the Mathematical Art (compiled by about the 1st century CE), "Excess and deficit", solves linear problems by a method of double false position: two guesses, one too big and one too small, determine the answer exactly.
- In 9th-century Baghdad, al-Khwārizmī named two of the operations of this lesson. Al-jabr ("restoring") adds equal amounts to both sides to remove a subtracted term; al-muqābala ("balancing") cancels equal terms from both sides. Brahmagupta in India (628 CE) also gave a general rule for solving linear equations.
- The equals sign was introduced by the Welsh mathematician Robert Recorde in The Whetstone of Witte (1557), "bicause noe .2. thynges, can be moare equalle" than two parallel lines. The signs and appear in Thomas Harriot's Artis analyticae praxis, published in 1631 after his death.
Further reading
- I. M. Gelfand and A. Shen, Algebra (1993) — equations, inequalities and much more, through problems.
- Victor J. Katz, A History of Mathematics: An Introduction (3rd edition, 2009) — Egyptian, Chinese, Indian and Islamic methods for linear problems.
- Arnold Buffum Chace, The Rhind Mathematical Papyrus (1927–1929) — a translation with commentary, including the false-position problems.
- Kangshen Shen, John N. Crossley and Anthony W.-C. Lun, The Nine Chapters on the Mathematical Art: Companion and Commentary (1999).