How Does Charles Babbage's Difference Engine Solve His Quest For Automating Log Tables

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

How Does Charles Babbage's Difference Engine

Solve his Quest for Automating Log Tables?


Asked 2 years, 1 month ago. Active 2 years ago Viewed 211 times
https://hsm.stackexchange.com/questions/11007/how-does-charles-babbages-difference-engine-solve-his-quest-for-automating-log
Accessed 23 October 2021 @ 12:29

At the London Science Museum, we see a model built in 1999 of Charles Babbage's
Difference Engine No.2 based on the plans he left:

1 / 12
We know that Charles Babbage wrote a book of log tables:

In doing this, Babbage was inspired to create Log Tables mechanically, leading to his
design of the Difference Engine.
The Difference Engine produced a ‘tabulation of polynomial functions’.
We can see that the operation of the Difference engine could produce a table that looked
like this:

2 / 12
x p(x) = 2x2 − 3x + 2 diff1(x)=(p(x+1)−p(x)) diff2(x)=(diff1(x+1)−diff1(x))

0 2 -1 4
1 1 3 4
2 4 7 4
3 11 11
4 22

This is fine - but how do you turn this into a log table? I feel like I'm missing a step in
the process.
My question is:
How does Charles Babbage's Difference Engine solve his quest for automating Log Tables?

2 Answers
Charles Babbage took took much longer than he thought to design his Difference
Engine, only a small part got built in his lifetime.

This is from the Science Museum in London.

3 / 12
There are a number of parts to this answer:
How do you calculate log10 60 without a calculator?

We can see the row for log10 60 in the book above. First we will cover off some
assumed knowledge in Babbage's book:

The logarithm is the inverse function to exponentiation. This means:


log10 1 = 0
log10 10 = 1
log10 100 = 2
So, log10 60 must be between 1 and 2.
Now as @xxavier has suggested - we can do logarithms using a Taylor series – ie

but this approximation only works for logs between log10 n where 0 < n < 1.
Also note that this is natural log (loge n) not base 10 log, so we’ll have to convert back
later.

So how do we get to log10 60?

4 / 12
We look at another Logarithmic identity:

How does that help?


We can take what we did before and simplify things:
log10 100 = 2
so,
log10 60=log10 100 + log10 0.6 = 2+ log10 0.6
Now we can go back to our Taylor series approximation:

Which is pretty close to a value provided by a calculator (-0.510826).


Now we convert back to
log10 n
using another logarithmic identity.

This means we can do:

So to convert back to

log10 x

we can divide by
loge 10

which is approx. 2.302.

5 / 12
So now,

Which looks close to what Babbage got:

So we can confidently calculate a logarithm by hand.


How do you calculate a logarithm the Finite Differences Method?
Babbage used the approach of Gaspard de Prony.
We'll use our Binomial expansion above to the sixth order:
We'll do this for a sixth order polynomial:

As an excel function this looks like this:

= (C161-1)
- (1/2) * POWER((C161-1),2)
+(1/3) * POWER((C161-1),3)
- (1/4) * POWER((C161-1),4)
+(1/5) * POWER((C161-1),5)
- (1/6) * POWER((C161-1),6)

6 / 12
Now we build a table for this polynomial of sum of the differences between 0 and 1:

Index Binomial calculation 1st Diff 2nd Diff 3rd Diff 4th Diff 5th Diff 6th Diff
1 0.00000
0.9 −0.10536 −0.10536
0.8 −0.22314 −0.11778 −0.01242
0.7 −0.35663 −0.13349 −0.01571 −0.00329
0.6 −0.51046 −0.15383 −0.02034 −0.00463 −0.00134
0.5 −0.69115 −0.18068 −0.02685 −0.00651 −0.00188 −0.00054
0.4 −0.90773 −0.21658 −0.03590 −0.00905 −0.00254 −0.00066 −0.00012
0.3 −1.17258 −0.26485 −0.04827 −0.01237 −0.00332 −0.00078 −0.00012
0.2 −1.50229 −0.32971 −0.06486 −0.01659 −0.00422 −0.00090 −0.00012
0.1 −1.91870 −0.41640 −0.08669 −0.02183 −0.00524 −0.00102 −0.00012

Now we shuffle top of columns to top row:

Index Binomial calculation 1st Diff 2nd Diff 3rd Diff 4th Diff 5th Diff 6th Diff
1 0.00000 −0.10536 −0.01242 −0.00329 −0.00134 −0.00054 −0.00012

Then we fill in first row with precomputed values, then populate each cell by adding the
cell above and the cell above right:

