Index Ai Academy
Foundation · Transposition of formulas

Final test: transpose any formula

Slips to fix from every topic, mixed practice of every kind of rearranging, the strategy chart and the full sheet.

About 45 minutes · Free lesson

What it covers6

Why it matters

This is the last lesson of the transposition subcourse, and its final test. Every kind of rearranging you've met comes back, mixed: peeling layers, clearing fractions, collecting a letter that appears twice, roots with ±, logs, flipped inequalities, angles, vectors, matrices, slopes, chances, sample sizes and the formulas that size a model. First you fix slips from every block. Then you practice every kind. Last, you collect the master strategy chart and the sheet.

What you'll be able to do

  • Spot and fix the slips of every block: a lost ±, a missing flip, a principal value taken as the only angle, a vector divided, an inverse on the wrong side, a conditional turned round, a count not rounded up
  • Choose the right move for any formula from where the letter sits and how many times it appears
  • Rearrange formulas from algebra, trig, vectors, matrices, calculus, probability, statistics and model planning, with their conditions
  • Check every rearrangement with numbers put back in, a round trip in code, and units
  • Use the master strategy chart and the formula sheet for the whole subcourse
Quick check
Have a guess before you start. Make x the subject of y = 3e^(2x) − 4.
  1. x = ln(y + 4)/6
  2. x = ln(y/3 + 4)/2
  3. x = ln((y + 4)/3)/2
  4. x = (ln y + 4)/6
Show the answer

x = ln((y + 4)/3)/2

The layers on x are × 2, e to the power, × 3 and − 4. Undo them in reverse: + 4, ÷ 3, ln, ÷ 2. Check with x = 0: y = 3 − 4 = −1, and ln((−1 + 4)/3)/2 = ln 1/2 = 0. The condition: y > −4, so the log has a positive number.

Find the slip

Purpose. Catch the slips of every block of the subcourse before they reach your answers. Each kind has a quick check:

  • Put numbers back in. A rearranged formula must give back the numbers you started with.
  • Count the answers. A positive number has two square roots, and most sines belong to two angles from 0° to 180°.
  • Check the domain. Probabilities stay from 0 to 1, logs need positive numbers, and divisors can't be 0.
  • Check the shape. A matrix product has a shape, and you can't divide by a vector.
  • Try a number. For an inequality, try a value on each side of your answer.

Below are thirteen worked lines from the algebra block and from trig, vectors and matrices. Each comment says what the line should give. Seven have a slip.

Try it now

How the checks catch them. Put numbers in: legs 3 and 4 give a hypotenuse of 5, not 7. Count the answers: 2x² = 18 has x = 3 and x = −3, but a square root gives only 3. Look for the other angle: 150° has the same sine as 30°. Picture the point: (−3, −3) is down and to the left, but atan(1) = 45° points up and to the right. Divide a vector entry by entry and the ratios rarely agree, so no single k exists. Multiply back: X @ A isn't B when the inverse sits on the wrong side. And try a number: x = 0 fits x ≥ −5 but fails −2x ≥ 10. Run the next check in your head.

Quick check
What does this print?
import math

x, y = -3, -3
print(round(math.degrees(math.atan(y / x))), round(math.degrees(math.atan2(y, x))))
  1. -135 -135
  2. 45 -135
  3. 45 45
  4. -45 135
Show the answer

45 -135

y / x is 1, and atan(1) is 45°: atan can't tell (−3, −3) from (3, 3). atan2 sees both signs, so it gives the true direction, −135°.

The later blocks. Slips in calculus, probability, statistics and model planning hide inside longer formulas, and most of them still give a believable number. Thirteen more lines, and eight have a slip. Look for a lost ±, a slope set to 0 wrongly, a conditional the wrong way round, a chance outside 0 to 1, a count not rounded up, the wrong log, a missing bias and a root of the wrong thing.

How these were caught. Put x = −2 into 3x²: it's 12 too. Differentiate C(x) = ax² − bx + c and the 2 in 2ax is there to keep. Read a conditional aloud: P(A and B) ÷ P(B) is "A, given B". A chance of −0.3 is outside 0 to 1, so a sign went wrong. Work out the margin for 1,067: 0.030002, just over 0.03, so round up. 2³ = 8 choices carry 3 bits. And 64 × 64 + 64 = 4,160, so the layer has 64 outputs. The lines left alone are right: Newton's step, the constant C = 4, total probability, the surprise and the compute plan.

