Unit 6 video transcript: Meet the Bernoulli numbers

Release candidate. The unit videos are added in the first release.

The words spoken in the Unit 6 video, scene by scene, as its captions show them, with what the animations show marked [On screen: ...] where they play. Each speaker is named where the speaker changes. The Unit 6 reading covers the same material.

The narration is spoken by synthetic voices made for this course, each shown on screen as a drawn robot. No person is speaking.

Unit 6 — Meet the Bernoulli numbers

Narrator: In the next unit you will ask an AI system to write a routine that produces Bernoulli numbers. Before you do that, you need to be able to answer one question without help: what does a correct answer look like?

Why this comes first

That is what this unit is for. Not a maths lecture — just enough ground under your feet that when generated code appears on the screen, you are in a position to judge it rather than admire it.

A Bernoulli number is an exact fraction

The Bernoulli numbers are a fixed sequence of exact fractions. B-zero, B-one, B-two, and so on, one for every whole number from zero upwards. They are not approximate, they are not a matter of opinion, and they do not depend on who computes them. Once you fix the index and the convention, a choice we come to shortly, the value is determined. The first few are: B-zero is one. B-one is minus one half. B-two is one sixth. B-three is zero. B-four is the value you will derive in the activity. B-six is one over forty-two. And every odd-numbered value above B-one is exactly zero. B-eight is shown after your derivation. And look down the right-hand column: by B-twelve the value is minus six hundred and ninety-one over two thousand seven hundred and thirty. The denominators are already awkward, and that matters later.

Where they come from

[On screen: Nine bars rise one after another, for 1 squared up to 9 squared, each as tall as its square. A bracket under them marks the question asked: 1 squared plus 2 squared and so on up to 9 squared, which is 285. Below, the formula for squares appears: 0 squared plus 1 squared and so on up to m minus 1 squared equals m cubed plus 3 times B1 times m squared plus 3 times B2 times m, all over 3. Under it the right-hand side is written again and filled in: B1 becomes minus one half, then B2 becomes one sixth, then each m becomes 9. It works out as 729 minus 243 over 2 plus 9 over 2, all over 3, which is 204. The bars are then re-marked with a second bracket: the formula summed 0 squared up to 8 squared, which is 204, not the 1 squared up to 9 squared that was asked. The closing line reads: every step correct, a different question answered.]

They turn up when you ask a simple question. What is one squared plus two squared plus three squared, all the way up? There is a formula that gives the answer directly, and one for cubes, and fourth powers, and every power after. Write one general formula covering every power. The same sequence of fractions appears among the numbers multiplying its terms, every time. That sequence is the Bernoulli numbers. They were established mathematics well before Note G took them as its example. You do not need the sums-of-powers formula for this course. It is here so the numbers do not feel arbitrary.

[On screen: Nine bars rise one after another, for 1 squared up to 9 squared, each as tall as its square. A bracket under them marks the question asked: 1 squared plus 2 squared and so on up to 9 squared, which is 285. Below, the formula for squares appears: 0 squared plus 1 squared and so on up to m minus 1 squared equals m cubed plus 3 times B1 times m squared plus 3 times B2 times m, all over 3. Under it the right-hand side is written again and filled in: B1 becomes minus one half, then B2 becomes one sixth, then each m becomes 9. It works out as 729 minus 243 over 2 plus 9 over 2, all over 3, which is 204. The bars are then re-marked with a second bracket: the formula summed 0 squared up to 8 squared, which is 204, not the 1 squared up to 9 squared that was asked. The closing line reads: every step correct, a different question answered.]

One detail of it previews the first trap, which is about the sign of B-one. On the screen is the formula for squares. With this course's B-one, minus one half, it stops one short of the limit you give it. Put in B-two, one sixth, and the limit nine. The formula gives two hundred and four. That is the sum from zero squared up to eight squared, not the two hundred and eighty-five asked for. The form that adds from one up to the limit needs B-one to be plus one half. Every step is correct, and it answers a different question. Checking that a procedure was carried out correctly is not checking that it was the right procedure. What you do need is the rule that generates them.

The rule that generates them

Every Bernoulli number is fixed by the ones before it, through a single identity. For a given n, take the sum over j from zero to n of "n plus one choose j" times B-sub-j, and that whole sum equals zero. The "choose" numbers are binomial coefficients, read off row n plus one of Pascal's triangle, counting the top row as row zero. The triangle starts with a single one; each row below begins and ends with one, and every other number is the sum of the two above it. Its rows give exactly these coefficients. The sum stops at j equals n, so the last number in the row is not used: for n equals two, the row is one, three, three, one, and you need one, three and three. The prerequisites page writes them out.