Index Binomial calculation 1st Diff 2nd Diff 3rd Diff 4th Diff 5th Diff 6th Diff
1 0.00000 −0.10536 −0.01242 −0.00329 −0.00134 −0.00054 −0.00012
0.9 -0.10536 −0.11778 −0.01571 −0.00463 −0.00188 −0.00066 −0.00012
0.8 -0.22314 −0.13349 −0.02034 −0.00651 −0.00254 −0.00078 −0.00012
0.7 -0.35663 −0.15383 −0.02685 −0.00905 −0.00332 −0.00090 −0.00012
0.6 -0.51046 −0.18068 −0.03590 −0.01237 −0.00422 −0.00102 −0.00012
0.5 −0.69115 −0.21658 −0.04827 −0.01659 −0.00524 −0.00114 −0.00012
0.4 −0.90773 −0.26485 −0.06486 −0.02183 −0.00638 −0.00126 −0.00012
0.3 −1.17258 −0.32971 −0.08669 -0.02821 −0.00764 −0.00138 −0.00012
0.2 −1.50229 −0.41640 -0.11490 -0.03585 -0.00902 −0.00150 −0.00012
0.1 −1.91870 −0.53130 -0.15075 -0.04487 -0.01052 −0.00162 −0.00012

So again we get

which we converted back to base 10 above.


You can see a detailed video of the finite differences method here.

7 / 12
How do we use Finite Differences in relation to the Difference Engine?
When initialising the engine - you can set values:

The values you are setting are the top row of the Finite Differences method from before.

Index Binomial calculation 1st Diff 2nd Diff 3rd Diff 4th Diff 5th Diff 6th Diff
1 0.00000 −0.10536 −0.01242 −0.00329 −0.00134 −0.00054 −0.00012

Babbages Difference Engine No.2 was designed for 7th order polynomials (our
calculation was sixth order). This means our Finite Differences Method would have had 7
columns.
On the Difference Engine each vertical axle represents a number with 31 digits - with a
gear corresponding to each digit, the most significant digit at the top:

8 / 12
Note that the Difference Engine represents negative numbers using tens complement.
So, to enter our first value -0.10536 - we have to convert it to tens complement.
10's complement of a decimal number can be found by adding 1 to the 9's complement
of that decimal number. It is just like 2s compliment in binary number representation.
For example, let us take a decimal number 10536, 9's complement of this number will
be 99999-10536 which will be 89463. Now 10s compliment will be 89463+1=89464.
(I'm assuming - similar to digital logic - there is a way to flag a 10s complement number
- but that wasn't available to me at the time of writing.)
So assuming we are entering the value 0.89464 - this means we'll need to turn the 31
wheels to look like:

Gear index Value


31 0
30 0
... ...
5 0
4 8
3 9
2 4
1 6
0 4

(We have entered a decimal fraction as an integer representing the numbers scaled up -
and assume that it will be scaled back down later).
Then we repeat this activity for the other 6 columns of the table - against the next 6
vertical axles of gear-values:

9 / 12
How does the Difference Engine Add Numbers?
In our Finite Differences method - we had to take the cell above, and the cell above
right.
Here we have two wheels representing values in the calculation, and the gear in the
middle that adds.

10 / 12
How does the Difference Engine carry values to the next significant digit during addition?

To carry numbers up - there was an external device:

This was stacked in a vertical array for each value gear on the axle:

11 / 12
You can see the addition gear and the carry mechanism here:

Second Answer:
You tabulate a function for a set of consecutive numbers, then compute a column with
the differences of the tabulated values, then the second, third, etc. differences, until you
get a column with a constant value. Then, by reversing the process, you can construct a
table of that function. If the original tabulated function is a polynomial approximating
the log function, you'll construct a table of logarithms... It's a purely mechanical
operation…
• Could you share a link or work through an example of this calculation?
– hawkeye Sep 21 '19 at 7:15
• For example, take the function you that gave as a table (2x2–3x+2). You can
extend the 1 diff column with the help of the 2nd diff, having 4,3,7,11,15, 19, 23,
27, 31... and using this extended 1 diff column, you can extend the p(x) values,
that will be 1, 4, 11, 22, 37, 56, 79, 106, 137... Thus, you have extended the
tabulation of p(x) without the need to evaluate the function, working only with the
differences. The log function can, as any function, be conveniently approximated
by a polynomial... – xxavier Sep 21 '19 at 7:37
• Can you find a polynomial formula to build the table to give accurate results for ln
x? – hawkeye Sep 25 '19 at 21:21
• A logarithm can be can be approximated by a Taylor series: ln(x) = (x-1) - (1/2)
(x-1)^2 + (1/3)(x-1)^3 - (1/4)(x-1)^4 + ... The more terms you use, the more
accuracy you get… – xxavier Sep 26 '19 at 6:31

12 / 12

You might also like