An idea of the power (speed) of Babbage's Difference EngineBabbage's engine as built in the 1990s prints one evaluation of a 7th order polynomial each four seconds.
- Fifteen evaluations per minute.

from Tim Coslett
"To evaluate seven terms of a power series took 15 minutes on the
Harvard [Mark I] device of which 3 minutes was set-up time, whereas it
will take at least 15 minutes to set up ENIAC and about 1 second to do
the computing."
- September 2, 1944 letter to Colonel Paul Gillon, assistant director
BRL from Lieutenant Herman Goldstine, U.S. Army liaison officer for
Project PX (ENIAC)

It seems that the Babbage machine (mechanical, designed about 1848) is about as fast as the
ENIAC (electronic, designed and built about 100 years later) on this particular problem.

without studying Numerical Analysis and getting headaches!
* Please note, this JavaScript emulator fails to run properly on Internet Explorer 7 and up.

Disclaimer - I (the author of this piece) am neither a mathematician nor historian
(I are a enjineer!)

The methods shown below may not be optimum, but no one has suggested better to me.

Babbage wrote much, but there were no details that I found of how he
was going to determine

the polynomial coefficients to set into his proposed machine to start it computing
non-trivial computations such as logarithms or trig functions,

determine ranges over which they would provide the desired accuracy,
nor other vital details.

I have examined
collections of his works - such as the 11 volume "The Works of Charles Babbage"
Edited by Martin Campbell-Kelly, published in London by William Pickering, 1989.
Even Volume 2 "The Difference Engine and Table Making" only gave grade school
examples of integer powers of 2 and similar trivial situations.

Possibly he figured that any competent mathematician of the era would
regard the determination of coefficients as obvious or child's play. Or maybe
he did not care to disturb "the rest of us" with interesting complexities.

The Goal of the Babbage Difference Engine was to provide accurate trig and log tables (for navigation, engineering & astronomical computations). Babbage designed
this version of difference engine during 1847-1849, using technical improvements
discovered while he was designing his Analytical Engine.

One can think of Babbage's Difference Engine as a means of providing an interpolation between
widely spaced known points. To use the available power (seventh degree polynomial)
of the engine, eight known points are required. Two of the points near the end points
of the function to be approximated, and six points roughly evenly spaced in-between the
end points.

This web site also includes two manuals kindly provided by
British National Museum of Science and Industry

Please note: This paper does not discuss the Babbage Analytical Engine
that contains many of the ideas of the modern computer, and was
described by "Ada King, Countess of Lovelace"
(please see name discussion here)
and others. The Analytical Engine development came
after the construction of the Difference Engine was abandoned.

The design of Difference Engine II incorporated improvements found during
Babbage's design work on his Analytical Engine - yielding a reduction of
parts count from 25,000 to 8,000.

This is one page (of 18 pages) of the five-place logarithms - from 200 through 250

This is a page of natural trigonometeric functions - from 28 through 29 degrees.

This book also contains logs of trig functions, Gamma functions,
hyperbolic functions, and much much more.

The British needed accurate trig and other tables for navigation of their sea going
merchant and naval vessels. They
were very interested in such developments and machines in the 1600s through the 1800s.

Babbage had investigated errors in navigational and astronomical tables,
and realized that both correct
computation and printing were needed. So the second part of
his Difference Engine was a type-setting machine, which reduced the probability
of human error to a minimum.

He was awarded a gold metal by the British Astronomical Society for his paper
"Observations on the Application of Machinery to the Computation of Mathematical Tables."
in 1821.

Charles Babbage was an interesting character; very gifted, but he was
a very poor project engineer and politician.
This paper is not about him or his problems and failure in producing
his Difference Engine, but is about how to set up a Difference Engine # 2 so that it
can produce the desired tables.

Bolded numbers below are difference values obtained by the process
Method of Finite Differences for y = x3The symbol -> indicates subtract the number just above from the number just below and place the result to the right.

x (cycle)

y = x3

1st dif

2nd dif

3rd dif

4th dif

0

0

->

1

1

1

->

6

->

7

->

6

2

8

->

12

->

0

->

19

->

6

3

27

->

18

->

0

->

37

->

6

4

64

->

24

->

61

5

125

The difference values obtained by the above process are 0, 1, 6, 6, and 0

Using above difference values to calculate y = x3

