Charles Babbage, 1791-1871. Portrait from the Illustrated London News, Nov. 4, 1871
The Analytical Engine of Charles Babbage
It seems a real miracle, that the first digital computer in the world, which embodied in its mechanical and logical details just about every major principle of the modern digital computer, was designed as early as in 1830s. This was done by the great Charles Babbage, and the name of the machine is Analytical Engine.
In 1834 Babbage designed some improvements to his first computer—the specialized Difference Engine. In the original design, whenever a new constant was needed in a set of calculations, it had to be entered by hand. 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 referred this arrangement as the engine eating its own tail or as a locomotive that lays down its own railway. 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 10th April, 1833, and the first drawing of the Analytical Engine is dated in September, 1834. There exist over two hundred drawings, in full detail, to scale, of the engine and its parts. These were beautifully executed by a highly skilled draughtsman and were very costly. There are also over four hundred notations of different parts, using Babbage's system of mechanical notation (see Laws of mechanical notation).
The object of the machine may shortly be given thus (according to the Henry Babbage, the youngest son of the inventor): It is a machine to calculate the numerical value or values of any formula or function of which the mathematician can indicate the method of solution. It is to perform the ordinary rules of arithmetic in any order as previously settled by the mathematician, and any number of times and on any quantities. It is to be absolutely automatic, the slave of the mathematician, carrying out his orders and relieving him from the drudgery of computing. It must print the results, or any intermediate result arrived at.
Babbage intended to design a machine with a repertoire of the four basic arithmetic functions, in contrast with the Difference Engine, which is using only addition. On the analogy of a modern digital computer, the design principle of the Analytical Engine can be divided to:
1. Input. From 1836 on, punched cards (see the nearby photo) were the basic mechanism for feeding into the machine both numerical data and the instructions on how to manipulate them.
2. Output. Babbage’s basic mechanism was always a printing apparatus, but he had also considered graphic output devices even before he adopted punched cards for output as well as input.
3. Memory. For Babbage this was basically the number axes in the store, though he also developed the idea of a hierarchical memory system using punched cards for additional intermediate results that could not fit in the store.
4. Central Processing Unit. Babbage called this the Mill. Like modern processors it provided for storing the numbers being operated upon most immediately (registers); hardware mechanisms for subjecting those numbers to the basic arithmetic operations; control mechanisms for translating the user-oriented instructions supplied from outside into detailed control of internal hardware; and synchronization mechanisms (a clock) to carry out detailed steps in a carefully timed sequence. The control mechanism of the Analytical Engine must execute operations automatically and it consists of two parts: the lower level control mechanism, controlled by massive drums called barrels, and the higher level control mechanism, controlled by punched cards, developed by Jacquard for pattern-weaving looms and used extensively in the beginning of 1800s.
The sequence of smaller operations required to effect an arithmetical operation was controlled by massive drums called barrels (see the nearby figure). The barrels had studs fixed to their outer surface in much the same way as the pins of a music box drum or a barrel organ. The barrels orchestrated the internal motions of the engine and specify in detail how multiplication, division, addition, subtraction, and other arithmetic operations, are to be carried out. The barrel shown in the illustration has only several stud positions in each vertical row. In the actual machine, the barrels were much larger because they controlled and coordinated the interaction of thousands of parts. Each row could contain as many as 200 stud positions, and each barrel could have 50 to 100 separate rows. The overall machine had several different barrels controlling different sections. Naturally, the barrels had to be closely coordinated with one another. As a barrel turned, the studs activated specific motions of the mechanism and the position and arrangement of the studs determined the action and relative timing of each motion. The act of turning the drum thus automatically executed a sequence of motions to carry out the desired higher level operation. The process is internal to the Engine and logically invisible to the user. The technique is what in computing is now called a microprogram (though Babbage never used this term), which ensures that the lower level operations required to perform a function are executed automatically.
For higher level control mechanism, Babbage initially intended to use a big central barrel, to specify the steps of a calculation. This idea however seems impractical, because this will require changing the studs on the super barrel, which could be a cumbersome operation. The task of manually resetting studs in the central drum to tell the machine what to do was too cumbersome and error-prone to be reliable. Worse, the length of any set of instructions would be limited by the size of the drum.
His struggle with the problem of control led Babbage to a real breakthrough on June 30, 1836. He conceived of providing instructions and data to the engine not by turning number wheels and setting studs, but by means of punched card input, by means of cards, similar to these, used in the Jacquard looms. This did not render the central drum obsolete nor replace it. Punched cards provided a new top level of the control hierarchy that governed the positioning of the central drum. The central drum remained, but now with permanent sequences of instructions. It took on the function of micro-programming, as this of other barrels. If there were separate barrels for each operation, and a central barrel for controlling the operations drums, the punched card presents a way of instructing the machine (the central drum) as to which operations we wished to perform and in what order, i.e. high-level programming the Engine.
The principle of cards was openly borrowed from the Jacquard loom (a mechanical loom, invented by the Frenchman Joseph Marie Jacquard in the beginning of 1800s, based on earlier inventions of his compatriots Basile Bouchon (1725), Jean Falcon (1728) and Jacques Vaucanson (1740)), which used a string of punched cards to automatically control the pattern of a weave (see the nearby photo).
In the loom, rods were linked to wire hooks, each of which could lift one of the longitudinal threads strung between the frame. The rods were gathered in a rectangular bundle, and the cards were pressed one at a time against the rod ends. If a hole coincided with a rod, then the rod passed through the card and no action was taken. If no hole was present then the card pressed back the rod to activate a hook which lifted the associated thread, allowing the shuttle which carried the crossthread to pass underneath. The cards were strung together with wire, ribbon or tape hinges, and fan, folded into large stacks to form long sequences. The looms were often massive and the loom operator sat inside the frame, sequencing through the cards one at a time by means of a foot pedal or hand lever. The arrangement of holes on the cards determined the pattern of the weave.
How can be programmed the Analytical Engine?
We know little of Babbage's programming ideas. There is nothing in the surviving papers in which this aspect of the machine is thoroughly discussed, e.g., nothing corresponding to a specification of a user instruction set. This is the more remarkable for it is the only aspect of the design that is discussed at length in a contemporary paper. In 1840, Babbage visited Turin in Italy and gave a series of seminars on the Analytical Engine. An account of these, by the italian engineer Federico Luigi Menabrea (1809-1896) (which later will become the Prime-Minister of Italy), was translated into English by Ada Lovelace (she has sometimes been acclaimed as the world's fist programmer, a romantically appealing image without any foundation), who appended extensive notes prepared under Babbage's close guidance. These deal with the familiar modern ideas of flow of control in programs, particularly the formulation of simple loops and nested loops controlled by counters. However, the paper and notes carefully and deliberately skirt around any discussion of details of the means by which these are to be implemented.
It seems that Babbage did not have a command of the issues raised by the user-level programming of the Analytical Engine. It would be quite wrong to infer that Babbage did not understand programming per se. The microprogramming of the barrels for multiplication and division show command of the basic branching and looping ideas and his skills in the microprogramming of addition and subtraction show complete virtuosity. It was from this base that Babbage explored the ideas of user-level programming. The issues of data structuring simply did not arise at the microprogramming level. There is some evidence to suggest that Babbage's ideas were moving in the directions now familiar in connection with the control mechanisms for loop counting in user-level programs. Had an Analytical Engine been brought to working order, there can be no doubt that Babbage's programming ideas would have been developed greatly.
From the hardware point of view, two strings of punched cards were needed to specify a calculation to be performed by the Analytical Engine. One string, the "operation cards," specified the arithmetic operations to be performed. The second string, the "variable cards," specified the axes in the store that contained the operands and were to receive the results. These two strings cannot be regarded as separate parts of a single instruction, as are the operation and operand fields of an instruction in an electronic digital computer, because the operation and variable cards were intended to move and loop independently of one another under the direction of separate control mechanisms.
Actually there were four, but no two, different kinds of punched cards with different functions:
1. Number cards were used to specify the value of numbers to be entered into the store, or to receive numbers back from the store for external storage.
2. Variable cards specified which axes in the store should be the source of data fed into the mill or the recipient of data returned from it. In modern parlance, they supplied the memory address of the variables to be used.
3. Operation cards determined the mathematical functions to be performed. The logical content of an operation card might have been like this example: “Take the numbers from the variable axes specified by the next two variable cards, and multiply them in the mill; store the result on the variable axis specified by the third variable card.” This was interpreted by the sensing rods on the operation-card reading apparatus and internally translated like this: “Advance the variable cards by one position, and rotate all the barrels to the starting position for a normal multiply-and-store sequence.”
4. Combinatorial cards controlled how variable cards and operation cards turned backward or forward after specific operations were complete. Thus, an operation card might have a logical content like this: “Move the variable cards ahead 25 positions, and set the operation cards to the start of the set that tells how to extract a square root.”
Babbage planned to intersperse the combinatorial cards with the operation cards they controlled, so the four sets of cards required only three card readers (plus one card punch, for number cards being output from the machine).
Babbage seems to have been led to separate the operation and variable cards on largely philosophical grounds stemming from his belief in the need to distinguish symbols for operation from those for quantity in mathematical notations. These views were probably reinforced when he considered the cards necessary for calculations such as the solution of simultaneous equations. Babbage realized also, that programs or subroutines (certainly not terms that he used) would need to be verified, what we would call debugged. He also knew that it would be valuable to rerun verified programs on new sets of data, and even to share programs across multiple engines. Thus, it was a natural and practical approach to specify the data as being independent of the operations. There the pattern of operations required for carrying out row reductions is very simple and a straightforward loop of operation cards is readily found. No such simple loop structure exists for the variable cards, which can only specify single axes in the store. The loop structures that we now recognize concern rows of the matrix of coefficients of the equations and similar concepts related to the structuring of the data. As Babbage did not have the concept of a variable address in the store, neither was the Analytical Engine able to calculate the location of an operand in the store, there was no way in which the user programs could exploit this higher level structure in the data.
It's amazing how far went Babbage in his programming conceptualization, keeping in mind, that he had no experience in programming an actual computer. From the current point of view, the series of operation cards provided not a program, in current terms, but a series of subroutines. The combinatorial cards provided terminology, a control-flow program, invoking subroutines with call-by-reference values provided by the variable cards. Babbage’s programming concepts clearly included what we call loops, subroutines, and branches (what later generations of programmers called “if ” or “if-then” instructions). Since he had no experience in programming an actual computer however, it is not surprising that Babbage did not get to the modern concepts of higher level languages, interpreters, or compilers.
A table with cards and actions for the formula (ab+c)d
Let's take as an illustration the formula (ab+c)d (see the upper table). The full detail of the cards of all sorts required, and the order in which they would come into play is this:
The four Number Cards for the" given numbers" a, b, c and d, strung together are placed by hand on the roller, these numbers have to be placed on the columns assigned to them in a part of the machine called "The Store," where every quantity is first received and kept ready for use as wanted.
We have thus besides the Number Cards, three Operation Cards used, and fourteen Directive Cards. Each set of cards would be strung together and placed on a roller or prism of its own; this roller would be suspended and be moved to and from. Each backward motion would cause the prism to move one face, bringing the next card into play, just as on the loom. It is obvious that the rollers must be made to work in harmony, and for this purpose the levers which make the rollers turn would themselves be controlled by suitable means, or by general Directive Cards, and the beats of the suspended rollers be stopped in the proper intervals.
A general plan of the Analytical Engine from 1840 (click to see a larger image)
In the upper general view of Analytical Engine can be seen the basic sections: in the right part is a section of the store including 11 variable axes. In practice, the store would have been much longer, with many more variable axes; Babbage sometimes considered a minimum of 100, and as many as 1000. Each variable axis contained many figure wheels rotating around a central axle, each holding one digit of its variable. Babbage usually planned to have 40 digits per variable. One extra wheel on top recorded whether the value was positive or negative.
Running horizontally between the variable axes were the racks, long strips of metal with gear-toothed edges that carried digits back and forth between the store and the mill. Small movable pinions were positioned either to connect a given variable axis to the racks or to leave it unconnected. If a number was going into the mill, the racks would also be connected to the ingress axis in the mill (labeled I). From there, it would be passed to another appropriate part of the mill. When the mill was finished operating on a number, it would be placed on the egress axis (labeled E). This could then be connected to the racks, which would pass the number along to whatever variable axis had been chosen to hold the result.
The mill is the left section, arranged around the large central wheel that interconnect its parts. For clarity, not all aspects of the engine are shown in this diagram. But this may obscure the machine’s complexity and size. The central wheels alone were about 70 cm across. The mill as a whole was about 150 cm feet in each direction. A store with 100 variable axes would have been about 3 m long. The ingress axis had its own anticipating carriage mechanism; an addition or subtraction could be performed there and then passed directly to the egress axis for storage. If a multiplication was coming up, the first nine multiples would be added on the ingress axis and stored on the table axes, shown as T1 through T9.
The results of a full multiplication or division would be formed on the two columns labeled A to the left of the large central wheel. This made it possible to hold intermediate results in double precision form. That is, if two 40-digit numbers were multiplied together, 80 digits of result could be kept on axes A. A subsequent division by another 40-digit number still allowed 40 digits of precision in the result.
One of the main mechanical problems in the Analytical Engine was the problem with carry. At first, Babbage used the method of delayed sequential carry used in the Difference Engine. In this, the basic addition cycle was followed by a separate carry cycle. The carry cycle first performed any carry needed on the lowest digit, then proceeded to the next higher digit, and so on. This method worked, but it was slow because carries were performed separately for each digit. Babbage considered having 30 or 40 digits in each number column, so the carries might take a lot longer than the addition itself. Thus, a single multiplication might take some hundreds of separate addition steps. It was clear that the carry time had to be shortened.
Babbage tried various approaches to optimize the carries, and within a few months had adopted what he called the anticipating carriage. Additional hardware allowed the carriage mechanism to detect simultaneously where carries were needed and where one or more wheels already at 9 might cause a carry to propagate over a series of digits. All carries could be performed at once, regardless of the number of digits on an axis. Working out the details of anticipating carriage took Babbage many years, longer than any other single aspect of the machine. But it could speed operations greatly, justifying the effort. The mechanism was too complex to allow a carriage mechanism for each adding axis. Babbage was forced to adopt a design where a single anticipating carriage mechanism could be connected at will with any adding column through the central wheels. Until then, multiplication had been provided by specialized hardware, and the carriage function had been removed from the adding axes to more specialized central hardware.
Babbage soon realized that addition itself could be removed from the adding axes, and performed through the central wheels. The adding axes simply stored digits on their individual wheels, and they could be connected or disconnected from the central wheels as needed. Babbage separated the machine into a section of storage axes, which he called the store, and another section where operations were performed, which he called the mill.
During the years Babbage made different designs for many of the units of the Engine, most often in the direction of simplification. Not all of them however were in this direction, because Babbage was very anxious to speed up calculation. An example of adding hardware to achieve speed was multiplication by table. In the initial method of multiplication by repeated addition, the number of cycles of addition would be equal to the sum of the digits of the multiplier. Thus, to multiply 198814 by 978, for example, 198814 would be added 24 times (9 + 7 + 8), along with 3 shifts.
Babbage planned to work with numbers having as many as 40 digits. Multiplying two 40-digit numbers together might well take 200 addition cycles. Babbage realized that by devoting a few cycles at the start of a long multiplication to some preparation, he could greatly speed the multiplication itself. He called this multiplication by table. In 9 cycles, he could calculate and place on special table axes in the mill the first 9 integral multiples of the multiplicand. Then he could simply pick one of these for each digit of the multiplier and add it to the accumulating product. Multiplying two 40-digit numbers would then take only 40 addition cycles, plus 9 to form the table, a total of 49 addition cycles rather than some 200. A similar method of division by table could also speed division.
It is considered, that the basic design the Analytical Engine was finished by December 1837, when Babbage finally wrote an extended paper, “Of the Mathematical Powers of the Calculating Engine,” which described the machine. He continued design work for many more years, but this involved refinement of detail and alternatives of implementation, not changes of principle. By 1837, Babbage had devised a machine whose basic organization would remain unchanged through all his subsequent work, and indeed through the entire subsequent development of computer design.
Babbage considered that the Analytical Engine was a universal calculating machine in the sense that, given sufficient time, it could carry out any possible arithmetic calculation. This argument is based on three observations. First, arithmetic operations on numbers of more than forty digits can always be carried through by breaking them into 40-digit segments, so the limited number of digits on any store axis is no fundamental limit. Second, calculations can be specified by strings of operation and variable cards of unlimited extent, so there is no limitation to the size or complexity of programs. Third, numbers from the store can be punched onto number cards and later read back, and this provides a backing store of unlimited extent to overcome the limited number of axes in the store.
Babbage was fully aware of speed limitations of his machine. He knew that the machine would in theory make possible far more extended and precise calculations than had ever been attempted by hand, but they would be possible in practice only with a machine that was highly reliable and quite fast. From his earlier work, he knew that reliability required the gears not to turn too quickly. Overall speed had to be achieved with smart design rather than raw power. This is what motivated the immense ingenuity that Babbage invested in time-saving methods like anticipating carriage and multiplication by table.
In the machine design of the late 1830s, the isolated addition of two 40-digit numbers would have taken about 19 seconds. But a lot of this involved moving numbers around between different sections before or after the actual addition. Babbage figured out how to overlap the different parts of the operation when more than two additions were to be performed in succession. This meant that each extra 40-digit addition took only 3.1 seconds. Multiplication and division were similarly accelerated by clever logical design. The duration depended on the number of digits in the numbers. Take the case of a multiplication of 20 digits by 40 digits (a very high degree of precision even by current standards). With sustained additions at 3.1 seconds each, a straightforward step and add approach would have taken nearly 8 minutes to complete. Babbage was able to reduce this to less than 2 minutes. Today, with microprocessor speed measured in millions of multiplications per second, 2 minutes seems incredibly slow. But it was a remarkable accomplishment more than a century before electronic computation.
After finishing of the work on the design of the Analytical Engine in 1847, Babbage turned to the design of a Difference Engine №2, exploiting the improved and simplified arithmetic mechanisms developed for the Analytical Engine. In 1857 Babbage returned to the design of the Analytical Engine. In this new phase of work Babbage was actively interested in building an Analytical Engine with his own resources. The logical design was somewhat simplified but, most importantly, far simpler and cheaper methods were proposed to implement the basic mechanisms. Babbage first experimented with sheet metal stamping and pressing for making gear wheels and similar parts. Later, he adopted pressure die casting for making parts-a newly invented technique that did not see extensive commercial use until the end of the nineteenth century. Babbage built many experimental models of mechanisms using these new techniques, and, at the time of his death in 187 1, a model of a simple mill and printing mechanism was near completion (see the lower photo).
A model of the mill of Analytical Engine, constructed about 1870 (© Science Museum, London)
Babbage's calculating machines, as well as all related materials were inherited by his youngest survived son, Major-General Henry Prevost Babbage (1824-1918) (see the nearby image), who had shown a strong interest in his father's work. Even as teenagers Henry and his older brother Dugald spent time in Babbage's drawing office and workshop learning workshop skills. Henry later acquired a srong 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 in October, 1871, and from 1872 he continued diligently with his father's work and then intermittently in retirement in 1875. After assembling some small demonstration pieces for Difference Engine Number 1 (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). Then Henry built an experimental four-function calculator for the Mill for the Analytical Engine, completing it in 1910. Henry actually decided not to continue with the original design of an Analytic Engine, but instead to develop a manually operated machine for addition, subtraction, multiplication, and division (a four-function calculator), incorporating the mechanisms planned for the mill and printing mechanism of the Engine (see the lower photo).
A part of the mill and printing mechanism of the Analytical Engine, constructed by Henry Babbage
Although eventually completed in the beginning of the twentieth century, when Henry was himself an old man, this machine appears never to have worked reliably. Moreover, Henry's work on the engines was sound, but without the boldness and inspiration of his father, the great Charles Babbage.