-1
$\begingroup$

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:

enter image description here

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

enter image description here enter image description here

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.

\begin{array}{|c|c|c|c|} \hline x& p(x) = 2x^2 − 3x + 2 & diff1(x) = ( p(x + 1) − p(x) ) & diff2(x) = ( diff1(x + 1) − diff1(x) ) \\ \hline 0 & 2& -1&4\\ \hline 1 & 1 & 3 &4\\ \hline 2 & 4 & 7&4\\ \hline 3 & 11 & 11 &\\ \hline 4 & 22 & &\\ \hline \end{array}

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?

$\endgroup$
1
$\begingroup$

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

enter image description here This is from the Science Museum in London.

There are a number of parts to this answer:

How do you calculate $\log_{10}60$ without a calculator?

enter image description here

We can see the row for $\log_{10}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:

$\log_{10}1$ = 0

$\log_{10}10$ = 1

$\log_{10}100$ = 2

So $\log_{10}60$ must be between 1 and 2.

Now as @xxavier has suggested - we can do logarithms using a Taylor series - ie

$$ \ln x = (x-1) - \frac{1}{2}(x-1)^2 + ....$$

but this approximation only works for logs between $\log_{10}n$ where 0 < n < 1.

Also note that this is natural log ($\log_{e}n$) not base 10 log, so we'll have to convert back later.

So how do we get to $\log_{10}60$?

We look at another Logarithmic identity:

$\log_{b}(xy) = log_{b}x + log_{b}y$

How does that help?

We can take what we did before - and simplify things:

$\log_{10}100$ = 2

so

$\log_{10}60 = log_{10}100 + log_{10}0.6 = 2 + log_{10}0.6 $

Now we can go back to our Taylor series approximation:

$$ \log_{e}x = (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 + \frac{1}{4}(x-1)^4 + \frac{1}{5}(x-1)^5 + \frac{1}{6}(x-1)^6 $$

$$ \log_{e}0.6 \approx -0.510464 $$

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

Now we convert back to $$ \log_{10}n$$ using another logarithmic identity.

$$ \log_{b}x = \frac{log_{d}x }{ log_{d}b} $$

This means we can do:

$$ \log_{10}x = \frac{log_{e}x }{ log_{e}10} $$

So to convert back to $$ \log_{10}x $$ we can divide by $$ \log_{e}10 $$ which is approx. 2.302.

So now

$$ \log_{10}0.6 \approx -0.222 $$

$$ \log_{10}60 \approx -0.222 + log_{10}100 \approx -0.222 + 2 \approx 1.778 $$

Which looks close to what Babbage got:

enter image description here

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:

$$ \ln x = (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 + \frac{1}{4}(x-1)^4 + \frac{1}{5}(x-1)^5 + \frac{1}{6}(x-1)^6 $$

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)

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

\begin{array}{|c|c|c|c|c|c|c|} \hline index & binomial calculation & 1st diff & 2nd diff & 3rd diff & 4th diff & 5th diff & 6th diff \\ \hline 1&0.00000&&&&&&\\ \hline 0.9&-0.10536&-0.10536&&&&&\\ \hline 0.8&-0.22314&-0.11778&-0.01242&&&&\\ \hline 0.7&-0.35663&-0.13349&-0.01571&-0.00329&&&\\ \hline 0.6&-0.51046&-0.15383&-0.02034&-0.00463&-0.00134&&\\ \hline 0.5&-0.69115&-0.18068&-0.02685&-0.00651&-0.00188&-0.00054&\\ \hline 0.4&-0.90773&-0.21658&-0.03590&-0.00905&-0.00254&-0.00066&-0.00012\\ \hline 0.3&-1.17258&-0.26485&-0.04827&-0.01237&-0.00332&-0.00078&-0.00012\\ \hline 0.2&-1.50229&-0.32971&-0.06486&-0.01659&-0.00422&-0.00090&-0.00012\\ \hline 0.1&-1.91870&-0.41640&-0.08669&-0.02183&-0.00524&-0.00102&-0.00012\\ \hline \end{array}

Now we shuffle top of columns to top row

\begin{array}{|c|c|c|c|c|c|c|} \hline index & binomial calculation & 1st diff & 2nd diff & 3rd diff & 4th diff & 5th diff & 6th diff \\ \hline 1&0.00000&-0.10536&-0.01242&-0.00329&-0.00134&-0.00054&-0.00012\\ \hline \end{array}

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

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

So again we get $$ \log_{e}0.6 \approx -0.51046 $$ which we converted back to base 10 above.

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

How do we use Finite Differences in relation to the Difference Engine?

When initialising the engine - you can set values:

enter image description here

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

\begin{array}{|c|c|c|c|c|c|c|} \hline index & binomial calculation & 1st diff & 2nd diff & 3rd diff & 4th diff & 5th diff & 6th diff \\ \hline 1&0.00000&-0.10536&-0.01242&-0.00329&-0.00134&-0.00054&-0.00012\\ \hline \end{array}

Babbages Difference Engine No.2 was designed for 7th order polynomials (our calcualation 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:

enter image description here

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:

\begin{array}{|c|c|c|c|c|c|c|} \hline gear index & value \\ \hline 31&0\\ \hline 30&0\\ \hline ...&...\\ \hline 5&0\\ \hline 4&8\\ \hline 3&9\\ \hline 2&4\\ \hline 1&6\\ \hline 0&4\\ \hline \end{array}

(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.

enter image description here

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.

enter image description here

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

To carry numbers up - there was an external device:

enter image description here

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

enter image description here

You can see the addition gear and the carry mechanism here:

enter image description here

$\endgroup$
0
$\begingroup$

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...

$\endgroup$
  • $\begingroup$ Could you share a link or work through an example of this calculation? $\endgroup$ – hawkeye Sep 21 at 7:15
  • $\begingroup$ 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... $\endgroup$ – xxavier Sep 21 at 7:37
  • $\begingroup$ Can you find a polynomial formula to build the table to give accurate results for ln x? $\endgroup$ – hawkeye Sep 25 at 21:21
  • $\begingroup$ 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... $\endgroup$ – xxavier Sep 26 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.