The difference values obtained by the above process (0, 1, 6, 6, and 0)
are placed into the Difference Columns of a "difference engine".

note: the noun "Difference Column" has been abreviated to "DC" in the table below.

adding DC1 to DC0, then DC2 to DC1, ...

cycle(x)

DC0(y=x3)

DC1

DC2

DC3

DC4

0

0

1

6

6

0

1

1

7

12

6

0

2

8

19

18

6

0

3

27

37

24

6

0

4

64

61

30

6

0

5

125

91

36

6

0

6

216

127

42

6

0

7

343

169

48

6

0

Bolded numbers above are the results obtained by the process.
An example of the above, and the BASIC program, is provided
here

Summary of the above difference method. A polynomial of limited degree
(number of terms, power of exponents, ...) can be evaluated exactly to many values
of x by using the method of differences. In the method of differences, you
evaluate a few values of x, do the differences, and by simple addition, and
can evaluate a large number of values.

This is just a table of 45 values - trivial - and the errors are almost intolerable already.

HOWEVER - in a more useful sin table, with a value every 1 minute, things go
dramatically wrong using this simple method. See this
UBASIC example of a sin table with an output every 1 minute
of angle.

By the way, you notice that I make a big deal about extended precision. there is an
example of using normal IEEE floating point (about 15 digit precision). You may notice that
similar code to the example in the above paragraph yields an error of 54% at a mere 12 degrees.

To summarize, if you are forming trig and log tables, using the method that works
so well with polynomials of 7th degree or less fails. The first 8 values have 0 error,
then the rest of the values have increasingly bad errors.

In the next section, we will examine a method where few if any values are EXACTLY
correct, but all values are within known (and hopefully acceptable) error limits.

This page (750 KB) from "Applied Numerical Methods"
by Carnahan shows that "least squares curve fit" is not needed when exact points are available.

The higher the order of the polynomial, the closer you can "fit" the
polynomial to the desired function. Unfortunately, the higher the
order of the polynomial, the more expensive the computing machine.
In these days of wonderfully cheap computing capability, you could
choose a 100th degrees polynomial with no visible impact on your budget.
However, Babbage was making his machine from very expensive precision
machinery, and he had to compromise. His compromise, which was still
too expensive to attract investment money - was a 7th degree polynomial design.

The same cost driven compromise caused Babbage to restrict the precision
of the Difference Engine to 31 decimal places. This seems like an
excessive precision - BUT - a wide variety of error sources, which
accumulate in the calculations, are caused by a finite limit to the computing accuracy.

AND several digit positions of the machine are need to count operations to provide
the "argument" column of the printed table, such as from above
y = x3 example.

x

y = x3

0

0

1

1

2

8

3

27

4

64

5

125

6

216

7

343

Fortunately, you can reduce the errors caused by the missing higher order terms by
adjusting the available (7th order) terms by closely fitting a lower order (7th order)
polynomial as closely as practical to the function over the range of interest.
(And if the errors are too great, you can reduce the range and reduce the errors.)
Curve fitting the approximating polynomial to the actual function helps correct for
the missing higher order terms of the actual function.

The individual values of the approximating polynomial, while not usually perfect,
can closely approximate the function over the entire desired range. I will show that
by using just a 7th order "interpolating polynomial" the sin function can be computed
in 1 minute steps from 0 to 23 degrees (1860 steps) with a maximum error of
10-12. With this kind of accuracy, if every thing else is perfect,
a navigator can determine his position within an inch relative to the earth's surface.
That ought to be good enough, even for the British Navy. ;-))

Use these values to determine the coefficients of a polynomial
using Gaussian Reduction or some other curve fitting technique.
Ideally, you will have an extended precision mathematical package
such as MATHEMATICA or MAPLE to do this quite automatically
(ah, this modern world :-)

Here is an
example,
written in MATHEMATICA (a wonderful and expensive extended precision
mathematical tool - I have a very old student version). The extended precision is needed
as IEEE floating point used by many low cost or free tools, such as Euler
is accurate to "only" 15 decimal digits. Since the Babbage machine is capable of
up to 31 digit precision, errors due to the limited precision of the floating point
other packages introduces serious simulation errors.

Unfortunately, the above packages are not free - even student versions
are sold for about $140.

A handy 15 decimal digit accuracy curve fit package is found at
the web site
of John Kennedy, retired
mathematics instructor from Santa Monica College.

