About Difference Engine
Before electronic computers, anyone who needed a logarithm, a sine or a navigator's figure looked it up in a printed table, and every number in those tables had been worked out by people called computers, copied out, set in type and printed. Each step let errors in. Charles Babbage designed machines to work out tables by turning a handle and to print them without a person copying anything. This page lets you turn the handle of the second of them, Difference Engine No. 2.
THE ENGINE: pick a table, or type your own polynomial in n (up to n7, such as n^3 - 2n + 7 or n(n+1)/2) and where it starts. The page sets the starting differences on the wheels. CRANK ONCE turns the handle once, which makes one line of the table; RUN turns it as many times as you pick, at the speed you pick (PAUSE stops it where it is and RESUME finishes the turns that were left; RESET starts the table again); or drag the handle's grip up and down. Each turn adds in two halves, and after each half the carries climb the columns one wheel at a time: a lever that has tipped up (red) is a carry waiting to be made. The printer sets each new value on the sheet.
WHY DIFFERENCES WORK: the same table worked out on paper. FROM THE VALUES takes differences of the values until they stop changing. LIKE THE ENGINE starts from the engine's settings (outlined in gold) and builds the table only by adding, half a turn at a time.
ERRORS: ONE WRONG DIGIT sets one wheel one too high and shows how far out the table goes. COPIED BY HAND has a person copy the engine's table with a slip now and then, and shows how differencing a printed table finds the slips. RUNNING OUT shows how far a log or sine table can be run from one setting before its last printed place goes wrong, and when a column runs out of wheels.
THE STORY
Babbage told the story that in 1821 he and the astronomer John Herschel were checking two sets of tables worked out by hand, found error after error, and he exclaimed that he wished they had been calculated by steam. In 1822 he built a small working model and announced his plan, and the government paid for a full engine. Joseph Clement, a leading toolmaker, made the parts. In 1832 Clement assembled a demonstration piece, about one seventh of the engine, which worked; it is in the Science Museum in London and is among the finest precision engineering of its time. In 1833 work stopped in a dispute with Clement, the full Difference Engine No. 1 was never finished, and in 1842 the government gave it up, after spending about £17,000.
Babbage went on to the Analytical Engine, a general-purpose machine, and from what he learnt there drew a new, simpler difference engine between 1847 and 1849: Difference Engine No. 2, with seven orders of difference and 31-digit numbers, and a printer that also pressed the results into moulds for making printing plates. It was never built in his lifetime.
In Sweden, Georg Scheutz and his son Edvard read an account of Babbage's engine and built their own difference engine, with four orders of difference. It was finished in 1853 and won a gold medal at the Paris exhibition of 1855; it went to the Dudley Observatory in Albany, New York, and a copy built in London was used by the General Register Office for life tables.
From 1985 the Science Museum, with Doron Swade as curator, built Difference Engine No. 2 from Babbage's drawings. The calculating section was finished in 1991, the two hundredth year since Babbage's birth, and it worked to 31 digits; the printer and stereotyper were finished in 2000. The whole engine has about 8,000 parts and weighs about five tonnes. It showed that the engine could have been built with the engineering of Babbage's day. A second engine was built for Nathan Myhrvold and shown at the Computer History Museum in California.
HOW IT WORKS
The method of differences. Write down the values of a polynomial for n = 0, 1, 2, …, take the differences between neighbours, then the differences of those, and so on. For a polynomial of degree k the k-th differences are all the same (k! times the number in front of nk), so the table can be run the other way: keep one number in each column, and to make the next line add each column into the one on its left. Nothing but adding is needed, which is why a machine of wheels can do it. Logs and sines aren't polynomials, but over a short stretch a polynomial fits them closely, so a table maker would set the engine from a few accurate values and run it for a stretch, then set it again.
Two halves of a turn. Adding column after column one at a time would be slow. Instead, in one half of each turn every second column is added into its neighbour at once, and in the other half the rest are. Because of the overlap the columns are out of step: the 2nd and 3rd differences must start one row early, the 4th and 5th two rows early, the 6th and 7th three. The page works these out from the table and sets them for you. (Which half comes first is the page's choice.)
Carries. When a wheel passes from 9 to 0 it tips a lever, and the 1 is carried into the wheel above later in the turn. Babbage staggered the carrying up each column, so the carries are made one wheel after another from the bottom upwards, and a carry that turns a 9 into 0 tips the next lever in time to be carried in the same sweep (999 + 1 ripples all the way up).
Simplifications. The drawing shows what each part does, not its real shape: the engine's cams, sectors, locks and the printer's inner workings are simplified, and the stereotype mould is shown as a tray of impressions. The page's handle makes one line per turn; the real handle is geared down and takes several turns. Units are on the bottom wheel. The page keeps negative numbers as tens' complement (−1 is 31 nines, so a top wheel of 5 to 9 means a negative number); a column runs out when its number needs more than that. The printed sheet shows n beside each value to make it readable, and log and sine tables are held to 24 decimal places and printed rounded to 10. The slips in COPIED BY HAND are made up by a random number generator at the rate you choose, not taken from any real table.
FURTHER WATCHING AND READING