"What is imagination?...It is a God-like, a noble faculty. It renders earth tolerable; it teaches us to live, in the tone of the eternal." - Ada Lovelace to Charles Babbage
When Charles Babbage, in 1837, proposed a ”Fully programmable machine” which would be later called an Analytical engine, not even the government who seed-funded his Difference Engine believed him.
Undoubtedly the most influential machine in existence is today’s modern computer. But back in the 19th century, when the world was drooling over the industrial revolution and railway tracks and steam engines, a machine which could think and calculate looked like a distant dream. While most see the evolution of these advanced machines such as computers and smartphones as examples of electronic innovation, what people have taken for granted had been an evolution and the hard work of transforming a mechanical device into a self-thinking smart device which would become an integral part of our lives.
Charles Babbage - The father of the computer
In the 19th century, the concept of specialization had not breached the revered halls of universities and laboratories.
Most of the geniuses were polymaths, so was the Englishman Charles Babbage. Charles Babbage was a renowned mathematician, philosopher, and mechanical engineer of his times.
During those days, mathematical tables (such as your logbook) were manually made and were used in navigation, science, and engineering. Since most of these tables were manually updated and calculated, the values in these tables varied frequently, giving inconsistent results during studies.
While at Cambridge, Charles Babbage noticed this flaw and thought of converting this mathematical-table based calculation into a mechanical product to avoid any discrepancies.
In 1822, Charles Babbage decided to make a machine to calculate the polynomial function—a machine which would calculate the value automatically. In 1823, the British government gave Charles Babbage £1700 (probably the first ever seed funding).
He named it the Difference Engine, possibly after the finite difference method it used to calculate. Charles Babbage invited Joseph Clement to design his ambitious massive difference engine that had about 25,000 parts, weighed around 15 tons, and was 8 feet tall.
Despite the ample funding by the government, the engine never got completed. And in the late 1840s, he planned on making an improved engine. But that was not completed either due to lack of funds.
In 1989–1991, scientists and engineers studying Charles Babbage’s research paper built the first difference engine, which is now placed in The Museum of the History of Science, Oxford.
How Does Charles Babbage’s Difference Engine work?
Wikipedia says: “A difference engine is an automatic mechanical calculator designed to tabulate polynomial functions. The name derives from the method of divided differences, a way to interpolate or tabulate functions by using a small set of polynomial coefficients.”
Let’s take an example with a polynomial function R = x2 + 1
|X||R||Difference 1||Difference 2|
|Step 1||0||1||1 (D11)||2 (D21)|
|Step 2||1||2||3 (D12)||2 (D22)|
|Step 3||2||5||5 (D13)||2 (D23)|
|Step 4||3||10||7 (D14)||2 (D24)|
|Step 5||4||17||9 (D15)||2 (D2)|
To solve this manually, you need to solve the equation “n+1” times, where n is the polynomial. So, for the given equation, we need three steps.
When X = 0, result of R = 1; X= 1, R =2; X=2, R= 5, and so on.
Difference 1 : D11 = R2 (Step 2) - R1 (Step 1) or D12 (Step 2) = R3 (Step 3) - R2 ( Step 2) and so on
So for the Difference 1 column in the table above,
D11 = 2 (R2) - 1(R1) = 1
D12 = 5 (R3) - 2(R2) = 3
D13 = 10 (R4) - 5(R3) = 5
Difference 2 : D21 = D12 (Difference 1 -Step 2) - D11( Difference 1- Step 1), and so on.
By subtracting two consecutive values from the Difference 1 column,
D21 = 3 (D12) - 1(D11) = 2
D22 = 5 (D13) - 3 (D12) = 2
Similarly, for a third-order equation, we can prepare a new column called Difference 3, and calculate it by subtracting two consecutive numbers from the last column.
*The values in the last column or the highest power value always remain constant in the last difference column.*
Since the engine could only add and subtract, some of the values from each column are given to the difference engine to feed the engine with information necessary for further calculations.
Working of a difference engine
Let’s take another example where you have to calculate the result for x = 3 from the above equation (R = x2 + 1), and the engine was already given the values of Step 1 and Step 2 columns (Refer to above table). The engine would follow the following steps:
Step 1: To calculate the value for D12, Step 1 difference 2 is added to Step 1 Difference 1, which is 2(D21) +1( D11)=3.
Step 2: This D12 when added with R2, which gives the result for Step 3 = 3 (D12) + 2( R2) = 5
Similarly, to calculate result for x = 4
Step 1 - For X = 4, Step 2 - Difference 2 added to Difference 1 = 2 (D22) +1 (D12) = 5
Step 2 - Add value from Step 1 to Step 3 result R3, which is 5+5, giving the final value as 10
A difference engine (shown above) consisted of N+1 columns, where column N could only store constants and Column 1 showed the value of the current iteration. And the machine was only capable of adding values from column n+1 to N.
The engine is programmed by setting initial values to the columns. Column 1 is set to the value of the polynomial at the start of computation. Column 2 is set to a value derived from the first and higher derivatives of the polynomial at the same value of X. Each column from 3 to N is set to a value derived from the first-order derivative. To simplify what the difference engine did, here is a simple code for Polynomial Function calculation using C++ -
using namespace std;
int d; // degree of the polynomial
int i; //
int c; //
cout << "Enter the degree of the polynomial: " << endl;
cin >> d; // degree of the polynomial
cout << "The degree of the polynomial you entered was " << d << endl;
int *c = new int[i];
for(i = 0; i <= d; i++)
cout << "Enter coefficients: " << endl;
cin >> c[i];
cout << "There are " << d + 1 << " coefficients";
cout << " The coefficients are: ";
for (i = 0; i < d + 1; i++)
cout << "\n " << c[i];
cout << endl;
cout << " Enter the value for evaluating the polynomials" << endl;
cin >> value;
sum = 0;
cout << " The value is " << value << endl;
cout << "First polynomial is: " << endl;
cout << c << "x^3 + " << c << "x^2 + " << c << "x + " << c << endl;
for (i = 0; i <= d; i++)
p = 1;
for (j = 0; j <= (d - 1); j++)
p = p * value;
sum = sum + p;
sum = pow(c*value,d)+pow(c*value,d-1)+pow(c*value,d-2)+pow(c*value,d-3);
cout << "The sum is " << sum << endl;
The difference engine was never finished, and during its construction, Charles Babbage had a brilliant idea of using Punch Cards for calculation. Till then, punch cards that had been used only for the mundane job of weaving would form the basis of future computer programming.
Before Joseph Jacquard came up with the idea of punch cards, the weaving was done using draw looms. A drawloom generally used a “figure harness” to control the weaving pattern. The drawloom required two operators to control the machine.
Although till 1801, punch cards were only used for individual weaving, Jacquard decided to use perforated papers with the mechanism, because he found that though being intricate, weaving was mechanical and repetitive.
In the most basic form, a weaving design is made by passing one thread over another.
In a patterned weave, the threads crossing each other are not synchronized by equal blocks but are changed according to the required pattern. A weaver controls the threads by pulling and releasing them.
When Joseph Jacquard came up with the idea of a loom, the fabric design in it was first copied on square papers. This design on the square was translated into punch cards. These cards are stitched together in a continuous belt and fed into the loom.
The holes in the card controlled which threads are raised into the weaving pattern. This automation allowed Jacquard to make designs and produce them again at lesser costs. Keeping this bunch of cards helped to reproduce the same design repeatedly with perfection on the same or another machine.
“Visualizing” the concept of using these punch cards to calculate, Charles Babbage described using them for the analytical engine.
In 1883, Charles Babbage was introduced to a young brilliant mathematician, Ada, who later became Countess of Lovelace, by her tutor. He was impressed with Ada's analytical skills and invited her to look the difference engine, which fascinated her. This formed the basis of a lasting friendship that continued until her death.
Ada Lovelace - The first programmer
Born to British poet Lord Byron and Annabella Milbanke, Augusta Ada Byron married William King-Noel, who was the first Earl of Lovelace. Ada was a natural poet who found mathematics poetic. Growing up, Ada’s education and her families’ influential presence got her in touch with a few prestigious innovators and literary figures of her time.
While studying mathematics, her tutor Mary Somerville introduced her to Charles Babbage, who, after his work on the unsuccessful Difference Engine, was working on an ambitious project of a machine which could solve any complex mathematical function (the Analytical Engine).
What you see below is a caricature image of the Analytical Engine as proposed by Charles Babbage. The important parts of this engine still constitute our modern computers.
Part 1 - The Store, was what we now call Hard disk or memory
Part 2 - The Mill, was what we now call Central Processing Unit (Mill where the churning or production is done)
Part 3 - Steam engine, which would be the source of energy
Ada, impressed by the theory and concept of the Analytical Engine, decided to work with Charles Babbage on the construction of the engine.
During her study of the Analytical Engine, she wrote a series of notes which explained the difference between a Difference Engine and an Analytical Engine. She took up Bernoulli number theory and built a detailed algorithm on the process of calculating Bernoulli numbers using an Analytical engine which was demonstrated in Note G of her article shown below. This made her the first programmer in the world. (This is disputed.)
Though her notes were never accepted, and as there was no funding or investment to back Charles Babbage’s fantastic idea, the analytical engine was never completed.
Here is a simple C++ program to the algorithm developed by Ada Lovelace in her lengthy notes:
const int nrolls=10000;
int count=0; // count number of trues
for (int i=0; i<nrolls; ++i) if (distribution(generator)) ++count;
std::cout << "bernoulli_distribution (0.5) x 10000:" << std::endl;
std::cout << "true: " << count << std::endl;
std::cout << "false: " << nrolls-count << std::endl;
Charles Babbage declined both the title of Knighthood and baronetcy and instead asked for a life peerage, but that wish wasn't granted in his lifetime. He died in 1871 ate the age of 79. Ada Lovelace died at the young age of 36 in 1852. Her contribution to computer science for having come up with the "first" algorithm still remains one of the greatest controversies in technology history. You can read one such article here.
Irrespective of these facts, their contribution to the field of computer and programming cannot be ignored. A super calculator which would be able to solve any mathematical problem and a device which would have the ability to think of ways to approach a problem is what Charles Babbage and Ada Lovelace thought of; this was the founding stone of the first programmable computer.
In the next article, we will discuss the use of Punch Cards and how with all technological developments in Europe, the USA got the first computer!