Transposing a formula means rearranging it so a different letter stands alone. It's one skill, and you'll use it in every topic from here on: geometry, matrices, calculus, statistics and the formulas inside AI models. This subcourse teaches every kind, one lesson at a time. It starts with the method behind all of them: see how the formula was built around the letter you want, then take it apart in reverse order, the way you unwrap a parcel.
What you'll be able to do
Trace how a formula is built around a letter, layer by layer, and name the opposite of each layer
Make a letter the subject by undoing its layers in reverse order, even with a minus sign in front, the letter in a denominator, or the letter inside brackets
State the conditions a rearranged formula needs, such as a divisor that can't be 0
Check a rearrangement three ways: numbers put back in, a round trip in Python, and units
Run a model's formulas backward: an input from a prediction, and a real value from a scaled one
Quick check
Have a guess before you start. In y = 3(x − 2)/4 + 5, which step happens to x last?
Multiplying by 3
Dividing by 4
Adding 5
Taking 2 away
Show the answer
Adding 5
Follow x = 10 through: take 2 (8), times 3 (24), divide by 4 (6), add 5 (11). Adding 5 is the last step, so it's the first one to undo.
The math: a formula is built in layers
Purpose. One method that makes any letter the subject, however many steps the formula has.
The subject of a formula is the letter standing alone on one side. Transposing (also called rearranging, or changing the subject) means making a different letter the subject. In y = 3(x − 2)/4 + 5, y is the subject.
Follow x through the formula in the order of operations, and you'll see it gets four layers wrapped around it: take away 2, multiply by 3, divide by 4, add 5. Each layer has an opposite that undoes it:
Done to the letter
Undone by
add k
take k away
take k away
add k
multiply by k (k not 0)
divide by k
divide by k
multiply by k
Later lessons add more rows: square roots undo squares, logarithms undo powers, arcsin undoes sin, and an inverse matrix undoes a matrix. The method stays the same.
Quick check
From an earlier lesson: in 3 × (x − 2)², what happens to x first?
It is squared
3 is multiplied by 2
2 is taken away
It is multiplied by 3
Show the answer
2 is taken away
Brackets come first, then powers, then multiplying. So the layers around x are: take 2 away, square, multiply by 3. The order of operations is the order the layers go on.
Watch x = 10 go through the four layers of y = 3(x − 2)/4 + 5, then come back. The top row builds y; the bottom row starts from y = 11 and runs each opposite, right to left.
Try it now
Change the input or the steps and press Use these numbers: the bottom row always runs the opposites in reverse order.
Symbols and formula. The method, in four steps:
Follow the letter you want through the formula and list its layers in order.
Write the opposite of each layer.
Apply the opposites to the other side, last layer first.
Check, and write down any value the letter can't take.
In plain words: whatever was done to the letter last is undone first, on both sides.
Quick check
A rectangle's perimeter is P = 2(l + w). What is w?
w = P − 2l
w = 2P − l
w = P/2 − l
w = (P − l)/2
Show the answer
w = P/2 − l
w has l added, then the bracket is doubled. Undo in reverse: halve P, then take l away. With P = 20 and l = 6, w = 10 − 6 = 4.
Three shapes that catch people out.
A minus in front of the letter. A ball thrown upward at u meters per second has speed v = u − gt after t seconds. Move the gt term to the side where it becomes positive: add gt to both sides, giving v + gt = u, then take v away, giving gt = u − v, then divide by g: t = (u − v)/g.
The letter in a denominator. Current is I = V/R. Multiply both sides by R to bring it up (IR = V), then divide by I: R = V/I. The condition: I can't be 0.
The letter inside brackets. With simple interest, A = P(1 + rt). Divide by P, take 1 away, divide by t: r = (A/P − 1)/t. The conditions: P and t can't be 0.
Every condition comes from a division you did along the way. Dividing by 0 has no answer, so each divisor must not be 0.
In your own words
In your own words: why is the last thing done to a letter the first thing you undo?
Write a sentence or two, then compare it with a good answer in the lesson.
In Python: write the opposite, then test it with a round trip
Purpose. Code can't tell you a rearrangement is right, but it can catch one that's wrong in a second.
Write the formula and its rearrangement as two functions. Going forward and then back should land exactly where you started. Try several inputs, including a negative and a fraction: one lucky input can hide a slip, but four rarely do.
It runs right here in your browser, with nothing to install.
Each row ends where it began: 10, −3, 0.5 and 100 come back (as 10.0, −3.0, 0.5 and 100.0, since dividing gives decimals).
Worked example
Worked example: speed and time, with a condition
v = u − gt rearranged for t, with the condition g ≠ 0 written into the code. To keep the numbers whole, g is rounded to 10 meters per second each second.
defspeed(u, g, t):
return u - g * t
deftime_for(v, u, g):
if g == 0:
returnNonereturn (u - v) / g
print(speed(30, 10, 2), time_for(10, 30, 10))
print(time_for(speed(30, 10, 1.5), 30, 10), time_for(10, 30, 0))
In the lesson you can change this and run it.
A ball thrown up at 30 meters per second slows to 10 after 2 seconds, and time_for turns 10 back into 2.0. The round trip with t = 1.5 returns 1.5. The last call has g = 0: with nothing slowing the ball, its speed never changes, so no time gives speed 10. The function returns None instead of crashing on a division by 0. That's the condition, written as code.
Quick check
What does this print?
defx_of(y):
return4 * y - 5 / 3 + 2print(x_of(11))
10.0
15.0
44.333333333333336
42.333333333333336
Show the answer
44.333333333333336
Without brackets, Python works out 4 × 11 = 44 and 5 ÷ 3 separately, then 44 − 1.67 + 2. The brackets in 4 * (y - 5) / 3 + 2 keep the layers together and give 10.0.
Quick check
Which test gives you the most confidence in x_of?
print(y_of(10)) and print(y_of(-3))
print(x_of(11)), checked by eye
A round trip for x = 10 only
Round trips for x = 10, −3 and 0.5
Show the answer
Round trips for x = 10, −3 and 0.5
Three inputs, including a negative and a fraction, each have to land back where they started. A slip would have to fool all three.
Drill
Fix the opposites
width(P, l) should undo P = 2(l + w), and time_for(v, u, g) should undo v = u − gt. Each has one slip. Fix them so the round trips come back.
defperimeter(l, w):
return2 * (l + w)
defwidth(P, l):
return P - l / 2defspeed(u, g, t):
return u - g * t
deftime_for(v, u, g):
return (v - u) / g
print(width(perimeter(9, 8), 9), time_for(speed(30, 10, 2), 30, 10))
In the lesson, your code is checked as you write it.
In your own words
Why test a rearrangement with several inputs, including a negative and a fraction, instead of one?
Write a sentence or two, then compare it with a good answer in the lesson.
In AI and ML: running a model backward
Purpose. A trained model answers "what output for this input?" Rearranging answers the backward question: "what input gives this output?"
Models are usually trained on scaled inputs: each input has an average taken away and is divided by a typical spread, so every input sits near 0. You'll meet this properly in Describing data. A prediction then passes through two formulas, and running it backward means peeling both.
The trail club predicts how many people sign up for a walk from the forecast temperature t in °C. Its model scales first, s = (t − 18)/6, then predicts signups = 4s + 20. Which temperature gives 26 sign-ups? Peel the model first, s = (26 − 20)/4 = 1.5, then the scaling: t = 6 × 1.5 + 18 = 27.
A model was trained on scaled inputs s = (x − 50)/10 and predicts y = 3s + 7. Which x gives y = 22?
55
0
5
100
Show the answer
100
Peel the model: s = (22 − 7)/3 = 5. Then peel the scaling: x = 10 × 5 + 50 = 100. Check: s = (100 − 50)/10 = 5, and 3 × 5 + 7 = 22.
A training schedule backward. Many training runs warm up: the learning rate (how big each training step is) starts at 0 and grows in a straight line to its top value over the first W steps, as lr = lr_max × step / W. Transposed for the step, it's step = lr × W / lr_max, which answers "when does the rate reach this value?"
step = 0.0006 × 2000 ÷ 0.001 = 1,200, and running 1,200 forward gives the rate back: 0.0006. Dividing makes the step a float, so it prints with .0.
Drill
A hike time, backward
The club's second model scales distance d (km) as s = (d − 8)/3 and predicts minutes = 25s + 160. Write dist_for(m), the distance for a hike of m minutes, by peeling both layers.
31Formulas with fractions: clear them firstFreeClearing denominators, cross-multiplying, a letter in the bottom, and reciprocal formulas like 1/R = 1/R₁ + 1/R₂.35 min
37Inverse functions, lines and scalingFreeUndoing a function by making x the subject, domains that allow it, line forms, and unscaling predictions.40 min
38Sequences and sums: find n, a, d and rFreeEvery letter of the arithmetic and geometric formulas as the subject, and an average's window from its decay.40 min
40Review: rearrange anything (algebra)FreeBroken rearrangements to fix, mixed practice from the whole algebra block, a strategy chart, and its formula sheet.35 min
41Coordinates and distanceFreePoints as (x, y), Pythagoras, distance in any number of coordinates, and nearest neighbors.42 min
42Angles, degrees and radiansFreeMeasuring a turn, converting units, arcs, and the angle between two arrows.36 min
43Sine and cosineFreeAcross and up: right triangles, the unit circle, and directions and rotations.42 min
44Waves: height, speed and shiftFreeAmplitude, period and phase, sampling a wave, and position codes in transformers.37 min
68Vector equations: rearranging with arrowsFreeSolving for a vector or a scale, recovering a gradient from two weight snapshots, and an angle from a dot product.40 min
87Counting: choices, orders and groupsFreeThe counting principle, factorials, ordered picks and groups, and why attention's cost grows with the square of the length.43 min
88Probability: from counts to chancesFreeEqually likely outcomes, the complement, distributions, seeded simulation, and a next-word model.43 min
89Combining events: and, or, independentFreeThe or rule, independence, probability trees, drawing with and without replacement, and chains of steps.42 min
100Maximum likelihoodFreeLikelihoods as products, log-likelihoods as sums, grid search, underflow, and the negative log-likelihood loss.45 min
101Linear regression: the best lineFreeResiduals, least squares by formula, three roads to one line, the matrix form, and train versus test error.45 min
109One neuron, start to finishFreeWeighted sum, activation, loss, slopes and update, by hand and in code, and what one straight line can and can't split.45 min
111Training a small networkFreeThe backward pass in matrix form, gradient checks, a full training loop, and reading loss curves.45 min
112The same network in PyTorchFreenn.Sequential with the NumPy weights loaded, the same loss and slopes, then SGD and mini-batches.45 min
113Attention as matrix mathFreeScaled dot-product scores, the causal mask, a row-by-row softmax, and blending value vectors.45 min
114Residual connections and layer normFreeAdding the input back and why its slope keeps learning alive, layer norm by hand, and add and norm.40 min
115A transformer block, start to finishFreeA sentence through embeddings, attention, add and norm, a small network and next-word scores, every shape named.45 min
117Final test: transpose any formulaFreeSlips to fix from every topic, mixed practice of every kind of rearranging, the strategy chart and the full sheet.45 min
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.
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.
See the course →
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