Variables V₁ ← 1 V₂ ← 2 V₃ ← n V₄, V₅, V₆ ... ← 0 (working registers)
Op. 1 V₃ − V₁ → V₄ Op. 2 V₃ + V₁ → V₅ Op. 3 V₄ / V₅ → V₄
Op. 4 V₄ × B₀ → V₆ Op. 5 V₄ × B₁ → V₇ Op. 6 V₆ + V₇ → V₆
Op. 7 V₆ × (V₃ − V₂) / V₃ → V₆ ... [operations 7 through 13 apply the same pattern with decremented index and updated Bernoulli terms]
if V₃ > 0 : V₃ − V₂ → V₃ return to Op. 4 if V₃ = 0 : −1 / V₅ × V₆ → B_n halt
Algorithm  ·  1843

Note G

Ada Lovelace 1815–1852
Scientific Memoirs, Vol. III

An algorithm for a computer that did not exist yet, written by a woman who was not supposed to be writing mathematics at all — and still the clearest description of how programming works.

Lesson 2
Variables V₁ ← 1 V₂ ← 2 V₃ ← n V₄, V₅, V₆ ... ← 0 (working registers)
The Variables

Before the first operation, Lovelace assigns names to memory. Each V is a column in the Engine's store — a slot that holds a number and can be overwritten. V₁ and V₂ are constants; V₃ holds the current index; the rest will hold intermediate values. Naming memory before using it is so fundamental that we no longer notice it. Every variable in every program written since inherits this idea.

Op. 1 V₃ − V₁ → V₄ Op. 2 V₃ + V₁ → V₅ Op. 3 V₄ / V₅ → V₄
The Operations

Each operation takes one or two inputs, performs an arithmetic step, and writes the result to a named variable. The arrow is assignment — the variable on the right becomes the result of what is on the left. After Op. 3, V₄ no longer holds what it held before: it holds a ratio. The machine has moved from one state to the next. This is what computation is: a sequence of state changes, written down in advance.

Op. 4 V₄ × B₀ → V₆ Op. 5 V₄ × B₁ → V₇ Op. 6 V₆ + V₇ → V₆
Using Earlier Results

The algorithm reaches back and uses Bernoulli numbers already computed — B₀ and B₁ — as inputs to the next calculation. Each new Bernoulli number is defined in terms of all the ones before it. Lovelace understood that the Engine could store previous results and use them again. She described this as the machine's ability to eat its own output — a strange, self-referential power that sets the Analytical Engine apart from every calculator before it.

Op. 7 V₆ × (V₃ − V₂) / V₃ → V₆ ... [operations 7 through 13 apply the same pattern with decremented index and updated Bernoulli terms]
The Repetition

The same sequence of operations recurs, each time with a smaller index and a fresh set of known Bernoulli values. Lovelace noted this explicitly in the diagram: the barrel of the Engine (its control mechanism) would need to rotate through the same cycle multiple times. She counted the rotations. She worked out how many times each operation would execute before the result was complete. She was reasoning, for the first time in print, about what we now call a loop.

if V₃ > 0 : V₃ − V₂ → V₃ return to Op. 4 if V₃ = 0 : −1 / V₅ × V₆ → B_n halt
The Conditional — and the Stop

The algorithm branches. If there are more terms to compute, it loops back. If the count has reached zero, it performs the final calculation and stops. This is the conditional — the machine takes different paths depending on intermediate results. Lovelace did not have the word for it. She drew arrows. The arrows carried the same logic that every if-statement in every program since then has carried: go here if true, go there if false.

In 1842, the Italian mathematician Luigi Menabrea published a paper in French describing Charles Babbage's Analytical Engine — a machine that did not exist, drawn in correspondence and technical diagrams, never funded to completion. Someone needed to translate the paper into English. Ada Lovelace translated it, then rewrote it. The seven appendices she added, labeled A through G, are three times the length of the original. Note G, the last, contains the first published algorithm designed for execution by a machine.

Diagram for the computation of Bernoulli numbers, Ada Lovelace, 1843
Diagram for the computation of Bernoulli numbers. Ada Lovelace, 1843. The original Note G — the first published algorithm. Public domain.

Babbage had described what the Engine could do in principle. Lovelace specified what it would actually do, step by step. Named variables. Sequenced operations. A loop that repeated until a condition was met. A stop. She counted how many times each operation would execute. She caught an error in Babbage's own earlier calculation. She was doing, for the first time in print, what we now call programming — for a machine that ran on steam and punched cards, that her collaborator never finished building, in a decade that had no word for what she was doing.

