Tokenwerk · The LLM textbook

Chapter 39 · Appendix · Reference · 5 minutes

Formula cheat sheet: math symbols in everyday language

For looking things up: here you learn to read formulas. Handy for the math corners, but not required.

Why formulas at all?

The neuron chapter said: “First input times first weight, plus second input times second weight, plus bias.” Clear enough, but with ten inputs it turns into a tapeworm. Formulas are shorthand, like “BRB” instead of “be right back”. They explain nothing new; they just save space.

This chapter is a cheat sheet. You don't have to memorize anything. Just come back whenever a symbol in a math corner looks strange.

A letter is a name for a number

“x is 2” means: the number 2 currently goes by the name x. In another example x can be a different number, like a blank in a form.

The multiplication sign likes to hide in formulas: 3 × x, 3⋅x3\cdot x and 3x3x all mean the same thing. With x = 2 you get 6. The = means “has the same value as”, and ≈ means “approximately”, for example after rounding.

A function is a calculation rule with a name

f(x)=3xf(x)=3x means: the rule called f takes a number and triples it. f(2)f(2) means: “apply the rule to 2.” Result: 6.

So the parentheses are not a multiplication sign here! If you program, you know this: triple(2) returns 6. Mathematicians are just lazy writers and call the function f.

With nesting like g(f(2))g(f(2)), you work from the inside out: first apply f to 2, then g to the result. This is exactly how the layers of a network will fit together later.

Small numbers up and down

Notation Meaning Example
x2x_2 The second element of a collection In [4,7,9] the second element is 7
x2x^2 Multiply x by itself For x=3, x²=9
xt+1x_{t+1} The element one place after position t After position 3 comes position 4
x<tx_{<t} All elements before position t Before position 3 are positions 1 and 2

The small number at the bottom is called an index, a kind of house number. A common trap: in math you usually count from 1, Python counts from 0. With code we always say which one we mean.

A hat on a letter, as in y^\hat y, is read “y-hat”. In this book it almost always means: prediction. yy without a hat is then the target. The hat is a name tag, not a calculation.

A sum is repeated addition

The list [2,4,6] has the sum 2+4+6=12. In shorthand:

∑i=13xi=x1+x2+x3.\sum_{i=1}^{3}x_i=x_1+x_2+x_3.

Read the formula: add up the list elements while the number i runs from 1 to 3. The big Σ is called sigma, a Greek S, as in sum. Below it is where it starts, above it is where it stops.

The i is a running variable, a counter that takes the values 1, 2 and 3 in turn. Whether it is called i or j doesn't matter. The main thing is that it has the same name everywhere.

A product is repeated multiplication

The same list multiplied: 2×4×6=48. For this there is the big Π, a Greek P as in product:

∏i=13xi=x1⋅x2⋅x3.\prod_{i=1}^{3}x_i=x_1\cdot x_2\cdot x_3.

Sum and product look alike but are different instructions. Later we will meet products of probabilities. Then we will first write out a few factors before the shorthand comes.

Fractions, mean and square root

A fraction bar means “divided by”. The sum divided by the count gives the average, technically the mean. For 2, 4 and 6: (2+4+6)/3=4.

The square root √ asks: which number times itself gives this? √9 is 3, because 3×3=9. √2 is about 1.414. In this book, roots are mainly used to bring numbers to a manageable size.

The absolute value is the distance from zero; the sign gets thrown out: 4 and −4 both have absolute value 4. Handy when you only care about “how big” and not “which direction”.

Greek letters: just names too

η (“eta”) will stand for the learning rate later, ε (“epsilon”) usually for a tiny helper number. Sounds important, but it is just naming. The letters themselves can't do anything.

Careful: the same symbol can mean different things in different texts. That is why a good formula always comes with an explanation. In this book it sits right next to it.

What is not here

Derivatives, the exponential function and the logarithm are not on this sheet. The book explains them exactly where they are needed, with numbers first.

The most important trick to finish: when a formula looks intimidating, simply plug the numbers from the example in for the letters. Most of the time it immediately becomes harmless.