By our definition of programming of the last 30 years - you didn't program it, you merely gave integer parameters to a function and let it loop a few times and provide an integer answer.
Keep in mind people who performed mathematical calculations given to them during World War II were called "Computers." (i.e. computing can mean calculating and programming can mean scheduling something - like a TV program).
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.
There are a number of parts to this answer:
How do you calculate log₁₀ 60 without a calculator?
We can see the row for log₁₀ 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.
- log₁₀ 1 = 0
- log₁₀ 10 = 1
- log₁₀ 100 = 2
So log₁₀ 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 where 0 < x < 1.
Also note that this is natural log not base 10 log, so we'll have to convert back later.
So how do we get to log₁₀ 60?
We look at another Logarithmic identity:
How does that help?
We can take what we did before - and simplify things:
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 log₁₀ n using another logarithmic identity.
This means we can do:
So to convert back to
we can divide by
which is approx. 2.302.
Which looks close to what Babbage got:
So we can confidently calculate a logarithm by hand.
But the Difference Engine can't expand Taylor series, it uses 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:
Now we build a table for this polynomial of sum of the differences between 0 and 1:
Now we shuffle top of columns to top row
Then we fill in first row with precomputed values, then populate each cell by adding the cell above and the cell above right:
So again we get
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:
The values you are setting are the top row of the Finite Differences method from before.
Babbage's 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:
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 2's complement 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 complement 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:
(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.
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.
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 an vertical array for each value gear on the axle:
You can see the addition gear and the carry mechanism here:
In the context of the 1800s, when ships were getting lost or crashing, and reliable log tables were worth real money, the Difference Engine was (and is) a machine of great beauty.
(The difference engine in the London Science Museum)