# What was Charles Babbage's Difference Engine?

Date: 2019-06-15 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/what-was-babbages-difference-engine/

**Answer:** The Difference Engine was a hand-cranked machine that Charles Babbage designed to calculate and print mathematical tables automatically, using nothing but repeated addition. He announced it in 1822, and although the full engine was never finished in his lifetime, it was the first complete design for an automatic calculating machine.

Long before electronic computers, people who needed numbers looked them up in printed books of tables: logarithms for astronomers, interest rates for bankers, positions of stars for sailors. Every one of those figures had been worked out by hand, copied by hand and set in type by hand. Mistakes crept in at each step, and a wrong figure in a navigation table could put a ship on the rocks.

Charles Babbage, an English mathematician born in 1791, decided that the cure was to take people out of the arithmetic. In 1822 he announced a machine that would compute tables and print them without a human hand touching the numbers. He called it the Difference Engine.

## What happened in 1822

The story usually starts a year earlier. In 1821 Babbage was checking hand-calculated tables with his friend John Herschel, an astronomer. They found one mistake after another, and Babbage is reported to have exclaimed, "I wish to God these calculations had been executed by steam." Steam was the great new power source of the day, so the wish meant: let a machine do this.

Babbage had been building a small model of a calculating machine since about 1819. On 14 June 1822 he presented a paper to the Royal Astronomical Society in London titled "Note on the application of machinery to the computation of astronomical and mathematical tables." That paper is the public announcement of the idea. The British government saw the value of cheaper, more reliable tables, and in 1823 it gave him £1,700 to begin building a full-scale engine.

## How the machine worked

The engine's name comes from a mathematical shortcut called the *method of finite differences*. Its great advantage is that it turns complicated calculations into simple additions, and addition is much easier to build out of gears than multiplication or division.

Numbers were held on toothed wheels, one wheel for each digit, each marked 0 to 9. That makes the engine *decimal* (it counts in tens, like we do) and *digital* (it only accepts whole steps, never an in-between value). If a wheel stopped halfway between two digits, the design made the machine jam on purpose, a simple form of error detection. A printing apparatus was built into the design, so results went straight from the gears to the page with no copying.

The scale was enormous. As drawn in 1830, Difference Engine No. 1 worked with sixteen-digit numbers and called for about 25,000 parts. Finished, it would have weighed roughly four tons and been about eight feet tall.

## A worked example: tables by addition alone

Here is the method of differences on a tiny scale, using the squares of whole numbers.

| n | n² | First difference | Second difference |
|---|---|---|---|
| 1 | 1 | | |
| 2 | 4 | 3 | |
| 3 | 9 | 5 | 2 |
| 4 | 16 | 7 | 2 |
| 5 | 25 | 9 | 2 |

The "first difference" is the gap between neighboring squares. The "second difference" is the gap between those gaps, and for squares it is always 2. Once you know that, you never need to multiply again:

1. Take the last first difference (9) and add the constant 2: you get 11.
2. Add 11 to the last square (25): you get 36, which is 6².
3. Repeat: 11 + 2 = 13, and 36 + 13 = 49, which is 7².

Each new row costs two additions. The Difference Engine did exactly this with columns of wheels, one column per difference, so turning the crank produced the next value in the table. Many useful functions in science and navigation can be approximated by polynomials (sums of powers like x² and x³), which is why one adding machine could produce so many kinds of tables.

> **Try it:** Write out the cubes 1, 8, 27, 64 and 125, then compute the first, second and third differences. You should find the third difference is always 6. Use that constant to predict 6³ and 7³ by addition alone, then check your answers with a calculator.

## Why it matters

In 1832 Babbage's engineer, the master toolmaker Joseph Clement, delivered a small demonstration section, about one-seventh of the calculating part and some 2,000 parts. It is described as the first successful automatic calculating device, and it still works today. Babbage used it to give demonstrations to guests at his home. Lady Byron, after seeing it in 1833, called it "the thinking machine (or so it seems)." Her daughter, Ada, saw it that same year and became one of Babbage's most important supporters.

The deeper point is the one Lady Byron sensed. Calculation had always been treated as mental work. Babbage showed that a precise rule could be built into brass and iron, and that the machine would follow the rule more reliably than a tired clerk. That idea, breaking a task done with the mind into steps a machine can carry out, sits underneath every computer, and so underneath every AI system people use in 2019, from voice assistants to game-playing programs.

The proof came long after Babbage. Between 1847 and 1849 he designed an improved Difference Engine No. 2 with about 8,000 parts. He never built it, but a team in London built one faithfully from his drawings, and it was completed in 2002. It weighs five tons, measures eleven feet long, and it works.

## Why did Babbage never finish the Difference Engine?

There was no single reason. The engine needed thousands of parts made to a precision that was costly to achieve with the metalworking of the 1820s and 1830s, and the bills kept growing. In 1833 work stopped after a dispute between Babbage and Clement over payment for moving Clement's workshop closer to Babbage's home. About 12,000 finished parts were never used and were eventually melted down. By the time the government formally ended its funding in 1842, the Treasury had spent about £17,500, a huge sum.

Babbage himself made matters harder. He was quick to take offense and attacked critics in public, and he did little to explain the mathematical promise of his machines. Many experts judged the engine only as a way to make tables, and some argued that existing tables were accurate enough. Worst of all for the project, Babbage's mind had moved on: around 1834 he began designing something far more ambitious, a machine that could be programmed for almost any calculation. That design, the Analytical Engine, made the Difference Engine look old-fashioned to its own inventor, and the government's confidence faded. The 2002 build settled one question for good, though: the design was sound.

## Sources

- A Brief History (The Babbage Engine): https://www.computerhistory.org/babbage/history/
- The Engines (The Babbage Engine): https://www.computerhistory.org/babbage/engines/
- Difference engine: https://en.wikipedia.org/w/index.php?title=Difference_engine&oldid=901832015
