Before Euclid, math was a bag of recipes that worked. The Greeks asked a new question — how do you know? — and the answer they invented, the proof, is still the only move in the game.
Each chapter here grabs a stretch of the timeline, picks a handful of fields off the map, and hands you widgets you can actually drag. Read the prose, then break the toy — that's the deal.
Math did not start with proof. For a couple of thousand years it was a bag of recipes that worked. Babylonian scribes solved quadratic-flavoured problems on clay tablets and had a stunningly good approximation of √2 — accurate to six decimal places — carved around 1800 BCE. Egyptian rope-stretchers laid out right angles with a 3-4-5 knotted loop. None of them could tell you why any of it was true. It worked, so you used it. The original "ship it and don't ask questions."
This chapter is about the moment someone did ask questions. The Greeks took the recipes and demanded a reason for each one — a chain of argument starting from a few things everyone already agreed on. That chain is the proof, and inventing it is arguably the single most consequential thing in this entire book. Everything downstream — algebra, calculus, computers, the AI reading this to you — inherits the habit.
We'll cover four map fields in this chapter: number theory, Euclidean geometry, the construction methods that came with it, and trigonometry. Three widgets, one code card, one quiz. Let's go.
Long before anyone wrote x for an unknown, the Pythagoreans were doing arithmetic by arranging pebbles on the ground. Stack pebbles in a triangle — 1, then a row of 2, then 3, then 4 — and you've drawn the triangular numbers: 1, 3, 6, 10, 15. Arrange them in a square grid instead and you get the square numbers: 1, 4, 9, 16. They literally watched number patterns by looking at shapes. (This is also where "square" and "cube" got their names — they were shapes first.)
The deepest thing they noticed: some numbers can't be arranged into any rectangle wider than one pebble. 7 pebbles only ever make a single line. These are the primes — and they're the atoms of arithmetic. Every whole number is exactly one product of primes, in exactly one way. 12 = 2·2·3, and there's no other recipe. Think of it as the original algebraic data type: a number is a multiset of prime factors, and multiplication just merges the bags. This is the fundamental theorem of arithmetic, and it's why primes matter — break a number down and you always bottom out at the same irreducible parts.
Centuries later Diophantus would push this further, asking which equations have whole-number answers (the kind of question that births a whole field). And Pierre de Fermat, scribbling in a margin, would foreshadow three more centuries of number theory with one famously unproven claim. We'll meet them properly in Chapter 2 — for now, just sit with the primes.
So how do you find the primes? Around 240 BCE, Eratosthenes — the same man who measured the circumference of the Earth with a stick and a shadow — gave an answer so clean we still teach it on day one of any programming course. Write the numbers in a grid. Take the smallest one you haven't dealt with (2). It's prime. Now cross out every multiple of it — they're all composite by definition. Move to the next survivor (3), cross out its multiples, and repeat.
That's the sieve of Eratosthenes. It never does a division, never tests a number for primality — it just walks forward crossing out multiples and lets the primes fall out as whatever's left standing. Drag through it below.
Around 300 BCE, Euclid wrote down the rules of the game for geometry and then played it for thirteen books. He started with five postulates — five things you're allowed to assume for free:
Everything else — every theorem in the Elements, all 465 of them — has to be earned by argument from those five rules plus what you've already proved. Nothing gets asserted; everything gets derived. That's the template the whole book runs on. It made the Elements the longest-running textbook in history: it was still standard classroom material in the early 20th century, more than two thousand years after it was written. No other technical book comes close.
That fifth postulate — the parallels one — bothered people for two millennia. It's clunkier than the other four, and generations of mathematicians tried to derive it from them and failed. The punchline, which we'll detonate in Chapter 5, is that you can't: drop it or change it and you get entirely new, perfectly consistent geometries. Hold that thought.
Here's the part that should feel familiar to a programmer. Euclid's geometry comes with exactly two tools: a compass (draw a circle) and a straightedge (draw a line). That's the entire API. No ruler markings, no protractor, no measuring. A geometric "construction" is a program written in those two operations — and a proof that it produces the thing you claimed.
The very first proposition of the Elements, Book I, Proposition 1, builds an equilateral triangle out of nothing but two points. Draw a circle centred at A passing through B. Draw another centred at B passing through A. They cross at a point — call it C. Connect A, B, and C. Because both circles have the same radius (the distance AB), all three sides are equal. It's a four-line program whose correctness is the proof. Build it yourself below — drag A or B and watch the three sides stay equal no matter what.
The Greeks didn't just invent proof — they invented specific proof moves you'll recognize from any debugging session. The sharpest is proof by contradiction: assume the opposite of what you want, run it forward, and hit something absurd. The absurdity means your assumption was the bug. Two of antiquity's greatest hits are exactly this.
The Pythagoreans believed every length was a ratio of whole numbers. Then someone proved the diagonal of a unit square isn't. Assume √2 = a/b in lowest terms (no common factors). Square it: a² = 2b², so a² is even, so a is even, so a = 2k. Substitute: 4k² = 2b², i.e. b² = 2k², so b is even too. But we assumed a/b had no common factors — and now both are even. Contradiction. The assumption was the bug: √2 is not a fraction. Legend says the man who leaked this proof drowned at sea. Math's first scandal.
Euclid's proof is a programmer's delight. Assume there are finitely many primes — list them all: p₁, p₂, …, pₙ. Now multiply them together and add one: N = p₁·p₂·…·pₙ + 1. Dividing N by any prime on your list leaves remainder 1, so none of them divides N. So either N is itself a new prime, or it has a prime factor you missed. Either way your "complete" list was incomplete. Contradiction — there's no finite list, so the primes never run out.
The astronomers had a different problem. The sky is full of angles — how far apart two stars are, how high the sun climbs — but the math they wanted to do was about lengths. They needed an adapter. Around 140 BCE, Hipparchus built the first one: a table of chords, listing for each angle the length of the straight line across a circle that the angle cuts off. Give it an angle, get back a length. That's the whole idea of trigonometry — it's the adapter between rotation and distance.
The version we use, the sine, traveled. Indian mathematicians (Aryabhata) reworked the chord into the half-chord we now call sine; the word itself is a chain of mistranslations from Sanskrit through Arabic into Latin. Islamic-world astronomers like al-Tusi turned it into a full discipline; it reached Europe in time to power navigation and the scientific revolution. Drag the widget below to see what sine actually is: the height of a point as it goes around a circle.
That wave the point traces? It's everywhere downstream. Once you can turn rotation into a smooth up-and-down, you can describe anything periodic — a vibrating string, an alternating current, a sound. In Chapter 4 we'll watch Fourier claim that any repeating signal is just a stack of these sine waves, and in Chapter 8 that idea becomes the backbone of every digital signal you've ever streamed. Trig is where it all starts.
Eratosthenes' algorithm survives unchanged into modern languages. Here it is two ways: the imperative array-sieve in Scala (cross out multiples in place), and the famous lazy infinite version in Haskell (elegant, not actually the "real" sieve, but a rite of passage). Flip between them.
In one chapter the Greeks gave mathematics its spine: the proof, the idea that knowledge is built from agreed-upon axioms by airtight argument. They handed us the primes (the atoms of arithmetic), the compass-and-straightedge "API" where a construction is a program, the contradiction move you still use to debug, and the sine — the adapter that turns rotation into distance. None of it has been thrown away. It's all still in production.
But notice what's missing: there's no x anywhere. The Greeks drew pictures and argued about lengths and ratios. They never wrote an equation in symbols. The next era stops drawing pictures and starts pushing symbols — and that changes everything.