Make a new directory, then access
John Kennedy's web site,
click on "Downloadable Math Software", then download "JK32W2.ZIP" to your new directory.
(I am assuming that you have access to PKZIP or a similar expansion routine.)
Unzip the file, and Start polyfit.exe. This starts a handy Windows program
that can calculate "Least Squares Fit" of data to the limits of IEEE floating point.

For your convenience, I have included John Kennedy's POLYFIT directory here.
You should be able to click on the .pdf and .txt files to see the contents.
To run PolyFit.exe , copy it to a directory, and click on it there -

We now have the coefficients, accurate to about 31 decimal places, of the sine function
over the range of 0 to 23 degrees.

Unfortunately, the simple difference set up used in the Normal serial operation
does not work for the Babbage parallel operation - expected operations are
done out of sequence, and the results are just wrong.

To correct the parameters set into the Babbage machine, you MUST
Subtract various differences. Perform the following in exactly this order.

from Tim Robinson web site - a
Mathematica notebook - .nb [of logarithms 1.0 to 1.6]
with the setup and its derivation.
This is set up so as to reproduce the first twelve pages of Babbage's
own 7 figure log table from a single setup (about 6000 values). .pdf version

From Doron Swade September 2002,
in-charge of building the Babbage Difference Engine - British Museum of Science and Industry

>The printing section does not seem to discuss
>whether negative numbers are printed in
> a) 10s complement
> b) signed absolute
>
>This is certainly not a problem in most trig and log generation,
> but is to me an interesting general question.
>
>Could you answer this matter of printing sign representation.

Negative numbers are dealt with as complements as you correctly surmise.
There is no provision for normalising for conventional signing before
printing. It is most likely that the stereotypes would have been left
intact and the results printed in complement form with appropriate
instructions in a customary Preface on use of the tables and the techniques
for inverting the complements. There is no provision in the printer
apparatus on DE2 to print signs and I cannot immediately see how the
machine could be modified to do so.

With the printer and stereotyping apparatus coupled to the calculating
section as depicted in Babbage's drawings all the apparatus can do is
produce an inscriptional and impressed record of the last column of results
in the calculating section. This 31-digit result (printed to 30 places) is
the outcome of repeated addition using finite differences. It is strictly
decimal i.e. the carry mechanism works strictly modulo 10. To convert to
sexagessimal notation would require a completely new set of 248 figure
wheels with carry fingers differently positioned. The timing cycle would
also be affected. In short, the answer is, 'no': the machine is strictly
decimal and converting to an alternative modulus would require redesign and
rebuild. (In contrast, the Scheutz Difference Engine was easily modified
for sexagessimal use).

The printing and stereotyping apparatus is now complete and working. There
were many modifications necessary and it was a more difficult job than the
calculating section. It is now likely that I will be spending time next
year completing the documentation i.e. updating and completing the
Technical Description you have to include the printer/stereotyping build.

> I was looking for a speed governor on the steam engine -
> found none.

My experience with the small model steam engines is that they have a certain speed they like to go at and won't exceed, so I guess they just chose the pulleys to get the speed required.

> The operator appeared to open a black
> ?phenolic so his fingers wouldn't be burned?
> round knob near the top of the boiler.
>
> If I remember correctly,
> on our model, the speed had to be carefully controlled.

Yes very much so, because of the intermittent drive to the helical axes.
It looks like they have a more robust version in this model.

> With all that mechanical advantage, and inertia,
> the computing machine better not jam (much) ;-))

Either a belt will slip or that small engine will stall.

Interestingly I came across a note by Babbage (in one of the Sketchbooks) where he talks about
driving the analytical engine by a small steam engine.
He has it nailed. The steam engine does not drive it directly. Instead it's driven by the
fall of two weights which are rewound
by the steam engine. While one weight is driving the other is being rewound.

For the record:
Sketchbook vol 2, page 47, 31 Dec 1835:
"The power supp[lie]d to Drive engine whether man animal or steam is to lift two weights
alternatively and the engine is never to be driven but by weights"

This is similar to the automatically rewound weights driving the printer in the
DE [Difference Engine]. This way there is a fixed torque available from the weights
which presumably is chosen so it will harmlessly stop on a jam.

He does not discuss
the issue of regulating the speed, but that was a solved problem by then,
using air brakes as in the strike mechanism of a church clock.