When do the thermometers agree?
Most of the world measures temperature in degrees Celsius; a few countries, including the United States, use degrees Fahrenheit. Water freezes at , which is , and boils (at sea level) at , which is . A warm afternoon in Accra at is .
| Celsius | |||
|---|---|---|---|
| Fahrenheit |
Here is a puzzle: is there a temperature at which both thermometers show the same number? At the Fahrenheit number is bigger by ; at , bigger by . The gap grows as it gets warmer — so perhaps it shrinks as it gets colder, and vanishes somewhere below zero?
More than 1,500 years ago, a Chinese textbook, the Sunzi Suanjing, posed a famous puzzle of the same kind: pheasants and rabbits share a cage; there are heads and feet. How many of each? Both puzzles ask for two unknown numbers satisfying two conditions at once. By the end of this lesson you will solve them in three different ways — and know exactly when such a puzzle has one answer, none, or infinitely many.
Constant rate of change
A taxi in Lima charges a fixed soles plus soles per kilometre.
| distance (km) | |||||
|---|---|---|---|---|---|
| fare (soles) |
Each extra kilometre adds the same amount, soles. The fare changes at a constant rate of soles per kilometre, and the formula is . Plot the table and the points line up perfectly: a constant rate of change draws a straight line. The rate, , tells us how steep the line is; the starting value, , tells us where it crosses the vertical axis.
y = mx + b
Each step of 1 to the right changes y by exactly m.
- y = mx + b
- y = mx + b: y = 7
Slope, linear functions and systems
Definition— slope
The slope of the line through two points and with is
It is the change in per unit change in : a rate of change. A vertical line () has no slope — its run is , and we cannot divide by .
Definition— linear function
A linear function has the form for fixed numbers and (see functions). Its graph, drawn in the coordinate plane, is the line , with slope and -intercept (the height where it crosses the -axis, at ).
Definition— proportional relationship
A relationship is proportional if for a constant , the constant of proportionality (see ratios and proportional reasoning). Proportional relationships are the linear functions with : their graphs pass through the origin.
Definition— system of equations
A system of equations is a collection of equations in the same unknowns. A solution of the system is a choice of values that satisfies every equation at once. Equations solved together are also called simultaneous equations.
Worked examples
Example— Slopes from two points
- Through and : . The line rises for every to the right.
- Through and : . A negative slope: the line falls.
- Through and : . A horizontal line: does not change.
- Through and : the run is . This is the vertical line ; its slope is undefined.
You may take the points in either order, as long as you subtract in the same order on top and bottom: as well.
Example— A line from its slope and one point
Find the line with slope through . It has the form , and the point must satisfy it: , so . The line is .
In general, the line with slope through is , which can also be written in point–slope form: .
Example— A line through two points: Celsius to Fahrenheit
The points and give the slope , and the intercept is . So
Check with the third point: . ✓ The slope says that each degree Celsius is degrees Fahrenheit.
Example— Recognising linear relationships in tables
In a table whose -values go up in equal steps, a relationship is linear exactly when the -values go up (or down) by equal steps too.
- Rice at rupees per kilogram: , , . Linear and proportional: .
- The taxi: , , . Linear but not proportional: doubling the distance does not double the fare ( km costs soles, not ).
- The area of a square: , , , . The steps are : not linear.
Why a line has one slope
The examples suggest two facts: on a line, the slope does not depend on which two points we pick; and a constant rate of change always gives a formula . Here are the proofs.
Theorem— the slope of y = mx + b is m
For any two points and on the line with , the slope between them is .
Proof
Since both points are on the line, and . So the rise is
and dividing by the run gives exactly .
∎
Theorem— constant rate of change means linear
Suppose a function has a constant rate of change : for all and , . Then for every , where .
Proof
Take and : , so .
∎
The picture gives the geometric reason: slope triangles drawn on one line are similar (their angles match because the line has one direction), and similar triangles have proportional sides (see similarity). The algebraic proof above needs no picture at all.
Theorem— proportional means through the origin
The linear relationship is proportional — that is, for all , for some constant — if and only if .
Proof
If for every , put : . Conversely, if then , which is proportional with .
∎
Simultaneous equations: three methods
Each linear equation in two unknowns and , such as , has infinitely many solutions — all the points of a line. A system of two such equations asks for the points on both lines: where they meet.
Example— Graphing: pheasants and rabbits
Let be the number of pheasants and the number of rabbits. Counting heads and feet (two feet per pheasant, four per rabbit):
Solving each for : and . The lines meet at .
Two conditions, one meeting point
Move the sliders and trace along the curves to read off values.
- heads: x + y = 35
- feet: 2x + 4y = 94
- heads: x + y = 35: y = 34
- feet: 2x + 4y = 94: y = 23
A graph shows the answer at a glance, but reading it is only as accurate as the drawing — a meeting point at would look much the same. Algebra gives exact answers.
Example— Elimination: pheasants and rabbits again
Multiply the first equation by , giving , and subtract it from the second:
Then . Check both equations: heads, and feet. ✓ Elimination works because, if both equations hold, any combination of them holds too.
Example— Substitution: when do the thermometers agree?
We want and at the same time. Substitute the second equation into the first:
So — a temperature reached in the coldest winters of places such as Yakutsk in Siberia.
Example— No solution, and infinitely many
- and . Doubling the first gives , which contradicts . No solution: as and , the graphs are parallel lines.
- and . The second equation is just the first one doubled: both describe the same line. Infinitely many solutions: for every number , the point works.
One, none, or infinitely many
Theorem— where two lines meet
Consider the lines and .
- If , they meet in exactly one point, at .
- If and , they never meet: they are parallel.
- If and , they are the same line.
Proof
A meeting point needs , that is, . This is a linear equation in of the form , and the lesson on linear equations showed it has exactly one solution if , none if and , and every as a solution if both are zero. When there is exactly one , there is exactly one meeting point .
∎
Vertical lines are not of the form , but they are easy: two different vertical lines are parallel, and a vertical line meets every non-vertical line exactly once. The next theorem covers all lines at once, vertical or not, and in fact all linear equations.
Theorem— two solutions give infinitely many
If two different points and both satisfy a linear equation , then for every number so does the point
and different values of give different points.
Proof
Substitute and regroup:
If with , then subtracting coordinates gives and , so and , contradicting that the points are different.
∎
The points make up the line through the two points ( is the first point, the second, the midpoint). Now apply the theorem to every equation of a system at once: if a system of linear equations — with any number of equations — has two different solutions, every solves all of them. So:
A system of linear equations has exactly one solution, no solution, or infinitely many. Never exactly two, or three.
Note
Going further: the general formula. For the system , , multiply the first equation by , the second by , and subtract: the -terms cancel and . Eliminating in the same way gives . So if the number is not zero, the system has exactly one solution,
The number is called the determinant of the system; when both equations describe genuine lines, it is zero exactly when the two lines are parallel or the same. You will meet it again in linear algebra.
Lines and systems in Lean
In Lean, slope is a small definition, and "the point is on the line " is just the equation y = m * x + b. We work with the rational numbers Rat.
/-- The slope of the line through `(x₁, y₁)` and `(x₂, y₂)`: rise over run,
`(y₂ − y₁) / (x₂ − x₁)`. It is meaningful only when `x₁ ≠ x₂`; the theorems below always
assume that. (Lean's `Rat` sets `a / 0 = 0`, which is a convention, not a slope.) -/
def slope (x₁ y₁ x₂ y₂ : Rat) : Rat := (y₂ - y₁) / (x₂ - x₁)/-- The order of the two points does not matter, as long as we subtract in the same order on
top and bottom: `(y₂ − y₁)/(x₂ − x₁) = (y₁ − y₂)/(x₁ − x₂)`. -/
theorem slope_symm (x₁ y₁ x₂ y₂ : Rat) (h : x₁ ≠ x₂) :
slope x₁ y₁ x₂ y₂ = slope x₂ y₂ x₁ y₁ := by
have h₁ : x₂ - x₁ ≠ 0 := fun h0 => h (by grind)
have h₂ : x₁ - x₂ ≠ 0 := fun h0 => h (by grind)
unfold slope
grindThe central fact — the slope between any two points of a line is the same — is proved exactly as on paper: first the rise is times the run, then divide.
/-- On the line `y = m·x + b`, the rise between two points is `m` times the run:
`(m·x₂ + b) − (m·x₁ + b) = m·(x₂ − x₁)`. The intercept `b` cancels and the distributive law
does the rest. -/
theorem rise_eq_slope_mul_run (m b x₁ x₂ : Rat) :
(m * x₂ + b) - (m * x₁ + b) = m * (x₂ - x₁) := by
grind/-- The slope between **any** two points of the line `y = m·x + b` is `m`. This is why a line
has one well-defined slope: the rise is `m·(run)`, so rise ÷ run is `m` for every choice of
points. -/
theorem slope_of_line (m b x₁ x₂ : Rat) (h : x₁ ≠ x₂) :
slope x₁ (m * x₁ + b) x₂ (m * x₂ + b) = m := by
have hrun : x₂ - x₁ ≠ 0 := fun h0 => h (by grind)
unfold slope
rw [rise_eq_slope_mul_run]
exact Rat.mul_div_cancel hrun/-- The converse: a relationship with a **constant rate of change** `m` — every rise is `m`
times its run — is linear, `f(x) = m·x + b` with `b = f(0)`. Take the two points `0` and `x`. -/
theorem linear_of_constant_rate (f : Rat → Rat) (m : Rat)
(h : ∀ x₁ x₂, f x₂ - f x₁ = m * (x₂ - x₁)) : ∀ x, f x = m * x + f 0 := by
intro x
have hx := h 0 x
grindFinding a line from a point and a slope, or from two points, and the test for proportionality:
/-- The line with slope `m` passes through `(x₁, y₁)` exactly when its intercept is
`b = y₁ − m·x₁`. So a slope and one point determine the line: `y = m·x + (y₁ − m·x₁)`, which
is the same as the point–slope form `y − y₁ = m·(x − x₁)`. -/
theorem line_through_point (m b x₁ y₁ : Rat) : m * x₁ + b = y₁ ↔ b = y₁ - m * x₁ := by
constructor
· intro h
grind
· intro h
rw [h]
grind/-- Two points with different `x`-coordinates determine a line: with `m` the slope between
them and `b = y₁ − m·x₁`, the line `y = m·x + b` passes through both points. The second point
works because `m·(x₂ − x₁) = y₂ − y₁` (`Rat.div_mul_cancel`). -/
theorem line_through_two_points (x₁ y₁ x₂ y₂ : Rat) (h : x₁ ≠ x₂) :
slope x₁ y₁ x₂ y₂ * x₁ + (y₁ - slope x₁ y₁ x₂ y₂ * x₁) = y₁ ∧
slope x₁ y₁ x₂ y₂ * x₂ + (y₁ - slope x₁ y₁ x₂ y₂ * x₁) = y₂ := by
have hrun : x₂ - x₁ ≠ 0 := fun h0 => h (by grind)
have hm : slope x₁ y₁ x₂ y₂ * (x₂ - x₁) = y₂ - y₁ := by
unfold slope
exact Rat.div_mul_cancel hrun
constructor
· grind
· calc slope x₁ y₁ x₂ y₂ * x₂ + (y₁ - slope x₁ y₁ x₂ y₂ * x₁)
= slope x₁ y₁ x₂ y₂ * (x₂ - x₁) + y₁ := by grind
_ = (y₂ - y₁) + y₁ := by rw [hm]
_ = y₂ := by grind/-- A linear relationship `y = m·x + b` is **proportional** (`y = k·x` for some constant `k`)
exactly when `b = 0`, i.e. when its graph passes through the origin. Forwards: put `x = 0`. -/
theorem proportional_iff (m b : Rat) : (∃ k, ∀ x, m * x + b = k * x) ↔ b = 0 := by
constructor
· intro ⟨k, hk⟩
have h0 := hk 0
grind
· intro hb
exact ⟨m, fun x => by rw [hb]; grind⟩/-- Doing one linear function after another gives a linear function: applying
`x ↦ m₂·x + b₂` and then `x ↦ m₁·x + b₁` gives `x ↦ (m₁·m₂)·x + (m₁·b₂ + b₁)`.
The slopes multiply. -/
theorem comp_linear (m₁ b₁ m₂ b₂ x : Rat) :
m₁ * (m₂ * x + b₂) + b₁ = (m₁ * m₂) * x + (m₁ * b₂ + b₁) := by
calc m₁ * (m₂ * x + b₂) + b₁ = m₁ * (m₂ * x) + m₁ * b₂ + b₁ := by rw [Rat.mul_add]
_ = (m₁ * m₂) * x + (m₁ * b₂ + b₁) := by grindWhere two lines meet:
/-- Two lines with **different** slopes meet in exactly one point: `m₁·x + b₁ = m₂·x + b₂`
holds exactly when `x = (b₂ − b₁)/(m₁ − m₂)`. (Subtract, then divide by `m₁ − m₂ ≠ 0`.) -/
theorem lines_meet_once (m₁ b₁ m₂ b₂ x : Rat) (h : m₁ ≠ m₂) :
m₁ * x + b₁ = m₂ * x + b₂ ↔ x = (b₂ - b₁) / (m₁ - m₂) := by
have hd : m₁ - m₂ ≠ 0 := fun h0 => h (by grind)
constructor
· intro heq
have hx : (m₁ - m₂) * x = b₂ - b₁ := by grind
calc x = (m₁ - m₂) * x / (m₁ - m₂) := by rw [Rat.mul_comm, Rat.mul_div_cancel hd]
_ = (b₂ - b₁) / (m₁ - m₂) := by rw [hx]
· intro hx
have hmul : (m₁ - m₂) * x = b₂ - b₁ := by
rw [hx, Rat.mul_comm, Rat.div_mul_cancel hd]
grind/-- Two different lines with the **same** slope never meet: if `b₁ ≠ b₂` then
`m·x + b₁ ≠ m·x + b₂` for every `x` — the gap between them is always `b₂ − b₁`. -/
theorem parallel_never_meet (m b₁ b₂ x : Rat) (h : b₁ ≠ b₂) : m * x + b₁ ≠ m * x + b₂ := by
intro heq
exact h (Rat.add_left_cancel (m * x) heq)/-- The *Sunzi Suanjing* puzzle: chickens and rabbits in a cage have `35` heads and `94` legs.
Elimination: subtract twice the heads equation from the legs equation to get `2r = 24`, so
`r = 12` rabbits and `c = 23` chickens. -/
theorem chickens_rabbits (c r : Rat) (h₁ : c + r = 35) (h₂ : 2 * c + 4 * r = 94) :
c = 23 ∧ r = 12 := by
have h2r : 2 * r = 24 :=
calc 2 * r = (2 * c + 4 * r) - 2 * (c + r) := by grind
_ = 94 - 2 * 35 := by rw [h₂, h₁]
_ = 24 := by grind
have hr : r = 12 := by grind
have hc : c = 23 := by grind
exact ⟨hc, hr⟩/-- The temperature at which the Celsius and Fahrenheit scales show the same number: the
system `F = (9/5)·C + 32`, `F = C`. Substituting the second into the first leaves
`(9/5)·C + 32 = C`, whose only solution is `C = −40`. -/
theorem celsius_fahrenheit (c : Rat) : 9 / 5 * c + 32 = c ↔ c = -40 := by
constructor
· intro h
grind
· intro h
rw [h]
grind/-- A system with no solution: `x + y = 3` and `2x + 2y = 10`. Doubling the first equation
gives `2x + 2y = 6`, so a solution would make `6 = 10`. (The graphs are parallel lines.) -/
theorem parallel_system : ¬ ∃ x y : Rat, x + y = 3 ∧ 2 * x + 2 * y = 10 := by
intro ⟨x, y, h₁, h₂⟩
have h610 : (6 : Rat) = 10 :=
calc (6 : Rat) = 2 * (x + y) := by rw [h₁]; grind
_ = 2 * x + 2 * y := by grind
_ = 10 := h₂
exact absurd h610 (by decide)/-- A system with infinitely many solutions: `x + 2y = 4` and `2x + 4y = 8` describe the same
line, and for every number `t` the point `(4 − 2t, t)` solves both. -/
theorem same_line_system (t : Rat) :
(4 - 2 * t) + 2 * t = 4 ∧ 2 * (4 - 2 * t) + 4 * t = 8 := by
constructor <;> grindThe general results: a unique solution when , and "two solutions give infinitely many".
/-- A system `a·x + b·y = e`, `c·x + d·y = f` with `a·d − b·c ≠ 0` has exactly one solution.
Eliminating `y` (multiply the equations by `d` and `b` and subtract) gives
`(a·d − b·c)·x = e·d − b·f`; eliminating `x` gives `(a·d − b·c)·y = a·f − e·c`. -/
theorem cramer (a b c d e f : Rat) (h : a * d - b * c ≠ 0) :
∃ x y, (a * x + b * y = e ∧ c * x + d * y = f) ∧
∀ x' y', a * x' + b * y' = e → c * x' + d * y' = f → x' = x ∧ y' = y := by
refine ⟨(e * d - b * f) / (a * d - b * c), (a * f - e * c) / (a * d - b * c), ⟨?_, ?_⟩, ?_⟩
· grind
· grind
· intro x' y' h₁ h₂
have hx : (a * d - b * c) * x' = e * d - b * f := by grind
have hy : (a * d - b * c) * y' = a * f - e * c := by grind
constructor
· calc x' = (a * d - b * c) * x' / (a * d - b * c) := by
rw [Rat.mul_comm, Rat.mul_div_cancel h]
_ = (e * d - b * f) / (a * d - b * c) := by rw [hx]
· calc y' = (a * d - b * c) * y' / (a * d - b * c) := by
rw [Rat.mul_comm, Rat.mul_div_cancel h]
_ = (a * f - e * c) / (a * d - b * c) := by rw [hy]/-- If two points solve the linear equation `a·x + b·y = e`, so does every point
`((1 − t)·x₁ + t·x₂, (1 − t)·y₁ + t·y₂)` on the line through them:
the left side becomes `(1 − t)·e + t·e = e`. Applied to each equation of a system, this shows
that a system with two solutions has a whole line of solutions. -/
theorem between_solutions (a b e x₁ y₁ x₂ y₂ t : Rat)
(h₁ : a * x₁ + b * y₁ = e) (h₂ : a * x₂ + b * y₂ = e) :
a * ((1 - t) * x₁ + t * x₂) + b * ((1 - t) * y₁ + t * y₂) = e :=
calc a * ((1 - t) * x₁ + t * x₂) + b * ((1 - t) * y₁ + t * y₂)
= (1 - t) * (a * x₁ + b * y₁) + t * (a * x₂ + b * y₂) := by grind
_ = (1 - t) * e + t * e := by rw [h₁, h₂]
_ = e := by grind/-- Different values of `t` give different points, as long as the two starting points differ.
So "two different solutions" really does give **infinitely many**: one for each number `t`. -/
theorem between_points_distinct (x₁ y₁ x₂ y₂ s t : Rat) (hne : (x₁, y₁) ≠ (x₂, y₂))
(hst : s ≠ t) :
((1 - s) * x₁ + s * x₂, (1 - s) * y₁ + s * y₂) ≠
((1 - t) * x₁ + t * x₂, (1 - t) * y₁ + t * y₂) := by
intro heq
simp only [Prod.mk.injEq] at heq
obtain ⟨hx, hy⟩ := heq
have hst' : s - t ≠ 0 := fun h0 => hst (by grind)
have hx' : (s - t) * (x₂ - x₁) = 0 := by grind
have hy' : (s - t) * (y₂ - y₁) = 0 := by grind
have ex : x₂ - x₁ = 0 := (Rat.mul_eq_zero.mp hx').resolve_left hst'
have ey : y₂ - y₁ = 0 := (Rat.mul_eq_zero.mp hy').resolve_left hst'
exact hne (by rw [show x₁ = x₂ by grind, show y₁ = y₂ by grind])What is formalised: every theorem of this lesson, over the rational numbers, including both halves of the "one, none or infinitely many" argument. Routine rearrangements are closed by grind, a decision procedure for such algebra. Mathlib treats the same ideas far more generally — lines as affine subspaces, systems as matrices, and Cramer's rule as Matrix.cramer — which you will meet in linear algebra.
Tables and systems by computer
"""Linear relationships in tables, and systems of two linear equations.
Part 1 decides, with exact fractions, whether a table of values comes from a
linear relationship y = m*x + b (constant slope between all pairs of
consecutive points) and whether it is proportional (b = 0). Part 2 solves
the lesson's systems by elimination and checks each solution. Part 3 goes
through EVERY system a*x + b*y = e, c*x + d*y = f with all six coefficients
in -2..2 (15,625 systems) and sorts them into one solution, no solution and
infinitely many - finding no other possibility, as the lesson proves.
"""
from fractions import Fraction as F
from itertools import product
#: name -> list of (x, y) pairs
TABLES = {
"taxi fare (km, soles)": [(0, 5), (1, 7), (2, 9), (5, 15)],
"Celsius -> Fahrenheit": [(-40, -40), (0, 32), (25, 77), (100, 212)],
"rice, kg -> rupees": [(1, 60), (2, 120), (5, 300), (8, 480)],
"square: side -> area": [(1, 1), (2, 4), (3, 9), (4, 16)],
}
#: name -> (a, b, e, c, d, f) meaning a*x + b*y = e and c*x + d*y = f
SYSTEMS = {
"chickens and rabbits": (1, 1, 35, 2, 4, 94),
"y = 1.8x + 32, y = x": (F(-9, 5), 1, 32, -1, 1, 0),
"x + y = 3, 2x + 2y = 10": (1, 1, 3, 2, 2, 10),
"x + 2y = 4, 2x + 4y = 8": (1, 2, 4, 2, 4, 8),
}
def slope(p, q):
"""Exact slope between points p and q (with different x-coordinates)."""
(x1, y1), (x2, y2) = p, q
if x1 == x2:
raise ValueError("vertical: slope undefined")
return F(y2 - y1) / F(x2 - x1)
def linear_fit(points):
"""Return (m, b) if all points lie on one line y = m*x + b, else None."""
slopes = {slope(p, q) for p, q in zip(points, points[1:])}
if len(slopes) != 1:
return None
m = slopes.pop()
x0, y0 = points[0]
return m, F(y0) - m * x0
def line_text(m, b):
"""Readable equation y = mx + b, e.g. 'y = (9/5)x + 32' or 'y = 60x'."""
slope_part = f"{m}x" if m.denominator == 1 else f"({m})x"
if b == 0:
return f"y = {slope_part}"
sign = "+" if b > 0 else "-"
return f"y = {slope_part} {sign} {abs(b)}"
def classify(a, b, e, c, d, f):
"""Classify a*x + b*y = e, c*x + d*y = f.
Returns ("one", (x, y)), ("none", None) or ("infinite", None).
"""
det = F(a) * d - F(b) * c
if det != 0:
x = (F(e) * d - F(b) * f) / det
y = (F(a) * f - F(e) * c) / det
return "one", (x, y)
if a == b == c == d == 0:
return ("infinite", None) if e == f == 0 else ("none", None)
# Rank 1: consistent exactly when the augmented minors vanish too.
if F(a) * f - F(c) * e == 0 and F(b) * f - F(d) * e == 0:
return "infinite", None
return "none", None
def check(a, b, e, c, d, f, x, y):
"""Does (x, y) satisfy both equations exactly?"""
return a * x + b * y == e and c * x + d * y == f
def census(values):
"""Classify every system with all six coefficients in ``values``."""
counts = {"one": 0, "none": 0, "infinite": 0}
bad = 0
for a, b, e, c, d, f in product(values, repeat=6):
kind, sol = classify(a, b, e, c, d, f)
counts[kind] += 1
if kind == "one" and not check(a, b, e, c, d, f, *sol):
bad += 1
return counts, bad
def main():
print("1. Is the table linear (one slope between consecutive points)?")
for name, points in TABLES.items():
fit = linear_fit(points)
if fit is None:
print(f" {name:<23} not linear: slopes vary")
else:
m, b = fit
kind = "proportional" if b == 0 else "linear, not proportional"
print(f" {name:<23} {line_text(m, b)} ({kind})")
print()
print("2. Systems solved by elimination")
for name, coeffs in SYSTEMS.items():
kind, sol = classify(*coeffs)
if kind == "one":
ok = "checks" if check(*coeffs, *sol) else "FAILS"
text = f"x = {sol[0]}, y = {sol[1]} ({ok})"
else:
text = {"none": "no solution", "infinite": "infinitely many"}[kind]
print(f" {name:<24} {text}")
print()
counts, bad = census(range(-2, 3))
total = sum(counts.values())
print(f"3. All {total} systems with coefficients in -2..2:")
for kind in ("one", "none", "infinite"):
share = 100 * counts[kind] / total
print(f" {kind:<9} solution(s): {counts[kind]:>6} ({share:.1f}%)")
print(f" unique solutions failing the substitution check: {bad}")
print()
print("Epistemic status: parts 1 and 2 are exact rational arithmetic, and")
print("every solution is checked by substitution. Part 3 is an exhaustive")
print("check of finitely many systems; the lesson proves for ALL systems")
print("that one, none and infinitely many are the only possibilities.")
if __name__ == "__main__":
main()About four systems in five have exactly one solution: the determinant is usually not zero. The rest have none or infinitely many, and the program never met any other case — a finite confirmation of what the theorem proves for every system. Every unique solution was also checked by substituting it back into both equations.
Explore: two lines
The plot starts with the thermometer puzzle: (Fahrenheit) and (the same number). The marked point is where the lines meet.
Where do two lines meet?
Starts at F = 1.8C + 32 and F = C.
- y = m₁x + b₁
- y = m₂x + b₂
- y = m₁x + b₁: y = 33.8
- y = m₂x + b₂: y = 1
Things to try:
- Make the two slopes equal. What happens to the meeting point? Now make the intercepts equal too.
- Keep and change . How does the meeting point move? Can you predict it with the formula ?
- Make one slope positive and the other negative. Can such lines ever be parallel?
Exercises
1. Linear relationships and simultaneous equations
Warm-upHumanFind the slope of the line through and .
2. Linear relationships and simultaneous equations
Warm-upHumanWhat is the slope of the line through and ?
3. Linear relationships and simultaneous equations
CoreHumanThe line passes through the point . What is ?
4. Linear relationships and simultaneous equations
CoreHumanWhich is the equation of the line through and ?
5. Linear relationships and simultaneous equations
CoreHumanWhich of these relationships are proportional? (Choose all that apply.)
6. Linear relationships and simultaneous equations
CoreHumanAt a market in Nairobi, mangoes and avocados cost shillings, while mango and avocados cost shillings. How much does one mango cost, in shillings?
7. Linear relationships and simultaneous equations
CoreHumanHow many solutions does the system , have?
8. Linear relationships and simultaneous equations
CoreFormalWhich Lean statement says "the slope between any two points of the line is "? (Here slope x₁ y₁ x₂ y₂ is (y₂ - y₁) / (x₂ - x₁), and Lean defines division by zero to give .)
9. Linear relationships and simultaneous equations
StretchComputationalWrite fit_line(points) for a list of points (x, y) with distinct -values. If all the points lie on one line , return the pair (m, b) as Fractions; otherwise return None. (Use exact fractions, not floats.)
10. Linear relationships and simultaneous equations
StretchHumanLet and . The function (first , then ) is linear. What is its -intercept?
Common misconceptions
Misconception
Slope as "run over rise". Slope is : change in divided by change in . Upside down, the line through and would get slope — but it climbs for every across, so its slope is .
Misconception
"Every straight-line relationship is proportional." Only lines through the origin are. The taxi fare is linear, but km costs soles while km costs , not . Doubling the input doubles the output only when .
Misconception
"A vertical line has slope zero." A horizontal line has slope : its rise is . A vertical line has run , and division by is undefined, so a vertical line has no slope. (Its equation is , which is not of the form .)
Misconception
Mixing the order of subtraction. gives the wrong sign. Either order of the points is fine, but use the same order on top and bottom.
Misconception
"A system of two equations always has exactly one solution." Parallel lines give none, and two equations describing the same line give infinitely many. What can never happen is exactly two solutions.
Other ways of seeing
Geometry— Similar triangles and parallel lines
Slope is a geometric invariant: every slope triangle on a line has the same shape, so the ratio rise ÷ run is the same. Parallel lines are lines with the same slope, and the formula shows that through any point there is exactly one line parallel to a given non-vertical line. That is the coordinate version of the parallel postulate of Euclid's geometry — a statement that, astonishingly, fails in the non-Euclidean geometries of the sphere and the hyperbolic plane (see non-Euclidean geometry).
Algebra— Elimination becomes linear algebra
Elimination works because we may add multiples of equations to each other without changing the solutions. With many equations and many unknowns, doing this systematically is Gaussian elimination, and the coefficients arranged in a rectangle form a matrix. The number is the determinant of the matrix ; geometrically, it measures how the map scales areas, which is why it is zero exactly when the system fails to have a unique solution. This is the beginning of linear algebra.
Category theory— Linear functions compose
Doing and then gives — another linear function, whose slope is the product of the slopes. Converting Celsius to Fahrenheit and Fahrenheit to Kelvin, for instance, composes into one linear conversion. Every linear function with can be undone: the inverse of is . Linear functions with non-zero slope, under composition, are a first example of a structure that mathematicians call a group (see chaining functions).
Wonder Trail
Chaining functions — and what is special about doing one thing after another — is the theme of this trail. It is written for older students, but the first steps follow directly from the composition of linear functions above.
Wonder Trail · Optional · never gradedArrows that composeWhat do functions between sets, maps between groups and continuous maps between shapes have in common? What if we studied only the arrows?Follow the trailHistory and global context
- Chapter 8 of the Chinese Nine Chapters on the Mathematical Art, Fangcheng ("rectangular arrays"), solves systems of several linear equations in several unknowns. The coefficients were laid out as columns of counting rods on a board and combined column by column — the method we now call Gaussian elimination, more than 1,500 years before Gauss. The same chapter states rules for calculating with negative numbers, which elimination needs.
- The Sunzi Suanjing ("Master Sun's Mathematical Manual", China, between the 3rd and 5th centuries CE) contains the pheasants-and-rabbits problem. In Japan it later became tsurukamezan, the "crane and turtle calculation", still a favourite in schools.
- In the 1630s, Pierre de Fermat and René Descartes independently connected algebra with geometry through coordinates. Fermat showed that every equation of the first degree in two unknowns describes a straight line — which is why such equations are called linear.
- Determinants appeared in the work of Seki Takakazu in Japan (1683) and, independently, Gottfried Wilhelm Leibniz in Germany (1693). Gabriel Cramer published the general formula for solving systems with determinants in 1750.
Further reading
- I. M. Gelfand, E. G. Glagoleva and A. A. Kirillov, The Method of Coordinates (English edition 1990) — a short, beautiful book on points, lines and equations.
- I. M. Gelfand and A. Shen, Algebra (1993).
- Kangshen Shen, John N. Crossley and Anthony W.-C. Lun, The Nine Chapters on the Mathematical Art: Companion and Commentary (1999) — including the fangcheng method.
- Victor J. Katz, A History of Mathematics: An Introduction (3rd edition, 2009).