Rules: Switch, Gate, Adder, Program

Timeline, 1822–2026
  1. 1822◆Babbage proposes the Difference Engine
  2. 1843◆Lovelace publishes the first program, for the Analytical Engine
  3. 1936◆Turing: a machine that can imitate any other
  4. 1937Shannon: relay circuits do Boolean logic
  5. 1941◆Zuse’s Z3, a programmable relay computer
  6. 1943McCulloch and Pitts: a neuron as a switch
  7. 1946ENIAC: 17,468 tubes, 150 kW
  8. 1947The transistor, Bell Labs
  9. 1958Rosenblatt’s perceptron
  10. 1959The MOSFET (Atalla and Kahng) and the planar chip
  11. 1965Moore’s observation
  12. 1969Minsky and Papert’s Perceptrons
  13. 1971◆Intel 4004, made for Busicom of Japan
  14. 1974Dennard’s scaling rules
  15. 1976Cray-1
  16. 1986Backpropagation popularised
  17. 1989LeCun’s convolutional network reads zip codes
  18. 1997◆LSTM (Hochreiter and Schmidhuber)
  19. ~2005Dennard scaling ends; clock speeds stall
  20. 2007CUDA lets GPUs run general code
  21. 2009ImageNet
  22. 2011◆K computer tops the TOP500
  23. 2012◆AlexNet, trained on two gaming GPUs
  24. 2017“Attention Is All You Need”
  25. 2020Scaling laws; GPT-3; Fugaku tops the TOP500
  26. 2022Chinchilla; H100; ChatGPT
  27. 2024100,000-GPU clusters; a 1,500 MW data-centre load drops off the Virginia grid
  28. 2025◆IEA: data centres used 415 TWh in 2024

In brief. This page builds a computer out of switches: gates that add, relays that throw relays, and a machine that can run any program, before the series asks what each flip costs.

The surprise. Konrad Zuse’s Z3 of 1941, a programmable computer, did its arithmetic with about 2,600 relays.

Take two light switches and two lamps, wire them the right way, and they add: flip both on and the lamp that means “two” lights up. A chatbot answering a question is the same idea, scaled up to a few hundred billion switches, flipping billions of times a second in a pattern that a program wrote down. This page asks what that pattern is, physically, before the rest of the series asks how much energy it costs.

It opens the physics stack of Act 1. The Yardstick set the bars; this page says what a computation is as switches. The Price of a Flip prices one switch; A model asks what we are paying those flips to compute.

  1. 1A sum made of switches
  2. 2A switch that throws a switch
  3. 3Rules on a tape
  4. Final words

1A sum made of switches

Take two light switches and two lamps. Wire the first lamp so it lights when exactly one switch is on, and the second so it lights only when both are. Now read the switches as numbers, off is 0 and on is 1, and read the lamps as a two-digit answer.

Model Two switches and two lamps. The boxes are just wiring: one passes current when exactly one input is on, the other when both are. Tap the switches.

Every case comes out right. 0 + 0 lights nothing. 1 + 0 lights the right-hand lamp. 1 + 1 lights only the left-hand one, which reads “10”: one two and no ones, in the counting system that uses only the digits 0 and 1, called binary. The two boxes are the first logic gates of this essay; engineers call them XOR (“exclusive or”) and AND.

Arithmetic, comparison and memory are all just patterns of switches driving switches. Who first showed that, and why it holds for any switch, comes in the next section.

To add bigger numbers, copy the box. Each copy adds three bits, one from each number plus the carry from the column to its right, exactly as in long addition at school.

Model Four 1-bit adders in a row make a 4-bit adder. Each “add 3 bits” box contains five gates like the two above. The carry has to travel from the right-hand column to the left before the answer is final; the grey boxes are still waiting.

Two things already show. First, the answer is not instant: each column has to wait for the carry from its neighbour, so a wider adder is slower unless it is cleverer. Second, every change flips some of the little switches inside: two to five usually, and up to thirteen of the twenty when a carry ripples all the way along. Hold on to both. Speed and the number of flips will decide everything that follows.

The maths: binary and the full adder

A binary number with digits b3b2b1b0 means 8b3 + 4b2 + 2b1 + b0. One full adder takes bits a, b and an incoming carry c and produces

