Babbage argued that he
. . . considered that a machine to execute the mere isolated operations of arithmetic, would be comparatively of little value
But
"On the otherhand the method of differences supplied a general method by which all Tables might be computed through limited intervals, by one uniform process. Again the method of differences required the use of Addition only. ...
[Extract from Chapter V of Passages from the Life of a Philosopher (1864), by Charles Babbage.]
Ordinary arithmetic calculating machines, in Babbage's day, of the Leibnizian or Pascaline type, could only carry out individual calculations. They were suited merely for the computation of single sums involving addition, subtraction, multiplication or division: their use was limited to the solution of one-off numerical problems. A calculating machine, however, if one could be adapted specially to perform the Method of Differences, one of such a type would solve a very different kind of numerical problem, that of how to mass produce whole mathematical tables, quickly and efficiently, and with perfect accuracy. Such a machine might be arranged not only to calculate them but also to print them as well. Indeed these were Babbage's great insights. Perceiving the simplicity and facility of the Method of Differences and the arithmetic operation required to execute it, recognising that it was a very powerful and general technique, he realised that its principles could be very easily embodied in simple mechanical components. These insights led him, in 1821, directly to design and develop a Difference Engine, a machine in which all that was necessary to calculate all numerical tables was one based on the algorithms of the Method of Differences, one which only needed mechanisms for ADDITION repeated many times over. This was his conception of the purpose and nature of his invention. A clearer understanding therefore, of the Mathematics of the Method of Differences is essential if one is to comprehend fully Babbage's vision and gain a better picture of the mechanics of his creation, its operations, capabilities and limitations, and the manner in which it was expected to achieve its object.
By Babbage's time the Method of Differences had been in use for a long while and with much success for the manual calculation of mathematical and other types of numerical tables.[Compare the efforts made in 1801 of Prony and his team of mathematicians and calculators who constructed manually a very large set of tables known as the French Grand Tables using the Method of Differences.] It was a well-tried and firmly established technique of Numerical Analysis, and its theory was well understood. What made it an ideal principle for the automatic, mechanical computation of such tables was that, in its use, the same sequence of simple arithmetical operations is replicated over and over again. Hence a machine designed to imitate it only needed those mechanisms for repeating these same operations. In fact methods or algorithms for evaluating functions or solving equations by Recursion or Iteration, e.g. by the repetitive substitution of the approximate solution of an equation back into itself to obtain a better approximation, which terms are now applied to any repetitive technique, had been devised as early as the late 17th century, by Newton himself not long after he had discovered the Infinitesimal Calculus. But the Method of Differences itself did not become a clearly identifiable, separate branch of numerical mathematics until some time after Brook Taylor enunciated during the 18th century the famous theorem which bears his name (Taylor's Theorem), to which the Theory and Method of Finite Differences is firmly attached.
What is a "difference"? A "difference", written Df(x), is simply the difference between the values of a function taken at two different values of its variable, x. Df(x) = f(x_{1})-f(x_{2}). A "differential" is much the same thing except that the difference between the two values of x used, x_{1} and x_{2}, is reduced [gradually by a limiting process] by an infinitesimal (infinitely small) amount, df(x). A "differential" is thus an infinitesimal "difference". Conversely, a "difference" can be seen as a kind of finite "differential", one which uses an interval of a finite size instead of an infinitesimal. Because of this similarity, between the two calculi, of Differentials and of Differences, it will be found that they share many theorems in common.
The Method of Differences is thus a method of integrating "differences". Babbage's Difference Engine was a machine specially and specifically designed to perform this task as efficiently as possible.
The Method of Differences is a practical numerical technique. It can be used to calculate exactly the numerical values of any mathematical function that can be expressed as a simple polynomial (that is as the sum of a series of algebraic terms of the multiple powers of a variable quantity, x). The degree of a polynomial is defined as the value of the highest power of the variable x, that appears in the series. For instance:
f(x) = a_{0} + a_{1}x + a_{2}x^{2} + a_{3}x^{3} is a polynomial with variable x and 3 coefficients a_{0}, a_{1}, a_{2} and a_{3}. It is of the third degree.
In practice several applications which involve mathematical relationships, e.g. many equations of physics and astronomy, can be reduced to simple expressions containing only polynomials of a finite degree. Furthermore most common, everyday mathematical functions, for example Logarithms, Sines, Cosines etc., can themselves be expressed in the form of polynomials, which, although they consist of an infinite series, can be approximated, quite satisfactorily, to ones of a finite degree. Some more examples of polynomials:-
f(x)= 41 + x + x^{2} is a polynomial of degree 2.
Sin(x) = x + x^{3} /3! + x^{5} /5! ... is an infinite polynomial
Cos(x) = 1 - x^{2} /2! + x^{4} /4! ... is also an infinite polynomial.
What makes the Method of Differences a practical proposition for the interpolation of the numerical values of functions is a theorem which states that the nth difference of a polynomial of degree n is a constant, and that all its differences of a higher order are zero and can therefore be ignored. As a result, when one is dealing with the evaluation of polynomials, one need only work with a finite set of differences. As the Theory of Differences and the Differential Calculus are very closely interrelated, the significance of this theorem can be demonstrated quite easily by observing what happens to a simple polynomial when one is differentiated:-
e.g.
f(x) = x^{2} + x + 41 is a simple polynomial of degree 2
df(x)/dx = 2x + 1 is its first differential
d^{2}f(x)/dx^{2}
= 2 is its second differential
Note that in this example, the second differential is a constant having the value 2, and that all its other differentials of a higher order have a value of zero. As it is so with differentials, the same is also true of differences. Take the values of the function f(x) = x^{2} + x + 41 for fixed and equal intervals (equal to 1 in this instance) of values for D
The Mathematical Theory of Convergence defines the limits to which this approximation is possible. It should be noted, however, that this theory it was not particularly well understood in Babbage's time, but for the purpose of considering the mechanical features of the Difference Engine that need not concern us here.
Now the feature that makes the Method of Differences special is that a complete reversal of the above procedure is allowed. Instead of starting with a table of values for a function distributed at a fixed interval and by repeated subtraction extracting the values of its various levels of differences, a process similar to Differentiation, one can do the complete opposite. One starts with the assumption that one is tabulating a polynomial function of the nth degree (2nd in this instance); consequently one may also assume that its nth difference is always a constant (2 in this case) and having been given or having ascertained starting values for the function itself and its n levels of differences one may calculate from these, by adding them together in the correct order repeatedly, a full table of values for the function at the fixed and specified interval, a process comparable to Integration. Thus given
f_{1} = 43
D^{1}f_{1} =
4
D^{2}f_{r}
= 2 and constant
for all r
One can calculate that
f_{2} = f_{1} + D^{1}f_{1}
= 43 + 4 = 47
D^{1}f_{2} = D^{1}f_{1}
+ D^{2}f_{1}
= 4+2 = 6
and so on :-
Notation for Differences and Various Important Relations:
A more formal notation was introduced above. A fuller explanation of it is given here:-
D is the Greek letter Delta; it stands for Finite Difference. D^{r}U means the rth Finite Difference of a function U.
U_{Z} represents the function to be tabulated; it is the zth value of this function in its table with a given, fixed interval. It could be written as D^{0}U_{z}
D^{1}U_{z} represents the zth value of the First Difference in the table; by definition it is equal to U_{z+1}-U_{z}
D^{2}U_{z} represents the zth value of the Second Difference in the table; by definition it is equal to D^{1}U_{z+1} - D^{1}U_{z} which is in turn equal to U_{z+2}-2U_{z+1} +U_{z.}
D^{n}U_{z } represents the zth value in the table of the nth Difference. It is equal to D^{n-1}U_{z+1 } - D^{n-1}U_{z}
The important relation for the Method of Differences is this latter one
D^{n}U_{z } = D^{n-1}U_{z+1 } - D^{n-1}U_{z}
This can be re-arranged thus:-
D^{n-1}U_{z+1 }= D^{n-1}U_{z } + D^{n}U_{z}
which is a mathematical statement of the fundamental algorithm or basic unit of replication used by the Method of Differences. In words, it states that the next value in the table for the n-l^{th} difference is equal to the current value of the n-l^{th} difference plus the current value of the n^{th} difference. All calculations performed using the Method may be represented by this one, general expression. In fact the uniformity of the mechanical parts used in DEl derives from the very reason that this expression is uniform with respect to all levels of differences.
Using the same notation, the theorem mentioned before can also be rewritten. The n^{th} difference of a polynomial of degree n, which has already been noted is a constant, can be shown to be equal to
D^{n}P_{n}(x) = n!.a_{n}.h^{n}
where P_{n}(x) is a polynomial of the nth degree with variable x; D^{n}P_{n}(x) is its nth difference; h is the interval of the table, a_{n} is the value of the coefficient of the term containing x^{n} in the polynomial, and n! means n factorial or 1.2.3.. .n. This latter equation is a useful relation, one which should be remembered by those wishing to use the Method of Differences.
SEQUENCING
The order or sequence in which DEl was to perform its additions or integration of its various levels of differences is important as it affects which values for the differences are to be used as starting values, to be set up on each of the Difference Axes prior to the punching and calculation of a table. There are two general methods of sequencing:
Serial Sequencing:
For each Result Cycle [see Operating Cycles of DEl) Calculation on the Difference Engine can take place in the following order:
This method of sequencing requires 12 turns of the First Axis of the Engine for every result produced on the Table or Result Axis, 2 for each of the above additions. This was probably the method used by Babbage on his earlier models (ca 1823-1826) for DEl. Somewhat later, however, he discovered a much more efficient mode of sequencing, which he used in the design for all his subsequent versions of DEl:
Parallel Sequencing or 'Pipelining':
During each Calculation Sub-Cycle integration of differences takes place in two phases, each requiring two turns of the First Axis, i.e. a total of four turns of the first axis are needed for every result produced. During each phase three additions are performed in parallel:
Phase I
Table or Result
Axis D^{0}u_{0}
1st Difference
Axis D^{1}u_{-1}
2nd Difference Axis
D^{2}u_{-1}
3rd Difference Axis
D^{3}u_{-2}
4th Difference Axis
D^{4}u_{-2}
5th Difference Axis
D^{5}u_{-3}
6th Difference Axis
D^{6}u_{-3}
[Constant]
[NB the 6th Difference on DEl is always treated as a constant and thus its value is not affected by the Engine's sequencing]
Examples of the Method of Differences at work
A Table of the Squares of the Natural Numbers, f(x) = x^{2}, may be produced by DEl using the following starting values:
U_{0} = 0, D^{1}u_{0} = 1 and D^{2}u_{0} = 2 (and constant).
From which, the following can be generated in sequence serially:
U_{l} = U_{0} + D^{1}U_{0} = 0 + 1 = 1, D^{1}u_{1} = D^{1}u_{0 }+ D^{2}u_{0} = 1 + 2 = 3.
U_{2} = U_{1 }+ D^{1}u_{1} = 1 + 3 = 4, D^{1}u_{2} = D^{1}u_{1} + D^{2}u_{1} = 3 + 2 = 5.
U_{3} = U_{2} + D^{1}u_{2}
= 4 + 5 = 9, D^{1}u_{3}
= D^{1}u_{2} + D^{2}u_{2}
= 5 + 2 = 7.
etc.
The values for U_{0},U_{1},U_{2} U_{3} ... can be seen to be a sequence of the squares of the natural numbers 0, 1, 2, 3
A Table of the Cubes of the Natural Numbers, f(x) = x3, may similarly be constructed in sequence serially, given these starting values:
U_{0} = 0, D^{1}u_{0} = 1, D^{2}u_{0} = 6 and D^{3}u_{0} = 6 (and constant)
Production of the remainder of the table is left as an exercise for
the reader to perform.
Calculating Limit of Babbage' Difference Engine
Again using the same notation, the limit to the calculating power of Babbage's First Difference Engine can be stated quite simply in terms of the following expression:-
Negative Numbers
DEl only worked with positive numbers; it could only add and store positive values. Nonetheless, the negative values of numbers could be represented and the process of subtraction performed through the use of an arithmetic artifice called Negative Complements
E.g. Suppose the value -137 needs to be used
The use of Negative Complements introduced many unforeseen complications into the workings of DEl. Whilst in their simple application they seem to be equivalent to the use of negative numbers and behave more or less as one would expect, they are not fully representative of them in all their mathematical aspects. If one was not careful in or judicious with their application, mistakes could be made. For instance, the values of negative numbers could not be punched in their proper, canonical format by DEl [See Printing Part: Punching Department] that is as positive numbers with minus signs, nor could their values be passed properly via DEl's Intermediate and Oblique Axes arrangement: the required, additional leading 9s of such numbers could not be prefixed automatically by DEl during the transfer. [See Eating One's Own Tail]. It seems Babbage was not always fully aware of these difficulties, perhaps over trusting that it would probably all work out in the wash. As a result, some of the features he incorporated in DEl would not have worked at all or worked as fully as he expected.
Taylor's Theorem and The Method of Differences
It was mentioned before that the Method of Differences was closely related to Taylor's Theorem. We shall now see how. Taylor's Theorem is usually stated in the following form:-
f(x+h) = f(x) + h.f'(x) + h^{2}/2! . f''(x) + h^{3}/3! . f'''(x) + ...
where
f(x) is any function of x, evaluated at the point x. h is any finite, fixed interval of x. f(x+h) is the function f(x) evaluated at the point at f'(x), f''(x), f'''(x), ... are the first, second, third, ... differentials of the function f(x) being evaluated.
The Theorem may be rewritten more concisely thus:-
f(x+h) = e^{hD.}f(x)
where f(x), f(x+h) and h are as above
e^{x} is the infinite series (1 + x + x^{2} /2! + x^{3} /3! + ...)
D. is the differential operator d./dx
thus D.y means dy/dx
Now First Differences may be defined thus:-
D^{1}f(x) =f(x+h) - f(x) = (e^{hD.} - 1) . f(x)
Similarly Second Differences may be defined thus:-
= (e^{2hD.} -2e^{hD.} + 1) . f(x)
= (e^{hD.} - 1)^{2} . f(x)
These formulae may be generalised thus:-
It is interesting to note that it appears in a footnote on one of the pages of the 'Preface' to the 'Memoirs of the Analytical Society', written by Babbage and Herschel when they were up at Cambridge together in 1813, some 8 years before Babbage beqan work on the Difference Engine.
It may be proved by Induction
Its truth has been established for n = 1 and n = 2.
By definition:-
D^{n}f_{z} = (e^{hD.} - 1)^{n-1} .f_{z+1 }- (e^{hD.} - l)^{n-l}.f_{z}
= (e^{hD.} - 1) ^{n-1} .(f_{z+1} - _{ }f_{z})
= (e^{hD.} - 1)^{n-1} .(e^{hD.} - 1).f_{z}
= (e^{hD.} - l)^{n} . f_{z}
Which is the desired form of the result.
Having established its truth for n=l and n=2, and demonstrated that the form of the expression for n may be derived from that of n-l, and having seen that they are of the same form, the truth of the theorem for all n results.
A more general expression for Lagrange's Theorem is thus
D^{n}f_{r }= [ (e^{hD.} - l)^{n}e^{rhD.}] . f_{0}
This gives an expression for the values of all differences relative
to the base value of the table, f_{0}.
The Practical Application of Lagrange's Theorem
Lagrange's Theorem can be used to calculate formulae for the starting values of any analytic function and its differences, for use when a table has to be generated using the Method of Differences. The following are for serial sequencing:-
a) Starting Value for the Function Itself (e^{hD.} - 1)^{0} · f(x) = f(x)
b) Starting Value for First Difference D^{1}f_{0} = (e^{hD.} - 1)^{1} . f(x)
= (1 + hD. + h^{2}D^{2}./2! + h^{3}D^{3}./3!
+ ... -1).f(x)
= 0 + hf'(x) + h^{2}/2! .f''(x) + h^{3}/3!. f'''(x) ...
c) Starting Value for Second Difference D^{2}f_{0} = (e^{hD.} - 1)^{2} . f(x)
= (e^{2hD.} - 2e^{hD.} + 1) . f(x)
= (1 + 2hD. + 4h^{2 }/2!D^{2}. + 8h^{3}/3!D^{3}. + ... ) . f(x)
-2(1 + hD. + h^{2 }/2!D^{2}. + h^{3}/3!D^{3}. + ... ) . f(x)
+f(x)
= 0 + 0 + 2h^{2}f''(x) + ih-(&3f'''x
2! 3!f(x)
Similarly formulae for the starting values of the following differences can be determined by expanding Lagrange's Theorem. Intermediate steps are not shown.
d) Starting Value for Third Difference
D^{5}f_{0} = (e^{hD.} - 1)^{5} . f(x)
= 0+0+0+0+0 + 120h^{5}/5!.f'''''(x) + 1800h^{6}/6!.f''''''(x)
g) Starting Value for Sixth Difference
D^{6}f_{0} = (e^{hD.} - 1)^{6} . f(x)
= 0+0+0+0+0+0 + 720h^{6}/6!.f''''''(x) + 15120h^{7}/7!.f'''''''(x)
The Starting Values for 7th and Higher Differences are not necessary as D^{7}f_{0} = 0 is the equation that defines the limit of the calculating power of Babbage's Difference Engine.
A table for the Coefficients used in the above expansions for the term h^{k}/k!.f_{k}(x) may be drawn up:-
VALUES OF k
DIFF
0 1
2
3
4
5
6
7
D^{0}
1
0
0
0
0
0
0
0
D^{1}
0
1
1
1
1
1
1
1
D^{2}
0
0
2
6 14
30 62
126
D^{3}
0
0
0
6 36
150 540
1806
D^{4}
0
0
0
0 24
240 1560
8400
D^{5 }
0
0
0
0
0 120
1800 16800
D^{6}
0
0
0
0
0
0 720
15120
D^{7 }
0
0
0
0
0
0
0 5040
Although the above table gives sufficient values for most calculations that were likely to have been undertaken by the Difference Engine, values for other coefficients could have been calculated and the table extended using the following generator:-
Value of Coefficient in Row r, Column c C [r,c] = r . (C [r,c-1] +C [r-1,c-1])
Example
Value of Coefficient in (Row 6, Column 7)
= 6 . (720 + 1800) = 15120
Practical Example:
Suppose that a Table of the Natural Logarithms has to be tabulated, beginning with the value 1 and continuing up to 10, for intervals of 0.0001.
First construct a table of the differentials of the logarithmic function and their values for x=l
Value for x=1
The Function itself Ln(x) 0
First Differential x^{-l }1
Second Differential -l.x^{-2 }-1
Third Differential 2.x^{-3 } 2
Fourth Differential -6.x^{-4 }-6
Fifth Differential 24.x^{-5 }24
Sixth Differential -120.x^{-6 }-120
Seventh Differential 720.x^{-7
}720
Now, using the formulae listed above, evaluate the starting differences, substituting h = 0.0001, the table's interval.
a) Starting Value for Function Itself
Ln(l) = 0.00000 00000 00000 00000 00000
b) Starting Value for 1st Difference
D^{1}f_{0} = 0
+ (0.000l).l/1! + (0.000l)^{2}.-l/2! + (0.000l)^{3}.2/3!
+ (0.000l)^{4}.-6/4! + (0.000l)^{5}.24/5! + (0.0001)^{6}.-120/6!
+ (0.0001)^{7}.720/7!
= + 0.00000 00000 00000 00000 00000
+ 0.00010 00000 00000 00000 00000
- 0.00000 00050 00000 00000 00000
+ 0.00000 00000 00333 33333 33333
- 0.00000 00000 00000 02500 00000
+ 0.00000 00000 00000 00000 20000
- 0.00000 00000 00000 00000 00001 66666
+ 0.00000 00000 00000 00000 00000 00014 28571
= + 0.00009 99950 00333 30833 53332
c) Starting Value for 2nd Difference
D^{2}f_{0 }= 0 + 0
+ 2.(0.000l)^{2}.-1/2! + 6.(0.000l)^{3}.2/3!
+ 14.(0.0001)^{4}.-6/4! + 30.(0.000l)^{5}.24/5!
+ 62.(0.0001)^{6}.-l20/6! + l20.(0.000l)^{7}.720/7!
= + 0.00000 00000 00000 00000 00000
+ 0.00000 00000 00000 00000 00000
- 0.00000 00100 00000 00000 00000
+ 0.00000 00000 02000 00000 00000
- 0.00000 00000 00000 35000 00000
+ 0.00000 00000 00000 00006 00000
- 0.00000 00000 00000 00000 00103 33333 33333
+ 0.00000 00000 00000 00000 00000 01714 28571
= 0.00000 00099 98000 34994 00103 31619 04762
Without showing intermediate calculations, using the same method, the starting values for the higher differences can be shown to be equal to the following
D^{3}f_{0 }= + 0.00000 00000 01999 10029 99100
D^{4}f_{0 }= - 0.00000 00000 00000 59952 02599
D^{5}f_{0 }= + 0.00000 00000 00000 00023 97002
D^{6}f_{0 }= - 0.00000 00000 00000 00000 01198
A Table of Common Logarithms (Base 10), over the same range of values, with the same interval, may be obtained by multiplying each of the above starting values for the various levels of differences by
l/Ln(10) = + 0.43429 44819 03251 82765 11289
before commencing calculation of the table.
Formulae for the Starting Values of Differences for Parallel Sequencing
Of course, it has been shown that in his later versions of DEl Babbage used parallel sequencing. Without showing intermediate steps, a similar table of the coefficients in the expansions of the formulae for calculating suitable starting values for the differences of any analytic function can be shown to be equal to the following:-
A table for the Coefficients for the term h^{k}/k!.f^{k}(x) :-
Values of k
0 1 2 3 4 5 6
D^{0}f_{0} 1 0 0 0 0 0 0
D^{1}f_{-1} 0 1 -1 1 -1 1 -1
D^{2}f_{-1} 0 0 2 0 2 0 2
D^{3}f_{-2} 0 0 0 6 -12 30 -60
D^{4}f_{-2} 0 0 0 0 24 0 120
D^{5}f_{-3} 0 0 0 0 0 120 -360
D^{6}f_{-3} 0 0 0 0 0 0 720
Using the same example as above, that of the Table of Natural Logarithms, without showing intermediate calculations, the starting values for the various levels of differences for parallel sequencing can be shown to be equal to:-
Table or Result D^{0}f_{0} = + 0.00000 00000 00000 00000 00000
1st Difference Axis D^{1}f_{-1 }= + 0.00010 00050 00333 35833 53335
2nd Difference Axis D^{2}f_{-1} = - 0.00000 00100 00000 05000 00003
3rd Difference Axis D^{3}f_{-2} = + 0.00000 00000 02000 30006 00100
4th Difference Axis D^{4}f_{-2} = - 0.00000 00000 00000 60000 00200
5th Difference Axis D^{5}f_{-3} = + 0.00000 00000 00000 00024 00600
6th Difference Axis D^{6}f_{r} = - 0.00000 00000 00000 00000 01200
Again a table of Common Logarithms (base 10) may be obtained by multiplying these differences by the factor given above.
Variations on the Standard Method of Differences
Once DEl has been set with starting values for differences on its 1st to 6th Difference Axes and also with a starting value for the function to be tabulated on its Result Axis, all that is necessary for one to do is turn the Driving Handle and the machine will do the rest.
For every Result Cycle (of either 6 or 10 turns of the First Axis, 4 of which form the Calculation Sub-Cycle; See Operating Cycles of DEl) DEl's Calculating Part
will first
Add the 6th Difference to the 5th
Add the 4th Difference to the 3rd
Add the 2nd Difference to the 1st
and then
Add the 5th Difference to the 4th
Add the 3rd Difference to the 2nd
Add the 1st Difference to the Result
once each. It has already been shown that this can be summarised by the following, a mathematical expression which describes the fundamental algorithm or basic unit of replication used by DEl in its calculations by the Standard Method of Differences:-
D^{n}U_{n+1}= D^{n}U_{n }+ D^{n+1}U_{n}
DEl, however, through the incorporation of some additional features or changes in its node of operation, is capable of a number of variations over and above the theme of the Standard Method of Differences. It can play more than one tune. These variations increase its flexibility and the range of types of calculation it is able to perform:
Variation 1: Manual Adjustment of Values held on Difference Axes
At certain moments during the Calculation Sub-Cycle DEl's Figure Wheels are not locked tight, but are held loosely and are capable of being turned by hand. Indeed this is necessary for one to be able to set up the starting values on them in the first place, before a new table commences. But it also means that, during operation of the Engine, whilst it is punching and calculating results, the digits on the Figure Wheels could also be adjusted at these times by hand by the operator. For instance, it is possible, in cases say, where the 6th Difference is not a true constant, to adjust its value at frequent intervals according to some regular rule as calculation on the Engine proceeds, thereby reflecting its variable nature. One of the uses which Babbage intended for the Alarm Bell System, which issues an audible warning whenever a previously set value has been reached by an Axis, was perhaps to remind the operator at what moments during the processing of a table when this was to be done. [See Calculating Part: Alarm System].
Variation 2: Addition of Multiple Values of Certain Differences
DEl's Calculating Part has a Barrels Department whose job it was to ensure that the sequence of operations was carried out in the set order. These Barrels have removable studs set around their curved surfaces which put various parts into and out of gear with one another, and they are themselves driven by wheels with removable teeth. [See Calculating Part: Barrels Department]. Furthermore in the Calculating Part's Transmission Gearing Department there are various Sector Wheels which can be exchanged for others which have a different number of teeth, or they can be repositioned so as to act earlier or later in the Cycle, if that is so desired. If these are set in their regular positions the machine performs the Standard Method of Differences. They, however, can be set to be in a variety of different positions, each of which results in a different sequence of operations taking place. For example, it is possible to adjust the machinery before the commencement of the calculation and punching of a table so as to arrange, during every Calculation Sub-Cycle, that the 3rd Difference will be added to the 2nd Difference 2, 3, 4 or more times every one time the 2nd Difference is added to the 1st Difference. There are many options open to the user of DEl regarding this. This mode of integration of differences produces a whole variety of different results and greatly extends the mathematical possibilities of DEl. In these cases the unit of replication in DEl can be summarised by the following expression:
D^{n}U_{n+1} = D^{n}U_{n}+ a. D^{n+1}U_{n}
where a is a whole number constant, but which may be different for different levels of differences but fixed for the calculation of a particular table.
Variation 3: "Eating its own Tail"
Certain elementary transcendental functions, viz, the circular and hyperbolic functions: sine, cosine, hyperbolic sine and hyperbolic cosine, each share a similar mathematical property which can be used to advantage when calculating tables of their values on Babbages Difference Engine. Namely, it is possible when compiling such tables, as each result is produced, for its value to be fed back automatically into the Engine again to participate in the generation of the value of the next. The procedure and mechanisms Babbage invented to carry this out he affectionately called Apparatus for Eating Its Own Tail" . It involved the use of a set of Intermediate and Oblique Axes attached to the front side of the Calculating Part of the Engine [see section on same].
How could this be so?
Before it has been argued that the Differential Calculus and the Calculus
of Differences share many theorems and results in common. See what happens
when the
hyperbolic sine function is differentiated.
f(x) = Sinh(x)
f'(x) = Cosh(x) 1st differential
f''(x) = Sinh(x) 2nd differential
Thus f''(x) = f(x)
In words: the value of the second differential is equal to the function itself. A very similar result can be shown to hold for differences. Consider three adjacent values in a table of hyperbolic sines spaced at an interval equal to k:
f_{0} Sinh(x-k)
f_{1} Sinh(x)
f_{2 } Sinh(x+k)
Its First Differences are:
D^{1}f_{0} = Sinh(x) - Sinh(x-k)
D^{1}f_{1}
= Sinh(x+k) - Sinh(x)
Its Second Differences are
D^{1}f_{2}
= Sinh(x+k) - 2.Sinh(x) + Sinh(x-k)
= Sinh(x)Cosh(x) + Cosh(x)Sinh(k) - 2.Sinh(x) + Sinh(x)Cosh(k) - Cosh(x)Sinh(k)
= 2.Sinh(x)Cosh(x) - 2.Sinh(x)
= 2.(Cosh(k)-l).Sinh(x)
That is to say the value of the second difference of the hyperbolic sine function is equal. to the function itself multiplied by a constant factor.
Consider the constant factor, 2.(Cosh(k)-1)
Cosh(k) = 1 +k^{2}/2! +k^{4}/4! + k^{6}/6! ...
Therefore
2.(Cosh(k)-l) =
Which approximates to, if k is very small:
k^{2} + k^{4}/12
the second term of which in the above series can be ignored, if k is
extremely small.
Thus the second d ifferences of the hyperbolic sine function
D^{2}f_{0} = k^{2}.Sinh(x) = k^{2.}f_{1}
In words: a very accurate value for the second difference can be obtained by taking the current value of the result and multiplying it by the square of the interval. On the Difference Engine, as each result is calculated, the above formula suggests that its value can be used to provide directly the next value for the second difference to be used in the iteration.
But this supposes Multiplication. Multiplication of two numbers together, of course was not possible on DEl: it only had mechanisms for Addition. But was Addition DE1's sole arithmetic processing capability? No! Babbage invented supplementary mechanisms, viz, the Intermediate and Oblique Axes, whereby DE1 could: transfer the values of numbers stepped up or down by powers of 10 from one set of Difference Axes onto others. The stepping of a number up or downby powers of 10 is, of course, equivalent to multiplying or dividing by a power of 10. With this limited multiplication capability DEl was able to be employed usefully in the calculation of tables of the elementary transcendental functions.
For DE1 to work with this limited multiplication capability, when calculating a table of hyperbolic sines, the tables interval, k, would have to be suitably selected such that k^{2 }was both a power of 10, as well as being small. With k = 0.01 k^{2} = 0.000001 (and an error in the factor of the order of k^{4}/12 or 0.0000000000000833). Second differences for a table of the values of the hyperbolic sine function spaced at an interval of 0.001 could therefore be calculated and utilised by stepping each result, as it was obtained, down by 6 decimal places.
Thus as D^{2}f_{r} = k^{2}.f_{r}
if f_{r}= 0.5 and k = 0.00l
then D^{2}f_{r} = 0.0000005
In words, the process is: take the current value of the result, step it down 6 decimal places and this gives one the next value of the 2nd difference to be used in the iteration sequence. No other formal multiplication was required. As long as the interval in the table was small it would take the errors a long time to accumulate before they would begin to affect the significant values of the result.
In actual fact, however, Babbages DEl, unlike his later series of Analytical
Engines had no Reduction to Zero mechanisms. Its Registers or Axes could
not
be cleared of their results automatically and reduced to zero. The
above algortihm, albeit that it seems to work, implies this, that the 2nd
Difference would be cleared of its current value before being substituted
with the new one. As that was not possible on DEl a slightly modified algorithm
was required.
Of course
f_{r+1} = f_{r} + D^{1}f_{r} by definition of what differences are.
But for the hyperbolic sine function
D^{2}f_{r} = k^{2}. fr+1
and D^{2}f_{r+1} = k^{2}f_{r+2} = k^{2}. ( f_{r+1} + D^{1}f_{r+1})
Therefore D^{2}f_{r+1} = k^{2} .( f_{r+1} + D^{1}f_{r+1} ) = D^{2}f_{r} + k^{2}.D^{1}f_{r+1}
In words: the next value for the second difference is obtained
by adding to the current value of the second difference at the same time
an amount equal to that of
the first difference added to the result divided by the square of the
interval of the table (i.e. stepped down appropriately). The Oblique and
Intermediate Axes arrangemeent worked on DEl, not by transferring the absolute
value each axis held but by transferring the amount by which each had been
incremented and all the movements forced on it by the immediately adjacent
and higher difference axis.
Initial values for the differences and sequencing was as follows
Initial Values:
Result Axis
= f_{0}
1st Difference Axis
= D^{1}f_{-1}
2nd Difference Axis
= D^{2}f_{-1}
All other Difference Axes
= 0
Sequence of operations:
1. D^{1}f_{0} = D^{1}f_{-1} + D^{2}f_{-1}
2. f_{1} = f_{0} + D^{1}f_{0}
and simultaneously
D^{2}f_{0} = D^{2}f_{-1}
+ k^{2}.D^{1}f_{0}
1. & 2. can repeat ad infinitum.
Similar functions or algorithms could be worked out for the hyperbolic cosine and the cuircular sine and cose. But it would be discovered that the latter two functions negative values would have to be stepped down and transferred from the Result Axis onto the 2nd Difference for the formulae to work. It might be supposed that this could be done using negative complements [see before]. Not so! DE1 had no means of concatenating the extra 9s required to the 'head' of the traansferred number automatically after the stepping down process had taken place. Therefore negative complemetns on DE1 would not allow this method to be used. Tables for Circular Sines and Cosines would have had to be calculated using the normal Method of Differences. Babbage, it appears, was not aware of the difficulties raised in this variation.
A Note of Warning
Having now presented a theoretical picture of the mathematical nature and purpose of the Difference Engine and some of Babbage's intentions for it, all that there remains is but a note of warning to would-be interpreters of the Engine, perhaps even, in retrospect, for Babbage himself, who did not always heed this. In translating mathematical methods to machinery, not everything that is expressed in the mathematical formulae etc. is necessarily able to be replicated in an analogous form in a machine. One cannot always assume that the Difference Engine embodies everything that the formulae for the Method of Differences contain. A detailed study of its actual mechanical operations are necessary to comprehend any in-built limitations that may manifest themselves during its use. And machines themselves have linkages not present in the mathematics. Of course, it is probable, that Babbage liked to think that his Calculating Machines were the full mechanical realisation of the mathematics involved. This way of thinking was more than likely a constructive way for him to conceive their structure and possibilities in the first place, and was useful and very suggestive for ideas. Nonetheless, machinery cannot always be a full and true analogy for mathematics, and one can fall into grave errors by making this assumption. Mathematics has more freedom and is more flexible. Babbage was guilty of making this mistake as well. Where significant differences from what is expected of the mathematics of a situation manifest themselves, these will be pointed out to the reader, particularly where Babbage himself fell into the same trap.