Computer Science · Mathematics · History of Science

Ada Lovelace

Algorithms The Analytical Engine First Programmer Pioneering Women in STEAM

Augusta Ada King, Countess of Lovelace, was born in 1815 as the daughter of the poet Lord Byron. She never met a working computer — yet in 1843 she wrote the world's first algorithm: a precise, step-by-step set of instructions intended for Charles Babbage's Analytical Engine. Her notes introduced concepts like loops, subroutines, and the idea that a machine could manipulate symbols beyond mere arithmetic — a vision that predates Alan Turing by nearly a century.

🎯 Your Mission

  • Trace data flow: Follow intermediate values across registers and explain why variable reuse is essential to computing memory.
  • Spot reusable blocks: Identify subroutines and loops that eliminate redundant mechanical instructions.
  • Connect symbol manipulation: Discover how Ada saw beyond number-crunching to universal computing, music, and algorithmic art.

Who Was Ada Lovelace?

Watercolor portrait of Ada Lovelace as a young woman by Alfred Edward Chalon, 1840
Ada Lovelace, watercolor by Alfred Edward Chalon, 1840. Public domain.

Born December 10, 1815 in London, Ada's father was the Romantic poet Lord Byron, who left the family when Ada was one month old. Her mother, Anne Isabella Milbanke, fearful Ada would inherit Byron's "poetic madness," raised her on a strict diet of mathematics and logic — ironically the very discipline that made Ada famous.

At 17, Ada met Charles Babbage at a dinner party and immediately grasped the potential of his Difference Engine — a mechanical calculator. Babbage was so impressed that he introduced her to his plans for the far more ambitious Analytical Engine: a general-purpose mechanical computer with a mill (processor), store (memory), input via punched cards, and output via printer.

In 1842, Italian mathematician Luigi Menabrea published a description of the Analytical Engine in French. Babbage asked Ada to translate it. She did — and added her own notes (labeled A through G) that were nearly three times longer than the original article. Note G contained an algorithm for computing Bernoulli numbers — history's first published computer program.

Ada died of uterine cancer on November 27, 1852, aged 36 — the same age as her father Byron. She was buried beside him at the Church of St. Mary Magdalene in Hucknall, Nottinghamshire. In 1980, the US Department of Defense named its new programming language "Ada" in her honor.

A Life Ahead of Its Time

  1. 1815 Born in London; father is poet Lord Byron.
  2. 1816 Byron leaves; mother raises Ada on a strict curriculum of mathematics and logic.
  3. 1832 Contracts measles; temporarily paralyzed; spends years bedridden — studies mathematics intensively.
  4. 1833 Meets Charles Babbage at a dinner party; sees the Difference Engine prototype.
  5. 1835 Marries William King (later Earl of Lovelace); becomes Countess of Lovelace.
  6. 1840 Babbage lectures in Turin on the Analytical Engine; Menabrea writes a description in French.
  7. 1842 Asked to translate Menabrea's paper from French; begins adding her own extensive notes.
  8. 1843 Publishes translation + Notes A–G; Note G contains the Bernoulli algorithm — the first computer program.
  9. 1844 Notes describe loops, subroutines, and the idea the machine could compose music.
  10. 1852 Dies aged 36; buried beside Lord Byron at the Church of St. Mary Magdalene.
  11. 1980 US Department of Defense names the "Ada" programming language in her honor (MIL-STD-1815).

Watch an idea become an algorithm

Four tickets. Ten dollars each. A six-dollar fee. Two people sharing the bill. Let's teach a machine to find each person's share.

1. Give each value a home

A variable names a stored value. A register is a machine's storage location. The label stays; the number inside can change.

V010Dollars per ticket
V14Tickets
V26Fee in dollars

V1 is a location's name, not V × 1. Its current value is 4.

2. Read → calculate → store

An algorithm is a precise, ordered list of instructions. Step through this one and watch its memory change.

Ready · inputs loaded

Find the ticket cost, add the fee, then share.
Read10 and 4From V0 and V1
Calculate10 × 4Ticket cost
StoreV3 is waitingA home for the result
V3—Ticket cost
V4—Total bill
V5—Each person's share

Predict the ticket cost, then run the first instruction. A dash means no value is stored yet.