Quick check
f(x) = x³ − 12x + 1. At which x is its slope 0?
  1. x = 4
  2. x = 12 and x = −12
  3. x = 2 and x = −2
  4. x = 2 only
Show the answer

x = 2 and x = −2

f′(x) = 3x² − 12. Set it to 0: x² = 4, so x = ±2. Both are turning points: f(2) = −15 and f(−2) = 17.

Drill

The inverse on the wrong side

solve_right(A, B) should return the X with X @ A == B, but its check prints False. Find the one slip and fix it.

import numpy as np

A = np.array([[2.0, 1.0], [1.0, 1.0]])
B = np.array([[7.0, 4.0], [5.0, 3.0]])

def solve_right(A, B):
    return np.linalg.inv(A) @ B

X = solve_right(A, B)
print(X)
print(np.allclose(X @ A, B))
In the lesson, your code is checked as you write it.
In your own words
Which slip in this part are you most likely to make, and which quick check would catch it?

Write a sentence or two, then compare it with a good answer in the lesson.

Mixed practice

Purpose. Practice every kind of rearranging the subcourse teaches, mixed, so you choose the move yourself. There are three ladders. Each problem says "rearrange, then put the numbers in", and the number tests the rearrangement.

Before you start each one, answer the first question of the strategy chart: where is the letter, and how many times does it appear? Once means peeling layers. Twice means collecting and factoring. Squared and plain means a quadratic. If one stops you, the steps show the way.

Quick check
The next ladder starts with letters in powers. You need t from 500 × 0.8ᵗ = 200. Which move frees t?
  1. Take the t-th root of 200
  2. Square both sides first
  3. Divide 200 by 0.8 first
  4. Divide by 500, then take logs
Show the answer

Divide by 500, then take logs

0.8ᵗ = 0.4, so t ln 0.8 = ln 0.4, and t = ln 0.4/ln 0.8 ≈ 4.1. Logs bring a power down to where you can divide.

The later blocks. The last ladder runs from trig to model planning. When an answer is a vector or a matrix, the item asks for one entry of it. Angles are in degrees unless the item says otherwise.

The master strategy chart. Every rearrangement in the subcourse follows the same six steps:

  1. Where is the letter, and how many times does it appear?
  2. Twice or more: collect its terms on one side and factor it out. Squared and plain: make it a quadratic.
  3. Once: list the layers around it, in the order they were put on.
  4. Undo them in reverse, each with its opposite.
  5. Write the conditions: zero divisors, ±, log domains, a flip.
  6. Check: numbers back in, a round trip in code, and units.

Three more rules finish the chart:

  • A matrix is undone by its inverse, on the same side it multiplied from.
  • A trig function is undone by its inverse, which gives one principal angle. Look for the others.
  • An inequality takes the same moves. Flip the sign when you multiply or divide by a negative, take reciprocals of positive sides, or divide by the log of a base below 1.

Watch steps 3 to 6 run on a formula with five layers.

The opposites for step 4.

Done to the letterUndone byWatch for
add k, multiply by ktake k away, divide by kk ≠ 0 to divide
square, any even power± roottwo answers
eˣ, bˣln, log ÷ log bpositive numbers only
sin, cos, tanarcsin, arccos, arctan; atan2 for a pointone principal angle
sigmoidlogit0 < p < 1
a matrix AA⁻¹, same sidedet A ≠ 0

In plain words: find the letter, peel off what was done to it from the outside in, and write down what must be true for the answer to exist.

Worked example

Worked example: one plan, three blocks, three round trips

Three planning questions from three blocks. Each answer is checked by putting it back into the formula it came from.

import math

# Statistics: test-set size for a margin of 0.03, z = 1.96, p = 0.5
n = math.ceil((1.96 * 0.5 / 0.03) ** 2)
print(n, round(1.96 * 0.5 / math.sqrt(n), 4))

# Model planning: outputs of a layer with 64 inputs and 4,160 parameters
out = 4160 // (64 + 1)
print(out, 64 * out + out)