She had been educated for precisely this, against every convention of the time. Her mother, Anne Milbanke, had designed her curriculum with deliberate severity: no verse in the house, no romantic disorder, mathematics and logic and French. Lord Byron had abandoned the family when Ada was a month old. Anne's response was curriculum. It worked, in the wrong direction. Ada Lovelace grew up to describe her own thinking as poetical science — a phrase that would have horrified her mother — and to treat mathematics as something you could inhabit, not merely use. She met Babbage in 1833, at seventeen. Most visitors to his Difference Engine saw a curiosity. She saw a question: what else could it do?

Ada Byron aged seventeen, 1832
Ada Byron, aged seventeen, 1832. Unknown artist. She met Babbage the following year. Public domain.

Babbage later claimed he had written Note G himself and that she had merely transcribed it. Modern scholarship, reading the letters carefully, disagrees. The handwriting, the corrections, the sequence of drafts — the evidence points to Lovelace. She died in 1852 at thirty-six, of uterine cancer, the same age as Byron. Her work was not rediscovered until 1953, when B.V. Bowden republished it, as the first real machines were already running. The ideas she had specified — variables, operations, loops, conditionals — had been independently reinvented and implemented in the intervening century without anyone knowing she had been there first. The programming language named after her, Ada, was commissioned by the U.S. Department of Defense in 1980 — the largest software procurement in history at the time, intended to consolidate hundreds of incompatible languages running across US military systems. The name was a decision.

Ada Lovelace
Ada Lovelace
Born
December 10, 1815 London
Written
1843, as annotations to Menabrea's paper
The machine
Babbage's Analytical Engine Never built
Died
November 27, 1852 Age 36 — same as Byron
Rediscovered
B.V. Bowden, 1953 — a century later
Named after
Ada programming language U.S. DoD, 1980
01

Note G contains the first published algorithm designed to be executed by a machine. It specifies named variables, sequenced operations, a repeating loop, and a conditional stop. Every program written since uses the same three ideas.

02

Lovelace wrote it for a machine that was never built. The Analytical Engine existed only in Babbage's drawings and their correspondence. She was specifying the behaviour of something imaginary — which is precisely what programmers do.

03

For nearly a century the note was forgotten. When B.V. Bowden republished it in 1953, the first real computers were already running. The ideas she described had been independently rediscovered, implemented, and named — without knowing she had been there first.

  1. Menabrea, Luigi Federico (1843). 'Sketch of the Analytical Engine invented by Charles Babbage Esq.' Translated with notes by A.A.L. [Ada Augusta Lovelace]. In Richard Taylor (ed.), Scientific Memoirs, Vol. III. London, pp. 666–731. — The primary source. Note G is Appendix G of this translation.
  2. Babbage, Charles (1864). Passages from the Life of a Philosopher. London: Longman, Green, Longman, Roberts & Green. — Babbage's memoir, where he claims to have drafted the Bernoulli numbers algorithm. The letters contradict him.
  3. Woolley, Benjamin (1999). The Bride of Science: Romance, Reason, and Byron's Daughter. London: Pan Macmillan. — The most readable full biography. Takes the letters seriously.
  4. Stein, Dorothy K. (1984). 'Lady Lovelace's Notes: Technical Text and Cultural Context.' Victorian Studies, 28(1), 33–67. — The scholarly paper that definitively establishes Lovelace's authorship of the technical content.
  5. Toole, Betty Alexandra (2004). 'Byron, (Augusta) Ada.' Oxford Dictionary of National Biography. Oxford University Press. doi:10.1093/ref:odnb/37253.
  6. Two Bit History (2018). 'What Did Ada Lovelace's Program Actually Do?' twobithistory.org. — The clearest technical breakdown of the algorithm and its actual bug.
  7. Fourmilab (n.d.). 'Sketch of the Analytical Engine Invented by Charles Babbage, with Notes by the Translator.' fourmilab.ch. — Full text of the original Menabrea/Lovelace document, freely available online.

Take any process you follow regularly — making coffee, choosing a route, deciding what to read next — and write it as a numbered list of operations. Each operation transforms a named value. When you need to repeat steps, write: return to step N. When you need a decision, write: if X, go to step N; otherwise go to step M.

You have just written a program. Not a metaphor for a program — an actual program, in the notation Lovelace invented. The named values are variables. The numbered steps are operations. The 'return to' is a loop. The 'if' is a conditional. Lovelace wrote Note G for a machine that ran on steam and punched cards, that her collaborator never finished building, in a century that had no word for what she was doing. She wrote it anyway, completely, correctly. Bring your program to the session. We will trace through it together.