Difference Engine
A numerical table is a tool designed to save the time and labor of those engaged in computing work. The oldest tables which are preserved, were compiled in Babylon in the period 1800-1500 B.C. They were intended to be used for the transformation of units, for multiplication and division, and they were inscribed in cuneiform on pieces of clay. During the first century B.C. Claudius Ptolemy in Alexandria created his theory about the motions of the heavenly bodies in a work that later came to be known by the name of Almagest.
They were to form one of the Ancient World’s most important astronomical documents and they contained all the necessary tables for the calculation of eclipses as well as various kinds of ephemeris, that is to say, tables that specified the positions of the heavenly bodies during a particular period, e.g. each day for a whole year.
During the first half of the thirteenth century, the Ptolemy tables caught the attention of King Alphonso the Wise of Castile. He then gathered together a great number of scholars in Toledo who were given the task of calculating a new collection of astronomical tables. The reason for this endeavor was said to be that King Alphonso, who was interested in astronomy, had discovered many errors in Ptolemy’s tables.
The work began sometime in the 1240s and took about ten years to complete. The tables produced were later known as the Alphonsine Tables. The vast costs involved were paid for by the king, whose name soon spread with the copies of the tables throughout the European scientific world. Besides the Babylonian tables, Ptolemy’s work, and the Alphonsine Tables, a great deal of toil went into the production of many other numerical tables of different kinds during this period.
With the introduction of the art of printing throughout Europe during the latter half of the 15th century, the first tables were printed. The Alphonsine Tables, for example, were printed in Venice in 1483. At the end of the sixteenth century, several famous arithmetical and trigonometric tables were published. To simplify multiplication work, multiplication tables were published. A real revolution in the table business happened after John Napier discovered logarithms in 1614. With a table of logarithms at hand, the computational effort could be greatly reduced. In 1617 Henry Briggs published the first table of logarithms.
Two hundred years later, at the beginning of the 19th century, numerical tables were still the most important calculating aid in Europe. The sole alternatives were Napier’s Bones and the slide rule. Mechanical calculating machines were extremely rare and at most a handful of very select individuals could ever have used them for serious calculations. Most of them were simply remarkable gadgets illustrating man’s scientific progress, rather than genuine aids to calculation.
For the normal calculator or scientist who had to carry out complex computations that demanded great accuracy, Napier’s Rods and the slide rule were of little help. In effect, his tools were pen, paper, and tables. There were tables for mathematics, astronomy, navigation, physics, engineering, statistics, trade, and finance, in the army and in many other areas. The publication of such tables however required a lot of manual calculating work and the final product was full of errors.
Sometime in 1821, the young English mathematician Charles Babbage (biography of Charles Babbage) got the idea about mechanical computation. He has provided us with two versions of the origin of his ideas about machines, but the one written in 1822 seems more plausible than the other, which appeared in his autobiography some forty years later. According to the first story, in 1820 or 1821, the Astronomical Society assigned Babbage and his friend Herschel one of the tasks for improving the tables of the navigational book Nautical Almanac.
They constructed the appropriate formulas and assigned the arithmetic to clerks. To diminish errors, they had the calculations performed twice, each by a different clerk. Then they compared the two sets for discrepancies. In the course of their tedious checking, Herschel and Babbage found a number of errors, and at one point Babbage said “I wish to God these calculations had been executed by steam.” “It is quite possible,” remarked Herschel.
But in his autobiography, Babbage remembered another version of the story, which must have happened either in 1812 or 1813:
“… I was sitting in the rooms of the Analytical Society, at Cambridge, my head leaning forward on the table in a kind of dreamy mood, with a table of logarithms lying open before me. Another member, coming into the room, and seeing me half asleep, called out, “Well, Babbage, what are you dreaming about?” to which I replied “I am thinking that all these tables” (pointing to the logarithms) “might be calculated by machinery.”
Whatever the truth, sometime in 1820 or 1821 Babbage started his work on the calculating machine, making several designs for clockwork-like mechanisms, that could be made to control a set of wheels with numbers along their edges that could print on paper. He made a small model consisting of 96 wheels and 24 axes, which he later reduced to 18 wheels and 3 axes. The machine was ready by the end of the spring of 1822 and in June was announced publicly and has been examined by several of the members of the Astronomical Society.
It seems Babbage must have known very little about machine design, mechanical calculating, and the history of such machines at that time because he started by considering the use of sliding rods, instead of the more natural use of wheels in the adding mechanism. This kind of mechanism which was “new” in the history of calculating machines, gives rise to grave difficulties in the process of carrying, a fact which Babbage eventually realized. In fact, this seems to have been such a revelation to him, that in November of 1822, he noted very solemnly that he had in the future decided always to choose circular motion for this purpose.
The working model had a section of the calculating mechanism, including two orders of difference, but no printing mechanism. He successfully calculated the first thirty values, arising from the formula + x + 41, which was a favorite example of his, because it generates a lot of prime numbers. The machine produced correct results at the rate of 33 digits per minute, so the values were tabulated in two and a half minutes. Later in the same year, Babbage wrote a note to the Society and an article “On the Theoretical Principles of the Machinery for Calculating Tables” for Brewster’s Journal of Science:
I have contrived methods by which type shall be set up by the machine in the order determined by the calculation. The arrangements are such that… there shall not exist the possibility of error in any printed copy of tables computed by this engine.
Babbage wrote also a letter on the general subject to the president of the Royal Society, Sir Humphry Davy. In this letter, Babbage pointed out the advantages such a machine would have for the Government in producing lengthy tables for navigation and astronomy and proposed to construct a machine on an enlarged scale for the Government’s use.
The Astronomical Society received Babbage’s proposal with the highest enthusiasm, and the Royal Society reported favorably on his project for building what he called a Difference Engine, a specialized calculating machine for the calculation of tables, using the method of differences.
Babbage was not the first to suggest a printing calculator, nor was he the first to propose the method of differences as a suitable principle on which to base a mechanized calculation. This distinction goes to the German engineer and master builder Johann Helfrich Müller, who described his dreams of calculating machines, based on the method of differences as early as 1784, but his idea remained only on paper. There is evidence, that at some point, Babbage learned about Müller and his project, but this most probably happened after 1821, when he had already started his work on Difference Engine.
What is the essence of the method of differences, which underlies Babbage’s first automatic calculating machine? Let’s consider the same formula, used by Babbage: T=x2 + x + 41. (See Table A above.) It generates a sequence of values for T, which happen to be prime numbers, as seen in the table in the nearby figure, in which with is noticed the first difference column, while with — the second difference column. If we take the differences between successive values of T, these so-called first differences follow quite a simple rule.
If we take the differences between the differences, known as the second differences, the result is even more striking-the second difference, is a constant. With this knowledge, the table can be built up in a very simple way, as shown by the box in the table. Take the second difference, and add it to the first difference to form a new first difference, 4+2=6. The process can be generalized. In our example, the second difference is constant because the function T is quadratic.
If the function T was a cubic, such as T = x3, then the second difference would vary, but the third difference, the difference between successive second differences, would be constant. In general, a polynomial of degree n will have a constant nth difference and each successive new value of the function can be obtained by n simple additions.
The usefulness of difference techniques is greatly increased by the fact that any section of a well-behaved continuous function can be approximated by a polynomial. The shorter the section and the higher the degree of the polynomial the closer the approximation. So if we wished to tabulate a function, such as a sine or the time of sunset, it is only necessary to divide the function into short enough intervals and find a suitable approximating polynomial for each interval.
The method of differences can then be used to tabulate the function throughout the interval. This process is known as sub-tabulation. Babbage realized that a machine could carry out this sub-tabulation process. First, he needed a mechanism for storing, separately, the numbers corresponding to the values of the tabular value, the first difference, the second difference, etc., and a mechanism to add each difference to the value of the preceding difference.
In the process of designing and building his Difference Engine, Babbage required many accurate drawings of the parts. While using these drawings, he felt that they did not fully and adequately describe the mechanism. For a machine with many parts moving in various ways, the static drawings could only show the shape and arrangement of the parts. So Charles devised a system of mechanical notation that would also indicate how the parts moved — their speeds and interconnections. Unlike the usual drawings, the notation did not picture the shapes of the parts.
Rather, it was a table of numbers, lines, and symbols to describe the machine’s actions. It was a general system that could be used to describe any machine. Charles published a description of his mechanical notation in the Philosophical Transactions of the Royal Society in 1826 and later in 1851 (see Laws of mechanical notation). However, this mechanical notation did not ever come into widespread use.
In an interview held in 1823 between Babbage and the Chancellor of the Exchequer, a rather vague verbal agreement was made whereby the Government would grant funds for the enterprise which was expected to take three years. His own Astronomical Society was so impressed by the machine, that it awarded him its first gold medal in 1824. In the same year, the British government advanced Babbage a fee of £1500, and he began to construct the full Difference Engine.
Babbage needed a small factory and competent workers, although initially two rooms in Babbage’s house were converted into workshops and a third into a forge. He hired a good engineer — Joseph Clement, to maintain the mechanical works in his shop. By 1828, Charles had spent more than £6000 on the construction, and the government had only reimbursed him for £1500. After a supportive report from Charles’s friends in the Royal Society, the government agreed to make up the difference. But the work went rather slowly.
The whole project was taking much longer than anyone had anticipated. While the fabrication of basic parts proceeded, shop patterns had to be drawn for others. The full set of plans was not completed until 1830. By then, Clement’s workers had produced many thousands of parts but had done little assembly.
Soon, Babbage and the government decided that the plans and assembly should be moved out of Clement’s shop.
On Babbage’s property was built a two-store fireproof workshop and a second building for the Difference Engine. Babbage’s intention was to move Clement’s whole operation to these new quarters. However, Clement resisted, because, with the funds Babbage had supplied him, he had greatly expanded his own workshop. He now had many machine tools and a number of employees and used them to do other work besides that contracted by Babbage. And by the trade practices of the time, he insisted that the machinery belonged to him, not to either Babbage or the government.
During 1832, Clement’s workers completed the assembly of as much of the engine as they had parts for (some 10000 parts were made). Even though the calculating section was largely complete, the printing section was not. From this time on, no further work was done. Clement would not move his machinery to Babbage’s shop, and only in 1834 was the engine itself transferred. By then, the government had expended £17000, and Babbage had spent some six thousand pounds own money. The government was unwilling to proceed further, given the need to reorganize the whole project after Clement and Babbage had parted company.
Almost all of the parts of the entire calculating mechanism had been made, but not assembled, when work on the project stopped early in 1833. A portion of the calculating mechanism was assembled in 1832 (see the lower photo) to demonstrate to a committee of the Royal Society and the Parliament that the project was proceeding satisfactorily, but it was limited to two orders of differences and five figures, suitable for demonstration purposes only.
It is about one-third of the height and one-half of the width, or about one-seventh of the entire calculating mechanism, and consists of about 2000 bronze and steel parts. The calculating part alone would have been 7 times larger than the little unit that was assembled. The entire machine was expected to contain some 25000 parts and to weigh over 2 tons, with dimensions roughly 260 cm high, 230 cm broad, and 100 cm deep.
The Design of the Difference Engine
The Difference Engine consisted of two major parts — the calculating mechanism and the printing and control mechanism. In the lower drawing from 1830 the elevation (upper part of the figure) and plan drawings (lower part) of Difference Engine, are clearly seen. The calculating mechanism is on the left, the axes of figure wheels for the tabular value (far right), and six differences are clearly visible. The printing mechanism is on the right, and the moving table carrying the stereotype printing plate and the sector carrying the digit-type punches are visible in the center of both drawings.
Digits are represented in the Difference Engine by the rotational position of horizontal gear wheels. A number is made up of a series of these figure wheels rotating about a common vertical axis. The bottommost wheel represents units, the next tens, the next hundreds, and so on. The figure wheels are about 15 centimeters in diameter and are spaced vertically about 7.5 centimeters apart on the axes. Babbage used the term axis to mean a stack of figure wheels that together store a number as a collection of decimal digits. The entire Difference Engine consists of an axis for the tabular value of the function, another axis for the difference, a third axis for the second difference, and so on for as many orders of differences as are desired.
Each axis served not just as a number store, but also as an adding mechanism. Addition occurred in two steps that will be explained with reference to adding the first difference to the tabular value. Inside each first difference figure wheel, there is a mechanism that is rotated through just as many steps as the value stored by the figure wheel. If the units figure wheel stands at 3, the mechanism will move through three steps. This motion is conveyed by gearing to the corresponding figure wheel of the tabular value axis. If the latter stood at 5 initially, it will be moved three steps to stand at 8. This process occurs simultaneously in the tens, hundreds, thousands, and other digit positions.
It may happen that addition to a figure wheel will generate a carry that must be propagated into the next higher digit position. If the units digit of the tabular value were initially 6 and 7 is added, it will move forward seven places and come to stand at three, but a carry must also be propagated into the tens figure wheel of the tabular value. Carry propagation is complicated by the fact that if the tens figure wheel already stands at 9 it will be moved forward by the carry to stand at 0 and a new carry will be propagated into the hundreds figure wheel. In the Difference Engine, these consecutive carries may propagate, as on occasion they must, from the units up through the most significant figure wheel. Each addition, therefore, consists of two distinct steps — the simultaneous addition of all figures of the first difference to the corresponding figures of the tabular value, and the consecutive propagation of carries from the units up to the most significant digits as required.
Tabulation of a function involves the repetition of this basic addition process for each of the orders of difference involved. As each axis is also an adding mechanism the tabulation of a cubic function from third differences, for example, requires six steps for each tabular value produced (see the nearby figure):
1. Addition of third difference digits to second difference digits
2. Carry propagation among second difference digits
3. The second difference is added to the first difference
4. Carry propagation among first difference digits
5. The first difference is added to the result column
6. Carrying took place in the result column
Negative numbers may be handled with no additional mechanism by representing them as their ten’s complements.
This scheme is readily extended to higher-order differences. It is obvious that the number of steps doubles the number of the power of function, which means that higher power functions will require a lot of steps. Babbage found a way to rearrange the calculation so that only four steps were required for each tabular value produced irrespective of the number of differences involved. This is characteristic of the sophisticated logical considerations underlying Babbage’s designs.
Babbage observed that when the first difference is added to the tabular value, in steps five and six, both the third difference and second difference axes are idle. He could thus add the third difference to the second difference, steps one and two, at the same time as the first difference is added to the tabular value. Steps one and two overlap steps five and six. Thus only four units of time, for steps three to six, are needed for each tabular value produced. In modern terminology, we would call the arrangement of hardware to perform a calculation in this way a pipeline.
The overlapping idea can be extended to higher differences and a new tabular value can always be produced in four steps, namely:
1. Odd differences are added to even ones and to the result.
2. Carrying takes place in the even differences and in the result.
3. Even differences are added to the odd.
4. Carrying takes place in the odd differences.
Not only does this rearranged form of the calculation save considerable time but it also makes the arrangements for driving the calculating mechanism much simpler.
It appears as if Charles Babbage did not initially determine the mathematical capacity of the engine. He only describes it as being intended as a larger engine. In 1823 the engine was being made to calculate with four orders of differences. The number of digits was not mentioned. In 1829 the machine was said to be able to operate with sixth-order differences, 12 digits, and to print 16 digits in the result with a speed of forty-four digits a minute. At some point, Babbage settled for six orders of differences, but the number of digits continued to vary, depending on the author. 18 digits are mentioned in 1834 and as an old man, Babbage himself said that the whole engine would have been capable of calculating with 20 places of digits.
The matrices for the stereotyping of the tables would have been produced in the printing unit. The result was to be taken from the result column in the calculating unit and transferred to the printing unit. There, eleven steel punches were supposed to print the result and argument on a copper plate, producing a printout similar to this, shown in the nearby figure.
It is a great pity that the work on the Difference Engine ceased so close to completion. Henry Babbage later estimated that only a further five hundred pounds would have sufficed. Babbage could readily have found the funds, however, his feelings and attitudes toward both the government and Clement could not allow him to do so. Besides that, within a year or two, Babbage’s mind had moved a long way toward the much more complex and intellectually rewarding Analytical Engine. There was then no way he would have returned to the original Difference Engine design and brought it to completion, even had events made that feasible.
In the late 1860s, Babbage said: “I have not finished it [Difference Engine] because in working at it I came on the idea of my Analytical Engine, which would do all that it was capable of doing and much more. Indeed the idea was so much simpler that it would have taken more work to complete the calculating machine than to design and construct the other in its entirety, so I turned my attention to the Analytical Machine.”
Nevertheless, it is out of the question, that the Difference Engine stood as a great monument to man’s ingenuity and ability to mechanize all kinds of labor. The idea was too important and exciting to be forgotten. Babbage’s exertions brought in their wake considerable publicity, which was an important factor in keeping the idea alive. Another factor was naturally the problem itself. A handful of inventors, all with different backgrounds, were to try during the 19th century to build difference engines according to their own ideas. First of them were the Swedes Pehr Georg Scheutz and his son Edvard, who managed only with small part of Babbage’s resources to produce a working Difference Engine in the middle of the 19th century.
For some years, Babbage displayed the working section of his Difference Engine in one of his drawing rooms and used the portion of the calculating mechanism to calculate nearly a hundred functions. He even designed some improvements to the original mechanism. In the Difference Engine, whenever a new constant was needed in a set of calculations, it had to be entered by hand. In 1834, Babbage conceived a way to have the differences inserted mechanically, arranging the axes of the Difference Engine circularly, so that the Result column should be near that of the last Difference, and thus easily within reach of it. He called this arrangement the engine eating its own tail. But this soon led to the idea of controlling the machine by entirely independent means and making it perform not only Addition but all the processes of arithmetic at will in any order and as many times as might be required. Work on the first Difference Engine was stopped on 10 April 1833, and the first drawing of the Analytical Engine is dated in September 1834.
After finishing the work on the design of the Analytical Engine in 1847, Babbage turned to the design of a Difference Engine No 2, exploiting the improved and simplified arithmetic mechanisms developed for the Analytical Engine. The logical design was the same as for the earlier Difference Engine, but he employed simpler mechanisms for storing and adding numbers and carry propagation. The printing mechanism was simplified so that a whole number was impressed on a printing plate as a single action rather than in a digit-by-digit manner. A conventional print copy, using inked rollers, was made simultaneously. The control was arranged by a single barrel in a very straightforward manner. The design and a complete set of drawings were prepared by mid-1848. These Babbage offered to the British government, apparently to satisfy a commitment he felt existed as a consequence of the failure of the project to build the first Difference Engine, but the government showed no interest in the new design.
Babbage’s calculating machines and related materials were inherited by his youngest son, Major-General Henry Prevost Babbage (1824–1918), who had shown a strong interest in his father’s work. While as a teenager Henry and his older brother Dugald spent time in Babbage’s drawing office and workshop learning workshop skills. Henry later acquired a solid grasp of the Difference (and Analytical) Engine designs and came to form a close bond with his father whom he visited on furlough from extended military service in India. Babbage bequeathed his drawings, workshop, and the surviving physical relics of the engines to Henry who tried to continue his father’s work and to publicize the engines after Babbage’s death.
Henry was at his father’s bedside when Babbage died on 18 October 1871, and from 1872 he continued diligently with his father’s work and then intermittently in retirement in 1875. He assembled some six small demonstration pieces for Difference Engine Number 1 and one of them he sent to Harvard. In the 1930s the piece attracted the attention of Howard Aiken, the creator of the Harvard Mark I, a program-controlled calculator.
The image featured at the top of this post is ©public domain, Wikimedia Commons.