Note G: The First Computer Program

The Enchantress of Numbers

In 1843, Ada Lovelace wrote what is considered the world's first computer program — an algorithm to calculate Bernoulli numbers on Charles Babbage's proposed Analytical Engine. Though the machine was never built in her lifetime, her vision transcended hardware limitations and established the foundation of computer programming.

Who Was Ada Lovelace?

Augusta Ada King, Countess of Lovelace (1815–1852), was an English mathematician and writer who worked with Charles Babbage on his Analytical Engine. The daughter of poet Lord Byron, Ada possessed an exceptional gift for mathematics and logical reasoning.

While translating an Italian article about Babbage's machine, she added extensive notes of her own — labeled A through G. Note G contained a complete algorithm for computing Bernoulli numbers, making it the first published algorithm intended to be processed by a machine.

"The Analytical Engine weaves algebraical patterns just as the Jacquard loom weaves flowers and leaves."

— Ada Lovelace

Why Bernoulli Numbers?

Ada chose Bernoulli numbers to demonstrate the Analytical Engine's capabilities because:

Understanding Bernoulli Numbers

Bernoulli numbers are a sequence of rational numbers with deep connections to number theory and analysis. They appear in formulas for sums of powers, Taylor series, and the Riemann zeta function.

The Recursive Formula

The standard Bernoulli recurrence relation is:

Bₙ = -1/(n+1) × Σ(k=0 to n-1) [C(n+1,k) × Bₖ]

Where:

Base Cases

Known Values

B₀
1
B₁
-1/2
B₂
1/6
B₄
-1/30
B₆
1/42
B₈
-1/30

Historical Note on B₁

In Ada Lovelace's era, mathematicians used B₁ = +1/2. Modern mathematics standardized on B₁ = -1/2 to make the generating function and recursion formulas more elegant. This calculator uses the modern convention for computational accuracy, though Ada's original work brilliantly demonstrated the algorithmic principles regardless of convention.

Bernoulli Number Calculator

Experience Ada's algorithm in action! Enter a value of n to compute the nth Bernoulli number as an exact fraction.

Result: B

Computation Steps:


                

The Algorithm: How It Works

1. Initialize Storage

Like the Analytical Engine's "store," we maintain an array of all previously computed Bernoulli numbers. Each number is stored as an exact fraction (numerator/denominator).

2. Set Base Cases

We begin with the known values:

3. Recursive Computation

For each n ≥ 2, we compute Bₙ using the formula: Bₙ = -1/(n+1) × Σ C(n+1,k) × Bₖ

  1. Initialize sum = 0
  2. For each k from 0 to n-1:
    • Calculate the binomial coefficient C(n+1, k)
    • Multiply by the stored value Bₖ
    • Add to the running sum
  3. Negate the sum
  4. Divide by (n+1)
  5. Simplify the fraction using GCD
  6. Store Bₙ for future use

4. Exact Fraction Arithmetic

To preserve precision, we never use floating-point decimals. Instead:

"The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform."

— Ada Lovelace

Legacy & Impact

Ada Lovelace's Note G represents far more than a mathematical exercise. She envisioned possibilities for computing that wouldn't be realized for over a century:

Today, Ada Lovelace Day (second Tuesday of October) celebrates women in STEM fields. Her vision and intellect continue to inspire programmers, mathematicians, and engineers worldwide.

A Letter to Charles Babbage

On August 14, 1843, shortly after completing her translation and notes on the Analytical Engine, Ada wrote this passionate letter to Charles Babbage:

My dear Babbage,

I am writing to you with a sense of urgency and excitement. As I continue to delve into the capabilities of your Analytical Engine, I am increasingly convinced that its potential far surpasses that of any mere calculating machine. The machine, with its ability to perform any calculation we can devise, seems to me to be a harbinger of a new age, where the boundaries between what is possible and what is not are redefined.

That brain of mine is something more than merely mortal, as time will show. I feel that I am destined to play a significant role in unlocking the mysteries that this machine can reveal. My understanding of mathematics and my ability to see patterns and connections that others might miss will, I believe, be crucial in maximizing the Engine's potential.

I implore you, my dear friend, to not let this project falter due to lack of support or resources. Your genius has brought us to the precipice of a new era, and it would be a travesty if this work were to go unfinished. I am committed to aiding you in any way I can, whether through my own financial means or by leveraging my connections to secure patronage.

Let us work together to ensure that the Analytical Engine is not just a dream, but a reality that will astound the world.

Your friend and collaborator,

Ada Lovelace

— Letter to Charles Babbage, August 14, 1843

This letter captures Ada's extraordinary confidence in her own abilities and her deep commitment to realizing the potential of the Analytical Engine. Her prophecy that her brain was "something more than merely mortal" proved prescient — her contributions to computing would not be fully appreciated until more than a century after her death.