# Logs and a flip: steps until lr = 0.05 * 0.95 ** t drops below 0.005
t = math.ceil(math.log(0.005 / 0.05) / math.log(0.95))
print(t, 0.05 * 0.95 ** (t - 1) > 0.005, 0.05 * 0.95 ** t < 0.005)
It runs right here in your browser, with nothing to install.

The test set needs 1,068 examples, rounded up from 1,067.1, and its margin prints as 0.03. The layer has 64 outputs, and 64 × 64 + 64 gives back 4,160, so the bias is counted. For the learning rate, dividing by ln 0.95 < 0 flips the sign: t > 44.9, so t = 45. The last line checks both sides: the step before is still above the target, and step 45 is below it.

Quick check
What does this print?
import math

z = math.log(0.9 / 0.1)
p = 1 / (1 + math.exp(-z))
print(round(z, 3), round(p, 3))
  1. 0.9 2.197
  2. 2.197 0.1
  3. 9.0 0.9
  4. 2.197 0.9
Show the answer

2.197 0.9

The logit of 0.9 is ln 9 ≈ 2.197. The sigmoid of that score gives 0.9 back: a round trip through an inverse pair.

Drill

The plan comes up short

n_for_margin(z, sigma, margin) should give the smallest whole n with z·σ/√n ≤ margin, but its answers miss the margin. Find the one slip and fix it.

import math

def n_for_margin(z, sigma, margin):
    return round((z * sigma / margin) ** 2)

print(n_for_margin(1.96, 0.5, 0.03), n_for_margin(1, 0.4, 0.015))
In the lesson, your code is checked as you write it.
In your own words
Pick a ladder problem that made you stop. Which step of the master strategy chart told you what to do?

Write a sentence or two, then compare it with a good answer in the lesson.

The formula sheet

Purpose. The rearranged formulas of the second half of the subcourse, each with its condition and its line of Python. The algebra half has its own sheet, in lesson 40. Trig and vectors:

lessonformularearrangedconditionin Python
46sin θ = o/hθ = arcsin(o/h), h = o/sin θ−1 ≤ o/h ≤ 1; one angle, −90° to 90°; sin θ ≠ 0 for hmath.asin(o / h)
46x = r cos θ, y = r sin θr = √(x² + y²), θ = atan2(y, x)atan(y/x) fails when x < 0math.atan2(y, x)
46y = A sin(ωt + φ)t = (arcsin(y/A) − φ)/ω−A ≤ y ≤ A; A, ω ≠ 0; add the period if t < 0(math.asin(y / A) - phi) / omega
68w_new = w − ηgg = (w − w_new)/ηη ≠ 0; never divide by a vector(w - w_new) / lr
68a·b = ‖a‖‖b‖cos θθ = arccos(a·b/(‖a‖‖b‖))no zero vector; θ from 0 to πnp.arccos(np.clip(c, -1, 1))
68v = βv + g, steadyv = g/(1 − β), g = (1 − β)vβ ≠ 1g / (1 - beta)
Quick check
From the sheet: cos θ = a·b/(‖a‖‖b‖) comes out as 1.0000000002 in code, for two vectors pointing the same way. What do you do?
  1. Clip it to 1 before arccos
  2. Use arcsin in its place
  3. Report that no angle exists
  4. Divide by ‖a‖ once more
Show the answer

Clip it to 1 before arccos

Rounding pushed the value a hair past 1, where arccos has no answer. The true value is 1, so clip to [−1, 1] and get θ = 0.

Matrices and calculus:

lessonformularearrangedconditionin Python
69AX = B; XA = BX = A⁻¹B; X = BA⁻¹A square, det A ≠ 0; the inverse on A's sidenp.linalg.solve(A, B); np.linalg.solve(A.T, B.T).T
69y = Wx + bx = W⁻¹(y − b)W square and invertiblenp.linalg.solve(W, y - b)
69XᵀXw = Xᵀyw = (XᵀX)⁻¹XᵀyXᵀX invertiblenp.linalg.solve(X.T @ X, X.T @ y)
86C′(x) = 2ax − b = 0x = b/(2a)a > 0 for a lowest pointb / (2 * a)
86f(x + h) ≈ f(x) + f′(x)hx_new = x − f(x)/f′(x)f′(x) ≠ 0x - f(x) / df(x)
86F(x) = x² + C, F(x₀) = y₀C = y₀ − x₀²one point fixes Cy0 - x0 ** 2
Quick check
Use the sheet's Newton's step for f(x) = x² − 2, starting at x = 1. What is the new x?
  1. 2
  2. 0.5
  3. 1.5
  4. −1