[On screen: The identity sum over j from 0 to n of n plus 1 choose j, times B_j, equals zero is shown, then taken for n equals 1. Row 2 of Pascal's triangle, 1 2 1, appears, and its first two numbers are marked as the coefficients used, because j runs from 0 to n. Two terms appear: 2 choose 0 times B0, plus 2 choose 1 times B1, equals zero. B0 is replaced by 1, leaving B1 as the one unknown. The working reads 1 plus 2 times B1 equals 0, then 2 times B1 equals minus 1, then B1 equals minus one half, which is boxed. Every term was known except the last; substitute, and solve for it.]

Here is one step, for the smallest case, n equals one. The coefficients come from row two of Pascal's triangle, and only the first two are used. One times B-zero, plus two times B-one, equals zero. B-zero is one, so two B-one is minus one, and B-one is minus one half: the value in the table. That is a complete, ordered procedure — exactly the kind of thing Unit 2 was about. Nothing in it is a matter of judgement. You substitute the values you already have, you are left with one unknown, and you solve for it. Pen and paper will do.

Worked: B2

Take n equals two: three terms, with coefficients one, three and three. Substitute B-zero is one and B-one is minus one half. The known part comes to minus one half. So three B-two is one half, and B-two is one sixth. You will run that procedure yourself, for B-four, in this unit's activity. Do it before you let any machine produce the number for you. A value derived independently is one strong reference for judging generated output. Authoritative tables and separately implemented methods are other valid references.

Trap 1 — two conventions, one difference

Now the part that catches people. There are two published conventions for this sequence. The first Bernoulli numbers set B-one to minus one half. The second Bernoulli numbers set B-one to plus one half.

[On screen: Headed 'Comparing index by index', two rows of Bernoulli values, the first convention and the second convention, are compared from n=0 to n=6. At n=0 both read 1 and the column is marked same. At n=1 the first convention reads minus one half and the second reads plus one half; the column is outlined in amber and labelled diverges. The later indices agree again and each is marked same: 1/6 at n=2, 0 at n=3, withheld in both rows at n=4, 0 at n=5 and 1/42 at n=6. An amber line reads: the two conventions part at n=1: -1/2 and +1/2. Below it: every other value is identical; they differ in exactly one place.]

Checker: Every other value in the two sequences is identical. They differ in exactly one place.

Questioner: So which of the two conventions is the right one?

Narrator: Both are standard. Both appear in reference works. Neither is a mistake. They come from two standard definitions of the sequence, the two expressions on the screen. And each suits a different formula: as you saw with the sums of squares, the form that adds up to one less than the limit needs minus one half, and the form that adds from one up to the limit needs plus one half. So if you compare two programs and they disagree only at B-one, you may not have found a bug. The output is just as consistent with an incomplete specification, and only the specification or the code tells you which. This course fixes the first convention: B-one is minus one half. That is written into the reference implementation, and it will go into the prompt you write in Unit 10. If you ask for Bernoulli numbers without saying which convention, you have no grounds for complaint about which one you get.

Trap 2 — Ada labels only the non-zero terms from B2

The second trap is historical, and it is subtler. Since every odd Bernoulli number above the first is zero, Lovelace does not bother giving those zeros a label. Her labels start at what we call B-two, and from there she numbers only the values that are actually there. She labels them with odd numbers: B-one, B-three, B-five, B-seven. So each of her labels is one less than the modern index. The number she calls B-one is what we now call B-two, one sixth. Her B-three is our B-four. Her B-five is our B-six. Her B-seven is our B-eight.

Questioner: So which number does Note G's worked example compute?

[On screen: Headed 'Same symbol, two different numbers', two number lines run across the frame, one above the other. The upper line is modern Bernoulli indexing: B0 = 1, B1 = -1/2, B2 = 1/6, B3 = 0, B4 has a value to derive, B5 = 0, B6 = 1/42, B7 = 0, and B8 is withheld. The lower line begins as an exact copy, aligned index for index. Then the lower line changes. The first two terms, 1 and -1/2, fall away, marked 'not numbered in Note G', because Note G's numbering begins at 1/6. Then the three zero terms at B3, B5 and B7 fall away, each marked with the word 'zero', because Note G numbers only the non-zero terms. Four terms remain. They are renumbered as Ada's B1, B3, B5 and B7, and the labels visibly slide one place to the right as they arrive, so the two lines are no longer in step. The animation ends with Ada's B7 highlighted directly beneath the modern B8, and the statement that Note G computes Ada's B7, which is the modern B8: the same symbol, two different terms, because the modern B7 is 0. A last line warns: ask for B7 without saying which indexing, and the answer you get back may be the wrong term.]

Narrator: The worked example in Note G computes her B-seven. In modern notation that is B-eight. Its value is the same as B-four's, so it is withheld here until after your derivation. Two notations, the same symbols, different meanings. A generated routine can be a faithful reading of Note G and still be wrong as a modern component. It can be right for Note G and wrong for today. That is a real failure mode, and you will see it named in Unit 8.

Two routes, equal weight

The activity offers two routes and they carry equal weight. The table-based route asks you to derive B-four on paper, then compare a claimed set of values against the table, index by index. That is verification, done by hand, and it is what a reviewer does when they cannot run the code. The Python route also starts on paper. You derive B-four by hand, then check your arithmetic in Python with exact fractions, using the standard-library Fraction type. Not floating point, the computer's usual approximate decimals. A float, a number stored that way, can look right at every index and be exact at almost none. So only an exact comparison catches it. Both routes end at the same three checkpoints, with the same questions and the same feedback.

Your checkpoints

By the end of the activity you should be able to state B-four from your own working, say which convention a program's output is consistent with and why it matters, and translate an index between Lovelace's notation and ours. Run each checkpoint in the browser, or in a terminal with the command on the screen. Once you can do those three things, you are ready to be given a wrong answer and notice.

Closing, 20 seconds, no speech. A candidate record on the left, a check against an independent reference in the middle, and a bracketed claim on the right fade in side by side. Below them: Continue with the course material, ai.qyber.dev/edu-ai-literacy-ada-verification/, Course playlist: youtube.com/playlist?list=PLPsBWTfgvakM, All links are also in the description, and Keep your record. Check the next claim.