| Return to main text |

Babbage's Difference Engine

Just what was the difference engine supposed to do?

Suppose, for the sake of argument that we want to work out the value of the polynomial function x+2x2+3x3 for lots of values of x (x=1, x=2, x=3, and so on).

The calculation of the value of x+2x2+3x3 would involve both multiplication and addition. So when x is equal to 3 we would have to calculate 3 + (2 × 3 × 3) + (3 × 3 × 3 × 3). Furthermore, the multiplications would soon involve large numbers. The method of differences allows this calculation to be completed using only addition and subtraction.

Table 1, below, shows the function x+2x2+3x3 for values of x from 1 to 5.

Table 1: 1st three differences of a function.
 x  Value of
x+2x2+3x3
1st difference 2nd difference 3rd difference
1 6      
2 34 28    
3 102 68 40  
4 228 126 58 18
5 430 202 76 18

The 1st difference is the difference between successive values of the function i.e. 28 is the difference between 6 (the value when x=1) and 34 (the value when x=2). Similarly, the second difference is the difference between successive 1st differences i.e. 40 is the difference between 28 and 68.

Looking at the result for x=4 and x=5, you will see that the third difference is 18 in both cases. The third difference will remain at 18 for all subsequent values of x (try it if you don't believe me). The actual value of the constant difference depends on the function being calculated. In this case, the value just happens to be 18. Another function would probably give a different value.

Having now found out our constant third difference (18), the next value of the second difference can be calculated by adding 18 to the last value. Similarly, the next first difference and thus the next value of the function can be calculated by using addition alone. (See Table 2, below).

To calculate this value using conventional methods would require 5 multiplications and two additions. Using the method of differences all that is required is three additions. All subsequent values can be calculated in a similar way.

Table 2: Calculate the function using differences.
3rd difference 2nd difference 1st difference Value of
x+2x2+3x3
  x  
18 76 202 430 5
  +18 +94 +296  
  =94 =296 =726 6

Thus, adding 18 to 76 (the last known second difference), gives 94, the next second difference.

Adding 94 to 202 (the last known first difference), gives 296, the next first difference.

Adding 296 to 430 (the last known value of the function when x=5), gives 726, the value of the function when x=6. Subsequent values of the function, when x=7,8,9 ...etc can be calculated in a similar way.

This is what the difference engine was intended to do.

In this case, the operator would set the wheels of the engine to 18, 76, 202 & 430, then turn the handle. The engine would do the additions in sequence and produce the result 726 as the next value of the function when x=6.

The wheels would now hold the values 18, 94, 296, 726, so the next turn of the handle would produce the result 1134 (the value of the function when x=7) and leave the wheels set to 18, 112, 408, 1132, ready for the next turn of the handle.

Wonderful! A clockwork spreadsheet! Everyone should have one.

| Return to main text |  Go to Top  |

27-Jan-2002
Text Copyright © 2002 A. Audsley, All Rights Reserved