+Add−Subtract×Multiply÷Divide←Store in
How does this look in Python?
v3 = v0 * v1 means calculate v0 times v1, then store the result in v3. Python uses * for multiplication, / for division, and = for assignment. The mathematical equation 10 × 4 = 40 states equality; the program instruction tells the machine what to do.
Predict: replace V3 with 7. Does V4 change too?
V3 becomes 7. V4 stays 46. A saved result does not automatically recalculate. Run the addition again to update V4. This is called overwriting: one current value replaces another.

3. Keep the recipe. Change the inputs.

A function is a reusable calculation that takes inputs and returns a result. These supplied inputs are its arguments. A subroutine is a reusable instruction block; it need not return a value.

Inputs10, 4, 6Price, tickets, fee
Function: share the bill(price × tickets + fee) ÷ 2Multiply → add → divide
Output23 dollarsEach person's share
Same function, two tickets: predict the new share
(10 × 2 + 6) ÷ 2 = 26 ÷ 2 = 13 dollars each. The arguments changed; the recipe stayed the same. Parentheses group the bill calculation before division.

The simulator below uses a different five-instruction subroutine. These first three calculations are its opening steps; its remaining steps are memory exercises.

4. Repeat only when the test says “yes”

A loop repeats instructions. In the simulator, the counter n records the pass number. The test n < 2 asks “is n smaller than 2?”

After pass 11 < 2 → TruePrepare new inputs → set n to 2 → run the same block again.
After pass 22 < 2 → FalseLeave the loop → print the saved results.

That choice of what happens next is conditional branching.

What if we forget to change n?
If n stays 1, the test keeps saying true. A loop controlled only by that test never stops. We need both progress and a stopping rule.
Try the register trace

What Is an Algorithm — and Why Did It Matter?

An algorithm is a finite, ordered sequence of precise instructions for solving a problem. Ada's 1843 Note G showed in detail how the proposed Analytical Engine could calculate Bernoulli numbers. It connected mathematical rules to operations, storage locations, and repeated steps.

Our simple trace teaches the same kinds of programming ideas using small whole numbers. Once you can explain reading, calculating, storing, and repeating, you are ready to ask what the more advanced mathematics is for.

Most radically, she wrote that the Engine "might act upon other things besides number... supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression... the Engine might compose elaborate and scientific pieces of music." — 1843

What is a Bernoulli number?

Bernoulli numbers are a particular sequence of numbers used in formulas, including formulas for sums of powers such as 1² + 2² + 3². They are not register names. B₂ means “the Bernoulli number at index 2,” not B × 2 or B squared. An index identifies a position in a sequence. A fraction such as 1/6 is one divided by six; −1/2 is negative one-half.

Using the modern convention in our Python reference, B₀ = 1 and B₁ = −1/2. A recurrence is a rule that finds a new sequence value using earlier values. Here is the small case that finds B₂:

  1. B₀ + 3 × B₁ + 3 × B₂ = 0Our rule. B₂ is the unknown; B₀ and B₁ are already known.
  2. 1 + 3 × (−1/2) + 3 × B₂ = 0Substitute B₀ = 1 and B₁ = −1/2.
  3. −1/2 + 3 × B₂ = 0Combine the known terms: 1 − 3/2 = −1/2.
  4. 3 × B₂ = 1/2Add 1/2 to both sides. The unknown term stands alone.
  5. B₂ = (1/2) ÷ 3 = 1/6Divide both sides by 3. Save the result for the next calculation.

The full recurrence handles larger indices with more earlier terms. The key programming task is to keep those earlier values, compute each contribution, add the contributions, and store the new result. You do not need to derive the full formula to understand that process. Ada's historical indexing differs from this modern convention.

Read the 1843 translation and Notes, including Note G. Our worked example and Python below are modern teaching explanations, not a transcription of her operation table.

The Engine's Four Parts — Mapped to a Modern Computer

The Analytical Engine had every major part a computer still has today, just built from brass and steam instead of silicon.

⚙️
The Mill

Performed arithmetic on numbers fed to it.

= CPU
📑
The Store

Held up to 1,000 numbers of 50 digits each, in columns of gears.

= Memory / RAM
📈
Punched Cards

Fed in the sequence of operations and the data, borrowed from the Jacquard loom.

= Program / Input
🖨️
The Printer

Planned to print results directly, removing human transcription error.

= Output

From Ada's Notation to Modern Code

Compare our classroom notation with Python. These examples explain programming concepts; they do not reproduce Ada's historical instructions.

