Ada Lovelace and the First Computer Algorithm

In this post we will focus on a very specific algorithm called the Note G algorithm, written in 1843 by Ada Lovelace. Born in 1815, Ada Lovelace is celebrated as a visionary whose work laid the groundwork for modern computing. Among her most notable contributions is the Note-G algorithm, widely regarded as the first computer algorithm, even though the machine it was designed for—the Analytical Engine—was never built.

The Analytical Engine: A Vision Ahead of Its Time

The Analytical Engine was a mechanical general-purpose computer proposed by Charles Babbage. Although it remained a theoretical construct, the engine’s design was revolutionary. It was intended to perform complex calculations and could be programmed using punched cards, a concept that would later influence the development of early computers.

The Note-G Algorithm: The First of Its Kind

Ada Lovelace’s Note-G algorithm was designed to be implemented on the Analytical Engine. The algorithm was part of her translation and expansion of an Italian article on the engine, where she detailed how the machine could compute Bernoulli numbers. This work is significant because it represents the first explicit description of a step-by-step process for a machine to perform a complex calculation—the essence of what we now call an algorithm.

Diagram of an algorithm for the Analytical Engine for the computation of Bernoulli numbers, from Sketch of The Analytical Engine Invented by Charles Babbage by Luigi Menabrea with notes by Ada Lovelace

Bernoulli Numbers?

For those unfamiliar with the term, Bernoulli numbers are a sequence of rational numbers with deep connections to number theory. They appear in various areas of mathematics, including the expansion of trigonometric functions and the calculation of sums of powers of integers. The sequence starts with B₀ = 1, B₁ = -1/2, B₂ = 1/6, and so on, with each number defined by a specific recursive formula.

Lovelace’s algorithm to compute these numbers was ground breaking because it demonstrated that a machine could perform tasks that went beyond simple arithmetic, showcasing the potential for automated computation.

Testing the Note-G Algorithm

Let’s use our Analytical Engine emulator to test Ada Lovelace’s algorithm. The algorithm provided below is a direct translation of Ada Lovelace’s algorithm (See picture above). It is used to calculate Bernoulli Number 7( B7).

To work out the value of B7, the algorithms relies on the values of B1, B3 and B5.

Bj Fraction Decimal
B1 1/6 +0.166666666
B3 −1/30 −0.033333333
B5 1/42 +0.023809523

As the Store of the analytical engine can only store integer values (whole numbers with no decimal), we are shifting the values being calculated by 12 digits.

For instance the output of our program should be read as follows: B7 = -33333333336 x 10-12 = 0.033333333336 ≈ -1/30
Charles Babbage’s Analytical Engine SimulatorOpen in new tab/window

Did you like this challenge?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 6

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!