sum = a ⊕ b ⊕ c, carry = (a ∧ b) ∨ (c ∧ (a ⊕ b))

where ⊕ is XOR, ∧ is AND and ∨ is OR: two XORs, two ANDs and one OR, the five gates the figure counts.

2A switch that throws a switch

A light switch needs a hand; a relay needs only a current. Telephone exchanges were built from relays by the million. In his 1937 master’s thesis at MIT, Claude Shannon showed that circuits of relays obey the algebra of logic that George Boole had written down in 1854: contacts one after the other behave like AND, contacts side by side like OR.1 Wire two relays both ways below.

Model Two relays drawn as mechanisms. Each key energises a coil, which pulls an armature that closes a contact; the lamp runs from a separate battery through those contacts. Series wiring is AND; side-by-side is OR. Timing and geometry are schematic.

The important part is easy to miss: the keys never touch the lamp’s circuit. The lamp’s current comes from its own battery, and it could just as well feed the coils of other relays, so one switch can drive several more and logic can be stacked as deep as you like. Konrad Zuse’s Z3 of 1941 used about 2,600 relays this way.2 The catch is the lever. It has mass, so it takes milliseconds to move, and it wears.

Here is that stack as a mechanism: A’s contact throws B’s coil. No second key.

Model Same relay object as above: coil, armature, contact. Default mid-action with A closed and B pulling. Timing schematic.

3Rules on a tape

An adder does one thing. The leap that made computers was a machine that could be told what to do. Charles Babbage proposed a mechanical Difference Engine to the Astronomical Society (later the Royal Astronomical Society) in 1822 and later designed a far more general Analytical Engine, programmed with punched cards; neither was finished in his lifetime.3 In 1843 Ada Lovelace published notes on the Analytical Engine that include a step-by-step method for computing Bernoulli numbers, usually counted as the first published program, and the observation that such a machine could manipulate symbols of any kind, not only numbers.3

In 1936 Alan Turing asked what it means for anything to be computable at all, and answered with a machine so simple it fits in a figure: a tape of squares, a head that reads and writes one square at a time, and a short table of rules.4

Model A Turing machine with four rules that adds one to a binary number. The blue head reads the square under it, looks up the rule for its current state and that symbol, and acts. Write your own number by tapping squares.

Turing’s point was that a single machine of this kind can read a description of any other such machine from its tape and imitate it. That is a general-purpose computer: the wiring stays fixed and the program is just data. Everything since, from ENIAC to the chip in a phone, is a faster version of this idea, with the tape replaced by memory.

Final words

A computation is a pattern of flips. Two switches make an adder; a chain of adders makes an arithmetic unit; a tape of rules makes a machine that can imitate any other. Nothing so far has said how much energy a flip costs, or why that cost stopped falling. That is the next page.

The Price of a Flip follows the switch from the vacuum tube to 2 nm silicon. On the long-run meter (the Verdict), this page sets the unit: a flip of a switch.

Notes and sources

  1. C. E. Shannon, “A Symbolic Analysis of Relay and Switching Circuits”, MIT master’s thesis (1937), published in Transactions of the AIEE 57 (1938); G. Boole, An Investigation of the Laws of Thought (1854).
  2. H. Zuse, “Z3” (completed May 1941, about 2,600 relays, destroyed in 1943; a replica is in the Deutsches Museum, Munich).
  3. C. Babbage, letter to Sir Humphry Davy on the application of machinery to calculating tables, 3 July 1822, and “Observations on the application of machinery to the computation of mathematical tables”, Memoirs of the Astronomical Society 1 (1822); the Analytical Engine was designed from 1834; A. A. Lovelace, translator’s notes to L. F. Menabrea, “Sketch of the Analytical Engine”, Scientific Memoirs 3 (1843), Note G.
  4. A. M. Turing, “On Computable Numbers, with an Application to the Entscheidungsproblem”, Proceedings of the London Mathematical Society s2-42 (1936–37). The four-rule incrementer in the figure is our own example.

Figures marked Data use the cited sources; Data + model combine them with the series’ own arithmetic. Figures marked Model are simplified models built to show a mechanism; their assumptions are listed under ⓘ data.