DSTECKLER.COM / INTERACTIVE HISTORY
1843 · Note G · A machine that never existed in her lifetime

Run Ada's idea.

Ada Lovelace described a program for Charles Babbage's Analytical Engine to calculate Bernoulli numbers. Move through a modern reconstruction and watch the machine read stored numbers, perform arithmetic, and write the result.

The Analytical Engine · in motion

STEP THROUGH THE CALCULATION
READY
Follow one number through the machine01 / READ
① Memory · read1B₀
→
② Mill · multiply× 1Arithmetic
→
③ Accumulator0Running total
1 × 1 = 1
Start the machine to see numbers moving from memory into arithmetic.
Operation 0 of 0

The store · numbers held in memory

READ—
×
COEFFICIENT—
→
PRODUCT—
Current number being computed
B₁
Result stored
—

What the machine is doing

Press Play to begin or Next operation to inspect one calculation at a time.

    Equivalent modern Python

    This is executable Python, using exact rational arithmetic so the fractions do not get rounded. The historical program used a different numbering convention.

    from fractions import Fraction
    from math import comb
    
    def bernoulli(up_to):
        memory = [Fraction(1)]  # B0
        for n in range(1, up_to + 1):
            total = Fraction(0)
            for k in range(n):
                coefficient = Fraction(comb(n, k), n + 1 - k)
                total += coefficient * memory[k]
            memory.append(-total)
        return memory
    
    for i, number in enumerate(bernoulli(8)):
        print(f"B{i} = {number}")

    The Python runtime is loaded in your browser the first time you run it. Internet access is required.

    Python output will appear here.

    Read Ada's original program

    Her published Note G specifies operations for the Analytical Engine, with variables, intermediate results, and a repeating block of instructions.

    The Bernoulli numbers are a sequence of exact fractions. This reconstruction uses today's indexing: B₀ = 1, B₁ = −1/2, B₂ = 1/6, B₄ = −1/30, B₆ = 1/42, B₈ = −1/30.

    In Ada's diagram, the result labeled B₇ corresponds to the modern B₈. The original is much more detailed than the abbreviated computation animated here.

    Open the original 1843 diagram ↗

    Read the history on your site ↗

    Try an experiment

    Change the target number at the top, reset, and step through the calculation again. Watch which registers get read repeatedly and when a new result is stored.