Mathematical principle

< Previous Up ^ Next >

It is a fact that all actual calculations contain errors. There are limits to how much precision you can have in any measurement. If a captain takes the elevation of a star with a sextant, he can't get infinite decimal places, likewise, in most real world calculations you start from values that contain errors. If you have a certain balance in your bank account and get interests credited, the tenths of cents get rounded to full cents. Thus, as long as a table is correct within the number of decimal places shown, an approximation is fine.

Most formulas can be approximated via a polynomial series such as:

an xn + an-1 xn-1 + ... + a1 x + a0

The more terms you have (the higher 'n' is) the less the error you get. Even functions that don't seem naturally given to a polynomial approximation can be produced, within a limited range,  with a good selection of coefficients.

The red line on the image at left represents the sine of an angle for a full turn. The other curves represent successive approximations. For each curve the degree of the polynomial ('n= ..') is shown in the same color as its curve. The curve for n=9 can't be seen because the actual sine (the red curve) overlays it completely. Thus, for the purpose of this graph a polynomial of n=9 is indistinguishable from the actual function.

The coefficients 'a' are zero for all even values of 'n' while the rest are 1 / n! alternating positive and negative. (positive for n=1, negative for n=3, positive for n=5 and so on)

Lets see the values for a certain polynomial,such as 3x + 1

X f(x) diff
1 4  
2 7 3
3 10 3
4 13 3

The first column represents the values of X; the second, the result of calculating that function. The last column is the difference in between the values of the current row and the previous. For any polynomial of degree n=1, the first difference is always a constant. Since this polynomial represents a straight line, it is logical that it increments regularly, thus the differences in between successive values are all alike.

For a polynomial of n=2, such as 2 x2 + 3 x + 1, we would have:

X f(x) diff1 diff2
1 6    
2 15 9  
3 28 13 4
4 45 17 4
5 66 21 4

In this case, the first column of differences (diff1) still changes, but if we calculate the difference in between successive differences we get the values of column diff2 which are all the same.

In fact, for any polynomial of degree 'n', the 'nth' difference will always be a constant.

The Difference Engine works by the reverse of this, namely, once you have the first row, you can work the rest out by additions. In this last example, you only need to have the numbers 6, 9 and 4 to get the rest.

The numbers in the following table have been produced by such a process

X f(x) diff1 diff2
1 6 9 4
2 15 13 4
3 28 17 4
4 45 21 4
5 66 25 4
6 91 29 4
7 120 33 4
8 153 37 4

Given the first row, 6, 9, 4, you calculate each successive cell in each row by adding the values on the cell immediately above and the one to the right of that. So, in the second row, we have 6 + 9 ==> 15, 9 + 4 ==> 13 and, finally, since the last column is always a constant we just repeat it (another way to look at it is by saying that the third difference is always zero, thus 4 + 0 ==> 4)

Then, for the third row, we have 15 + 13 ==> 28, 13 + 4 ==> 17. The rest of the rows have been produced by just such method, and you could verify it by calculating the actual polynomial.

The procedure is so simple that it should be possible to do it 'by steam', as Babbage wanted.

Of course, the first problem to solve is calculating the first row, and that is why the Difference Engine can't calculate a particular value, the whole process depends on calculating successive values starting from a known one, plus the first row of differences. For a simple polynomial such as this, the task is easy, but for a complex polynomial it is much harder. Moreover, you first have to find the polynomial that best approximates the actual function you want to calculate, such as the sine curve above. All these are well-known algebraic procedures, though not easy.

This effort pays off once you start producing pages and pages with columns full of values, which is the most tedious, time consuming and error prone part of all.

< Previous Up ^ Next >