Show the answer

1.5

f(1) = −1 and f′(1) = 2, so x_new = 1 − (−1)/2 = 1.5. √2 ≈ 1.414, so one step moved closer.

Probability and statistics:

lessonformularearrangedconditionin Python
96P(A and B) = P(A) × P(B given A)P(B given A) = P(A and B)/P(A)P(A) > 0; the answer from 0 to 1p_and / p_a
96P(A given B) = P(B given A) × P(A)/P(B)P(A) = P(A given B) × P(B)/P(B given A)P(B given A) > 0; the answer from 0 to 1a_given_b * p_b / b_given_a
96z = (x − μ)/σx = μ + zσσ > 0mu + z * sigma
108SE = σ/√n; m = zσ/√nn = (σ/SE)²; n = (zσ/m)²round n upmath.ceil((z * sigma / m) ** 2)
108p = σ(wx + b)x = (ln(p/(1 − p)) − b)/w0 < p < 1; w ≠ 0(math.log(p / (1 - p)) - b) / w
108s = −log₂ p; L = −ln pp = 2^(−s); p = e^(−L)bits use log₂, nats use ln2 ** -s, math.exp(-L)
Quick check
A model's cross-entropy loss on one example is 0.69, measured with ln. About what probability did it give the right answer?
  1. About 1.99
  2. About 0.31
  3. About 0.5
  4. About 0.62
Show the answer

About 0.5

L = −ln p gives p = e^(−L) = e^(−0.69) ≈ 0.50. A loss of about 0.69 means a coin flip on the right answer.

Model planning, and the inverse pairs worth keeping:

lessonformularearrangedconditionin Python
116P = n_in·n_out + n_outn_out = P/(n_in + 1)count the bias; a whole numberP // (n_in + 1)
116C ≈ 6ND, D ≈ 20NN = √(C/120), D = C/(6N)rules of thumb, not lawsmath.sqrt(C / 120)
116s = q·k/√dd = (q·k/s)²s ≠ 0, same sign as q·k; d a whole number(qk / s) ** 2
30y = ax + bx = (y − b)/aa ≠ 0(y - b) / a
33y = xⁿx = ±y^(1/n) for even n, y^(1/n) for odd neven n: y ≥ 0; in code, root the size of a negative yy ** (1 / n)
35y = eˣ; p = 1/(1 + e^(−z))x = ln y; z = ln(p/(1 − p))y > 0; 0 < p < 1math.log(p / (1 - p))
46y = sin xx = arcsin y−1 ≤ y ≤ 1; one principal angle, −90° to 90°math.asin(y)
69y = Axx = A⁻¹ydet A ≠ 0; the inverse on A's sidenp.linalg.solve(A, y)
36ax < c, a < 0x > c/athe sign flipsc / a
In your own words
Which row of the sheet would you most want beside you on an AI and ML project, and why?

Write a sentence or two, then compare it with a good answer in the lesson.

Goes deeper in

Practice what you just read

  • 1 code example you can edit and run
  • a practice exercise that checks your code
  • a 5-question quiz
  • 9 review cards for spaced repetition

Try a quiz question

Solve XA = B for the matrix X, with A invertible.

  1. X = BA⁻¹
  2. X = A⁻¹B
  3. X = B/A
  4. X = B − A

Answer it at the end of the lesson to see if you're right, and why.

Before this lesson

Keep learning

Where this lesson leads.

575 lessons in thirteen phases. 176 are free without an account, and a free account opens the rest. See every lesson.

Foundation · about 96 hours of study

Foundation math