ConceptClassroom notationModern Python
Loop FOR n FROM 1 TO 8: repeat block for n in range(1, 9):
Register / Variable V3 ← V0 × V1 v3 = v0 * v1
Conditional Branch Loop check: n < 8? if n < 8:
Output Output: V6 print(v6)

Python's range(1, 9) counts 1 through 8 — it stops before the second number. That's a real, common bug source; you'll see it again in the Practice section below.

Where does the Turing Test connect to this?
Ada distinguished between the Analytical Engine's ability to do what it is programmed to do and the ability to originate anything — anticipating debates Turing would formalize a century later as the "Turing Test."
Is the Ada programming language still used?
The programming language Ada (MIL-STD-1815, named for Ada's birth year) was mandated for US military software in the 1980s and is still used in aviation, rail signaling, and nuclear systems today.
Was the Analytical Engine ever actually built?
Charles Babbage's Analytical Engine was never completed in his lifetime. A working portion was built at the Science Museum in London in 1991. A full replica was proposed for 2021 but funding has remained elusive.

Punched Cards: How the Engine Was Programmed

Babbage borrowed his input method from the Jacquard loom, which used punched cards to weave patterns into fabric — a hole let a sensing hook pass through to lift a thread, while solid cardboard blocked it. The Analytical Engine adapted this mechanical principle: punched holes represent 1 (engaged), and blank cardboard represents 0 (unengaged).

Explore both how numbers were encoded into cardboard and how Babbage's cards commanded the Mill to calculate:

Binary Pattern00000000
Decimal Value0

Poetical Science: From Arithmetic to Symbols & Music

Ada called her approach "poetical science." While Babbage saw a magnificent machine for calculating mathematical tables, Ada had a profound realization: numbers can represent symbols. If numbers could represent pitches, the Engine could compose music; if numbers could represent weaving levers, it could weave intricate brocades.

"The Analytical Engine weaves algebraical patterns just as the Jacquard-loom weaves flowers and leaves... It might compose elaborate and scientific pieces of music of any degree of complexity or extent."
— Ada Lovelace, Note A (1843)

Tap holes on the punch strip below to compose a 6-step melodic sequence. As each hole trips, the Engine translates the card's physical pattern into chime frequencies and woven tapestry threads:

Trace It Yourself: Predict the Registers

Before you watch the simulator run, try being the engine. This classroom exercise uses easy inputs rather than computing Bernoulli numbers. Steps 4–8 form the core reusable subroutine (five operations), called twice in the simulator below. The last two rows are extra practice in overwriting and scaling, separate from the simulator’s Steps 9–10.

How to read this table: each row shows memory after that instruction. Only the destination changes; carry the other values forward. A dash means no value has been loaded yet, not zero. Steps 1–3 loaded the three given inputs, so the arithmetic starts at Step 4. For the first blank, read V0 = 10 and V1 = 4, multiply them, and write the result in V3.

V0 = 10V1 = 4V2 = 6

For each row, work out the value the operation writes into the register, and type it into the blank. Everything you need is already in the table — either a "given" value above, or a result from an earlier row.

Steps 4–8: core reusable subroutine. Steps 9–10: extra practice.
StepOperationV3V4V5V6V7
4V3 ← V0 × V1 ————
5V4 ← V3 + V2 40 ———
6V5 ← V4 / 2 4046 ——
7V3 ← V1 × V2 4623——
8V6 ← V3 + V5 244623 —
9V3 ← V2 × V2 462347—
10V7 ← V3 / 6 36462347
Notice V3 gets a new value three separate times (Steps 4, 7, and 9), each time overwriting whatever it held before. That's exactly how a variable works in code — it's reusable storage, not a permanent label for one number.

Interactive Analytical Engine — Architectural Trace

A classroom model of the Store (memory), Mill (arithmetic), reusable instructions, and branching. This demonstration uses simple inputs; it does not execute Ada’s historical Bernoulli operation cards.

Predict, test, explain

Focus the canvas or card: Space plays/pauses, ←/P restores, →/N advances, R resets. Seeking pauses playback.

Current step1 / 17
Active registersV0
PlaybackReady

Store registers — current and previous stored values
RegisterRoleValuePrevious valueStatus

Printer tape: waiting for derived results.

Steps 4–8 and 11–15 execute the same five instructions with different inputs. Step back restores a saved teaching state; it does not reverse a physical engine.

Ada's Key Contributions

📝
First Published Algorithm (1843)

Note G of her translation described a step-by-step process for computing Bernoulli numbers — the first algorithm intended for execution by a machine, not a human.

🔄
Concept of Loops

Ada described how a sequence of operations could be repeated with updated values — the foundation of every for-loop, while-loop, and recursive function in computing today.

🔀
Conditional Branching

She recognized the Engine could take different action paths based on intermediate results — the origin of if/then/else logic in all programming languages.

🎵
Symbolic Computation

Ada foresaw that if numbers could represent musical notes, the Engine could compose music. This is the earliest documented vision of a general-purpose symbolic computer.

🧩
Subroutines

She described reusable operation sequences — the concept that became functions, procedures, and methods in all modern software.

💻
"Ada" Programming Language (1980)

The US Department of Defense named its safety-critical programming language Ada in her honor, recognizing her as the mother of software. Ada is still used in aviation, rail, and defense.

Ada Lovelace's Legacy Today

Ada Lovelace Day (second Tuesday of October) celebrates women in STEAM globally, inspired by her legacy. Alan Turing cited Babbage and Lovelace's work in his 1950 paper "Computing Machinery and Intelligence" — the paper that introduced the Turing Test.

Every modern programming concept — variables, loops, conditionals, subroutines — traces conceptually to Ada's 1843 notes. The separation of hardware and software (the Engine could run any algorithm on punched cards) is Ada's most profound insight — 100 years before von Neumann architecture.

Ada grasped that the Analytical Engine's punched-card programs were separate from the machine — the first conception of software as distinct from hardware. This idea, that the same machine could be reprogrammed to solve any problem, is the founding principle of every computer ever built.

Practice Problems

Completed: 0 / 9

Think about algorithms, loops, and the history of computing.

Easy1. In what year did Ada Lovelace publish the world's first algorithm?

Hint: Ada published her translation of Menabrea's paper, with her famous Notes A–G, in the same year she met Babbage at the British Association meeting in Cambridge.

Easy2. What programming concept did Ada describe as repeating a sequence of operations with updated values?

Hint: Ada's Bernoulli algorithm repeated a block of 25 operations, updating register values on each pass. Every for-loop and while-loop in modern code traces to this idea.

Medium3. An algorithm has 3 nested loops each running n = 10 times. How many total operations are executed? (Hint: 10 × 10 × 10 = ?)

Hint: Each nested loop multiplies the operation count. 3 loops × n = 10 each gives n³ = 10 × 10 × 10 = 1,000. In Big-O notation, this is O(n³) — cubic time complexity.

Medium4. Ada's Note G computed which mathematical sequence?

Hint: These are rational numbers that appear in the Taylor series expansions of many trigonometric and hyperbolic functions. Ada's algorithm computed the first eight of them using a loop across 25 operation steps.

Challenge5. Which of these is closest to Ada's most radical insight about the Analytical Engine?

Hint: Ada explicitly wrote that the Engine could act on "other things besides number" — including musical notes. This is the origin of the idea that a computer is a universal symbol-manipulating machine, not just a calculator.

Medium6. On an 8-hole punched card, holes 1, 3, and 8 are punched — all others are left blank. Hole 1 = 128, hole 2 = 64, hole 3 = 32, hole 4 = 16, hole 5 = 8, hole 6 = 4, hole 7 = 2, hole 8 = 1. What decimal number does this card represent?

Hint: Add up the value of every punched hole: 128 (hole 1) + 32 (hole 3) + 1 (hole 8) = 161.

Easy7. Which part of the Analytical Engine is the direct ancestor of a modern computer's RAM (memory)?

Hint: This part held up to 1,000 numbers of 50 digits each, in columns of gears — a place to store data, not to calculate with it.

Debug8. This code should copy Step 4 of the algorithm — with V0 = 10 and V1 = 4, it should produce 40. Instead, it produces 14: v3 = v0 + v1. What's the bug?

Hint: 10 + 4 = 14, which matches the buggy output exactly. Compare that to what Step 4's real operation, V3 ← V0 × V1, should be doing.

Debug9. This loop should compute all 8 Bernoulli numbers (n = 1 through 8), but it only computes 7: for n in range(1, 8):. In Python, range(1, 8) produces 1, 2, 3, 4, 5, 6, 7 — it stops before the second number. What's the fix?

Hint: This is a classic "off-by-one" bug — one of the most common bugs in real code. To get 8 numbers starting at 1, the range needs to stop just after 8, not before it.