Charles Babbage · Difference Engine No. 2 · 1847–49
Babbage’s Difference Engine No. 2: the machine that tabulates polynomials by adding, to 31 digits
Babbage designed it in 1847–49 and never built it; the Science Museum in London did, between 1985 and 2002, and it worked. Eight columns of 31 figure wheels hold a number and its differences. Every four turns of the handle (geared down 4:1 in the modern build) the columns add into one another, carries climb the stacks, and a new line of the table comes out. Choose a table, or give the engine up to eight whole numbers, and turn the handle.
Swipe the engine sideways to see all eight columns; the handle is at the right.
Tables by addition
Errors in hand-calculated mathematical and astronomical tables, and in copying and typesetting them, were what Babbage set out to remove. His answer was a machine that uses the method of finite differences, which needs only addition. The Computer History Museum’s example: x² + 4 gives 5, 8, 13, 20 for x = 1 to 4. The differences between them are 3, 5, 7, and the differences of those are always 2. Add 2 to 7 and you get the next difference, 9; add 9 to 20 and you get the next value, 29. Then 11 and 40, and so on, with no multiplication.
A polynomial of degree seven has a constant seventh difference, so a machine that stores a value and its seven differences can keep tabulating it, within its 31 digits. Difference Engine No. 2 holds eight numbers of 31 digits each: the table value and seven differences.
How a column adds
Each digit is a figure wheel with 40 teeth: four runs of 0 to 9 round its rim, so one tooth is one unit. A column is 31 wheels stacked on one axis, the units at the bottom. To add one column to the next, the engine turns every wheel of the first back to zero; sector wheels between the columns carry those teeth across, so each wheel of the second column moves on by the first column’s digit, all 31 at once. The first column is then restored from the sectors, so nothing is lost.
When a wheel passes from 9 to 0 it trips a spring “warning” lever. Then a vertical axis with 30 carry arms set in a helix, 22½° apart except for a 45° gap between the 15th and 16th, turns and polls the warnings from the bottom up. Where a lever is warned, the passing arm moves it on, and the lever advances the wheel above by one. If that wheel was at 9 it passes to 0 and warns the next one, which the next arm reaches a moment later. In the worst case, 1 added to thirty-one 9s, the carry climbs the whole column and leaves 31 zeros. Choose “The worst carry” to see it.
Wheels are locked by wedges between operations. The wedges correct small misalignments; a wheel far enough out of position to present a tooth to its wedge blocks it and jams the engine, which Babbage meant as a warning that a result could not be trusted.
Two half-cycles
Adding column by column, right to left, would leave three quarters of the engine idle. Babbage’s engine instead adds all the odd columns into the even ones at once (1 into 2, 3 into 4, 5 into 6, 7 into the table), then the even columns into the odd ones (2 into 3, 4 into 5, 6 into 7) while the table goes to the printer; columns are numbered from the handle end. For that to give the right table, the starting values on alternate columns are set half a cycle apart; the drawing above is set up that way. The time per result is the same whether a table uses one difference or seven.
| Quantity | Value | Source |
|---|---|---|
| Columns × figure wheels | 8 × 31 | Swade, Calculation |
| Teeth per figure wheel | 40 (four runs of 0–9) | Swade |
| Carry arms per column | 30, at 22½° (45° between the 15th and 16th) | Swade |
| Handle turns per result | 4 (with the 4:1 reduction) | Swade, Build |
| Results per minute | 10 (one every 6 seconds) | Swade, Build |
| Digits printed | 30 of 31 | Swade, Printing |
Built about 150 years later
Babbage left twenty large drawings of the engine but never built it. In 1985 the Science Museum set out to, under its curator of computing Doron Swade, to the 1847–49 design and with no more precision than Babbage could have had. New drawings specified each of about 8,000 parts. The calculating section was finished in 1991, the bicentenary of Babbage’s birth, and the printer and stereotyper in 2002.

The drawings had errors. Swade’s reading of the key drawing of the adding mechanism is that the warning lever is set the wrong way for the direction the wheels turn: built as drawn, it would have acted as a stop. The built engine was changed to make the carries work. The builders also fitted a 4:1 reduction gear at the handle, so four turns make one cycle; in Babbage’s design one turn of the handle was one cycle. After several thousand cycles the drive was noticeably freer and the engine ran at ten cycles a minute: one result every six seconds, forty turns of the handle a minute.

The output apparatus takes the 30 lowest digits of the table column (the top wheel is not connected to it). It inks each result on a paper roll, one line at a time, and impresses the same figures into soft material to make moulds for printing plates; the stereotyper’s line spacing and page layout can be set. The engine weighs about five tons and is eleven feet long and seven feet high. A second engine, built for Nathan Myhrvold, was shown at the Computer History Museum in California from 2008 to 2016.

Sources
The mechanism follows Doron Swade’s technical description of the engine as built; the drawing is a schematic of the arithmetic, not a copy of Babbage’s drawings.
- Doron Swade, Charles Babbage’s Difference Engine No. 2: Technical Description, Science Museum Papers in the History of Technology 5 (1996); transcription published with the author’s permission: ed-thelen.org (chapters Calculation, Printing, Build).
- Computer History Museum, The Babbage Engine: “How it Works”, “The Engines”, “A Modern Sequel”.
- Wikipedia, “Difference engine”.
- Photos, Wikimedia Commons: geni (CC BY-SA 4.0), Jitze Couperus (CC BY 2.0), Erik Pitti (CC BY 2.0).