From whole numbers to the math inside a neural network: each idea by hand, in Python, and in AI 118 lessons All free
  1. Numbers and place value FreeWhat a digit's place is worth, the number line, and Python as a calculator that never tires.36 min
  2. Multiplying and dividing: groups FreeEqual groups, quotient and remainder, and cutting training data into batches.35 min
  3. Order of operations, and names for numbers FreeBrackets, powers, then multiply and divide, then add and subtract; variables hold numbers.36 min
  4. Numbers below zero FreeThe number line through zero, sign rules, distance from zero, and an error's direction and size.37 min
  5. Fractions: equal parts, equal fractions, adding FreePieces of a whole, equal fractions, and re-cutting to add; accuracy as a fraction.45 min
  6. Multiplying and dividing fractions FreeA share of a share, dividing by flipping, and why chances in a row get small.35 min
  7. Decimals and rounding FreeFractions in place value, rounding, and why 0.1 + 0.2 isn't exactly 0.3.36 min
  8. Percentages FreePer hundred, percent change, percentage points, and the accuracy and error rates of models.35 min
  9. Ratios, rates and proportion FreeSharing in a ratio, rates per unit, scaling, and splitting data 80/10/10.35 min
  10. Powers and roots FreeRepeated multiplying, the laws of exponents, square roots, and squared error.43 min
  11. Very big and very small numbers FreePowers of ten, e-notation like 3e-4, orders of magnitude, and a model's size in memory.36 min
  12. Bits, bytes and floats: how numbers are stored FreeBase 2, what n bits can hold, a float as sign, power and digits, and a tensor's memory.35 min
  13. Review: find the slip (numbers) FreeBroken calculations to fix, mixed practice from the whole module, and its formula sheet.34 min
  14. Letters for numbers FreeVariables, terms and like terms, substitution, and a model's formula as a Python function.41 min
  15. Expanding and factoring FreeBrackets as areas, pulling out common factors, and a squared error expanded into a bowl.41 min
  16. Solving equations: keep the balance FreeThe same move on both sides, undoing steps in reverse, and running a model's formula backward.41 min
  17. Rearranging a formula FreeMaking any letter the subject, round-trip checks, and planning a training run.36 min
  18. Inequalities and true-or-false FreeRanges, flipping the sign, if and elif, and the thresholds, clips and ReLU inside a model.42 min
  19. Functions: a rule from input to output Freef(x) notation, tables and graphs, domain and range, loops over lists, and loss as a function.42 min
  20. Chaining and undoing functions Freeg(f(x)), inverses that undo, scaling and unscaling, and a network as a chain.42 min
  21. Straight lines: slope and intercept FreeRise over run, the line through two points, and a model's weight and bias as slope and intercept.42 min
  22. Two equations, two unknowns FreeSubstitution and elimination, where lines cross, and why models are fitted, not solved.42 min
  23. Quadratics: bowls and their lowest point FreeRoots by factoring and by formula, the discriminant, the vertex, and the best weight of a model.42 min
  24. Exponentials: growth and decay FreeThe same factor each step, the number e, and decaying learning rates.43 min
  25. Logarithms: the power question FreeTo what power?, the laws of logs, and adding log-probabilities instead of multiplying.45 min
  26. Sequences and Σ FreeArithmetic and geometric sequences, Σ as a loop that adds, and mean squared error.40 min
  27. Weighted and moving averages FreeWeights that add to 1, a window average, the exponential moving average, and smoothing a loss curve.35 min
  28. Sets, and reading the symbols FreeSets, union and intersection, ℝⁿ and f : ℝⁿ → ℝᵐ, and reading a paper's first equation.41 min
  29. Review: find the slip (algebra) FreeBroken algebra and code to fix, mixed practice from the whole module, and its formula sheet.34 min
  30. Transposing step by step: undo in reverse order FreeA formula's layers, the opposite of each, peeling from the outside in, conditions, and round-trip checks.35 min
  31. Formulas with fractions: clear them first FreeClearing denominators, cross-multiplying, a letter in the bottom, and reciprocal formulas like 1/R = 1/R₁ + 1/R₂.35 min
  32. When the letter appears twice: collect and factor FreeGathering the letter on one side, factoring it out, dividing by the bracket, and rearranging precision and F1.35 min
  33. Squares, roots and powers FreeSquare roots with ±, squaring to undo a root, cube and nth roots, and the √d inside attention.40 min
  34. When the letter is squared and plain: quadratics FreeRearranging into ax² + bx + c = 0, the formula, completing the square, and choosing the root that fits.35 min
  35. Letters in the power: exponentials and logarithms FreeTaking logs to bring a power down, exponentiating to free a letter, and the logit that undoes the sigmoid.40 min
  36. Rearranging inequalities: when the sign flips FreeThe four moves on an inequality, negatives and reciprocals that flip it, logs below 1, and sample sizes.35 min
  37. Inverse functions, lines and scaling FreeUndoing a function by making x the subject, domains that allow it, line forms, and unscaling predictions.40 min
  38. Sequences and sums: find n, a, d and r FreeEvery letter of the arithmetic and geometric formulas as the subject, and an average's window from its decay.40 min
  39. Combining formulas: substitute and eliminate FreePutting one formula inside another to remove a letter, and sizing a training run from a time or money budget.35 min
  40. Review: rearrange anything (algebra) FreeBroken rearrangements to fix, mixed practice from the whole algebra block, a strategy chart, and its formula sheet.35 min
  41. Coordinates and distance FreePoints as (x, y), Pythagoras, distance in any number of coordinates, and nearest neighbors.42 min
  42. Angles, degrees and radians FreeMeasuring a turn, converting units, arcs, and the angle between two arrows.36 min
  43. Sine and cosine FreeAcross and up: right triangles, the unit circle, and directions and rotations.42 min
  44. Waves: height, speed and shift FreeAmplitude, period and phase, sampling a wave, and position codes in transformers.37 min
  45. Review: find the slip (shapes and waves) FreeBroken geometry and code to fix, mixed practice from the module, and its formula sheet.29 min
  46. Angles, triangles and waves: rearranging with sin, cos and tan FreeSides and angles from SOH CAH TOA, principal values, arcs, polar coordinates, and a wave's time and period.45 min
  47. Vectors: lists of numbers that point FreeA list, a point and an arrow; components, dimension, NumPy arrays, and data as vectors.42 min
  48. Adding and scaling vectors FreeComponent-wise sums, scalar multiples, mixes, and the weight update w − ηg.43 min
  49. Length and distance: norms FreeL2, L1 and max norms, unit vectors, distance, and the norms inside losses and clipping.42 min
  50. The dot product FreeMultiply in pairs and add; a·a as squared length; a @ b; one neuron as a dot product.43 min
  51. Angle, cosine similarity and projection FreeDirection without length, perpendicular vectors, shadows, and search by meaning.45 min
  52. Perpendicular directions: bases and coordinates FreeOrthonormal directions, coordinates as dot products, rebuilding a vector, and taking a direction out.35 min
  53. Matrices: tables of numbers FreeRows, columns and entries; two-dimensional arrays and slices; a data set as a matrix.41 min
  54. Adding, scaling and transposing matrices FreeEntry-by-entry sums and scalings, the transpose, mean images, and tables turned around.36 min
  55. A matrix times a vector FreeEach row dotted with the vector, the size rule, A @ x, and a layer acting on one example.42 min
  56. Matrix multiplication FreeRow meets column, the size rule, order matters, and a batch through a layer: X W + b.45 min
  57. Identity, diagonal, triangular and symmetric FreeFour patterns and their jobs: rescaling, distance tables, and the causal mask.37 min
  58. Matrices as movements of space FreeStretches, flips, shears and rotations; columns as landing spots; chaining; a layer moving data.42 min
  59. Determinant and inverse FreeThe area factor ad − bc, singular matrices, undoing a matrix, and redundant features.42 min
  60. Solving systems by elimination FreeAugmented matrices, row moves, back-substitution, the three outcomes, and fitting weights.45 min
  61. Independence, span and rank FreeRedundant vectors, span, rank, outer products, and low-rank updates like LoRA.42 min
  62. Eigenvectors: directions that only stretch FreeAv = λv, checking candidates, np.linalg.eig, and the main direction of a data cloud.41 min
  63. SVD and PCA: the important directions first FreeA matrix as pieces by size, the best rank-k copy, compression, and PCA maps of data.45 min
  64. Tensors, shapes and broadcasting FreeAxes and shapes, reshape, axis=, broadcasting, and shapes through a small model.43 min
  65. One-hot vectors and lookup tables: embeddings FreeA one-hot row picks a table's row, a sentence looked up as vectors, and a score for every word.35 min
  66. Sliding dot products: convolution FreeA small pattern slid along a list and over a grid, output sizes, stride and padding, and shared weights.40 min
  67. Review: find the slip (vectors and matrices) FreeShape slips to fix, mixed practice from the module, and its formula sheet with shapes.36 min
  68. Vector equations: rearranging with arrows FreeSolving for a vector or a scale, recovering a gradient from two weight snapshots, and an angle from a dot product.40 min
  69. Matrix equations: multiply by the inverse, on the correct side FreeNo dividing by a matrix: inverses from the left or right, order, transposes, and the normal equations.40 min
  70. Rates of change FreeChange over change, secants, rates from readings with np.diff, and reading a loss curve.41 min
  71. Limits: what a value heads toward FreeApproaching from both sides, holes, corners and jumps, epsilon, and judging activations.37 min
  72. The derivative: slope at a point FreeShrinking secants, f′(x) and dy/dx, Δy ≈ f′Δx, and which way a weight should move.45 min
  73. Derivative rules FreeConstants, powers, multiples, sums, eˣ and ln x, checked numerically, and a squared error's slope.41 min
  74. The product rule and the chain rule FreeProducts and chains of functions, forward then backward, and one neuron's dL/dw.45 min
  75. Lowest points and curvature Freef′ = 0, the second-derivative test, tables, local and global minima, and convex losses.43 min
  76. Standing in for a curve near a point FreeTangent lines, a curvature term, growing error, and why learning rates must be small.37 min
  77. Partial derivatives FreeOne input at a time, ∂, nudging in Python, and the two slopes of a line's loss.41 min
  78. The gradient FreeAll the slopes as a vector, steepest climb and descent, a numerical gradient, and the loss gradient.42 min
  79. Gradient descent FreeStepping against the gradient, the learning rate, a training loop, and fitting a line.45 min
  80. Faster descent: momentum and Adam FreeMomentum and Adam by hand, the bias correction, and three optimizers down one narrow valley.40 min
  81. The chain rule with many paths: backpropagation by hand FreeGraphs, multiply along paths and add across them, gradient checks, and a 2-2-1 network by hand.45 min
  82. Automatic differentiation: how PyTorch finds every slope FreeA tape of steps walked backward, and requires_grad, backward(), .grad, zero_grad() and no_grad().40 min
  83. Jacobians and Hessians FreeSlopes of vector functions, a layer's Jacobian, second partials, and bowls, domes and saddles.42 min
  84. Integrals: adding up thin slices FreeStrip and trapezoid sums, summing undoes differencing, probability as area, and AUC.43 min
  85. Review: find the slip (calculus) FreeCalculus slips to fix, mixed practice from the module, and its formula sheet.36 min
  86. Rearranging in calculus: slopes, steps and constants FreeSetting a slope to zero, Newton's step, the chain rule turned around, constants from a point, and learning rates.45 min
  87. Counting: choices, orders and groups FreeThe counting principle, factorials, ordered picks and groups, and why attention's cost grows with the square of the length.43 min
  88. Probability: from counts to chances FreeEqually likely outcomes, the complement, distributions, seeded simulation, and a next-word model.43 min
  89. Combining events: and, or, independent FreeThe or rule, independence, probability trees, drawing with and without replacement, and chains of steps.42 min
  90. Conditional probability and Bayes' rule FreeConditionals from tables, why P(A | B) isn't P(B | A), Bayes' rule, and precision and recall.45 min
  91. Random variables and distributions FreeUncertain numbers, the probability of a range, sampling by slices, and sampling versus argmax.42 min
  92. Expected value, variance and standard deviation FreeProbability-weighted averages, spread in the data's own units, and a training loss as an expected value.42 min
  93. Bernoulli, binomial, uniform and normal FreeYes-or-no trials, counts of yeses, the 68-95-99.7 rule, z-scores, and an accuracy's error bar.45 min
  94. Two variables at once: covariance and correlation FreeJoint tables and marginals, covariance, correlation, the covariance matrix, and features that carry the same information.45 min
  95. Review: find the slip (probability) FreeProbability slips to fix, mixed practice from the module, and its formula sheet.36 min
  96. Probability formulas: solve for the missing chance FreeConditionals, Bayes' rule for the prior, the or rule, expected values, variance, and z-scores turned around.45 min
  97. Describing data: center, spread and scale FreeMean, median and mode, variance and standard deviation, percentiles, outliers, and standardizing features.42 min
  98. Samples, the law of large numbers and the central limit theorem FreeSamples and populations, the standard error σ/√n, the bell of averages, and error bars on test scores.43 min
  99. Is the difference real? Comparing two models FreePaired differences, a bootstrap interval, what a p-value is and isn't, and why many tries make lucky wins.40 min
  100. Maximum likelihood FreeLikelihoods as products, log-likelihoods as sums, grid search, underflow, and the negative log-likelihood loss.45 min
  101. Linear regression: the best line FreeResiduals, least squares by formula, three roads to one line, the matrix form, and train versus test error.45 min
  102. Logistic regression: a line that answers yes or no FreeThe sigmoid, the log loss, its slope p − y, a training loop, and choosing a threshold.45 min
  103. Scoring a classifier: confusion table, precision, recall, F1 FreeThe four cells, accuracy, precision, recall and F1, and what moving a threshold does to each.35 min
  104. Softmax: scores into probabilities FreeExponentiate and share out, shifting and temperature, the safe softmax, and a classifier's last step.43 min
  105. Surprise, entropy and cross-entropy FreeSurprise in bits, entropy, cross-entropy and KL divergence, perplexity, and a language model's loss.45 min
  106. KL divergence: how far one distribution is from another FreeKL by hand, cross-entropy as entropy plus KL, why it isn't symmetric, and a soft-target loss.35 min
  107. Review: find the slip (statistics and information) FreeStatistics slips to fix, mixed practice from the module, and its formula sheet.38 min
  108. Statistics and information: n, z, logits and bits FreeSample sizes from error bars, inputs from probabilities, logit gaps from softmax, and chances from bits and losses.40 min
  109. One neuron, start to finish FreeWeighted sum, activation, loss, slopes and update, by hand and in code, and what one straight line can and can't split.45 min
  110. A layer and a small network as matrices FreeTwo layers on a batch, the shape of every matrix, adding a hidden unit, and XOR solved.45 min
  111. Training a small network FreeThe backward pass in matrix form, gradient checks, a full training loop, and reading loss curves.45 min
  112. The same network in PyTorch Freenn.Sequential with the NumPy weights loaded, the same loss and slopes, then SGD and mini-batches.45 min
  113. Attention as matrix math FreeScaled dot-product scores, the causal mask, a row-by-row softmax, and blending value vectors.45 min
  114. Residual connections and layer norm FreeAdding the input back and why its slope keeps learning alive, layer norm by hand, and add and norm.40 min
  115. A transformer block, start to finish FreeA sentence through embeddings, attention, add and norm, a small network and next-word scores, every shape named.45 min
  116. Planning a model: rearranging the formulas of a working network FreeLayer widths from parameter counts, sizes from memory and compute, the attention scale, and a training plan.40 min
  117. Final test: transpose any formula FreeSlips to fix from every topic, mixed practice of every kind of rearranging, the strategy chart and the full sheet.45 min
  118. Capstone: a sign reader from the formulas FreeBuild, train and test a trail-sign classifier with NumPy alone, and report its accuracy with an error bar.45 min
Part of a free course 118 lessons

The Foundation Math For Ai & ML: from arithmetic to attention

Learn the math behind AI from arithmetic up: numbers, algebra, vectors and matrices, calculus, probability and statistics, each shown as numbers moving and checked in Python, ending with a network you build and train from the formulas.

Part of a free course 19 lessons

Transposition of Formulas: algebraic manipulation in every topic

Learn to make any letter of any formula the subject: layers undone in reverse order, fractions, a letter that appears twice, powers, roots, quadratics, logs, inequalities, trigonometry, vectors, matrices, calculus, probability, statistics and the formulas inside AI models, each checked in Python.

Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write