This page is a drill . The parent note told you the rule:
θ t + 1 = θ t − η ∇ L ( θ t )
Here θ (theta) is the thing we are tuning (a number, or a list of numbers), L is the loss (the "height on the hill"), ∇ L (read "nabla L", the gradient ) is the arrow pointing uphill, and η (read "eta", the learning rate ) is how big a step we take. One more symbol we lean on below:
θ ∗ — the minimizer
θ ∗ (read "theta-star") is the value of θ where the loss is lowest — the very bottom of the valley. It is what gradient descent is trying to reach . For L ( θ ) = θ 2 the bottom sits at θ ∗ = 0 ; for other losses it sits wherever the curve bottoms out.
If any of those words are shaky, read the parent first. Below we build a matrix of every case this one formula can throw at you, then we work an example for each cell so you never meet a scenario cold.
Every gradient-descent problem lives in one of these boxes. The columns are what makes it tricky ; each row is a concrete example that lands in that box.
#
Case class
What is different here
Example
A
Start on the right of the minimum (θ 0 > θ ∗ ), gradient positive
Step must go left (minus a positive)
Ex 1
B
Start on the left (θ 0 < θ ∗ ), gradient negative
Step must go right (minus a negative)
Ex 2
C
Zero gradient — you start AT a minimum, or at a flat spot
Nothing moves; is it done or stuck?
Ex 3
D
Learning rate too big — overshoot / diverge
Loss grows; sign flips each step
Ex 4
E
2-D parameters — gradient is a vector
Update every coordinate at once
Ex 5
F
Real-world word problem — units and meaning
Translate story → L , ∇ L , step
Ex 6
G
Non-convex — many valleys
Which valley you land in depends on start
Ex 7
H
Exam twist — pick the largest safe η
Use the stability bound η < 2/ λ m a x
Ex 8
Intuition The one picture behind all of it
Every example is a ball on a curve. The gradient is the slope under the ball . The minus sign says "roll the way the slope goes down ." η says "how far to roll before we look again." In the figure below, the amber dot is the start θ 0 = 4 , the amber arrow is the (uphill) gradient, and the white arrow shows the actual step — landing on the white dot, downhill and to the left.
Figure s01 — one downhill step on L ( θ ) = θ 2 : the step (white) points exactly opposite the gradient (amber).
L ( θ ) = θ 2 , start θ 0 = 4 , η = 0.1
Forecast: guess before reading — will θ go up or down, and roughly where does it end?
Compute the gradient. L ( θ ) = θ 2 , so ∇ L ( θ ) = 2 θ .
Why this step? The update needs a slope; the power rule d θ d θ 2 = 2 θ gives it. At θ = 4 this is 2 ( 4 ) = 8 — a positive slope means the curve rises as we move right, so downhill is left . This is exactly the situation drawn in figure s01 above.
First update. θ 1 = 4 − 0.1 × 8 = 4 − 0.8 = 3.2 .
Why this step? Minus a positive number moves us left, toward 0 — exactly the direction of decreasing height.
Repeat. ∇ L ( 3.2 ) = 6.4 ⇒ θ 2 = 3.2 − 0.64 = 2.56 . Then θ 3 = 2.56 − 0.512 = 2.048 .
Why this step? Notice the steps shrink as the slope shrinks — the ball naturally slows near the bottom.
See the pattern. Each step multiplies by 0.8 : θ t = 4 ( 0.8 ) t .
Why this step? θ t + 1 = θ t − 0.1 ( 2 θ t ) = ( 1 − 0.2 ) θ t = 0.8 θ t . This is a geometric shrink toward θ ∗ = 0 .
Verify: θ 3 = 4 ( 0.8 ) 3 = 4 ( 0.512 ) = 2.048 ✓. Loss dropped from 16 to 2.04 8 2 ≈ 4.19 — smaller, good.
Worked example Ex 2 — same
L ( θ ) = θ 2 , but start θ 0 = − 4 , η = 0.1
Forecast: the minus sign is still there — will the step still push us toward zero from the left?
Gradient at the start. ∇ L ( − 4 ) = 2 ( − 4 ) = − 8 .
Why this step? On the left branch the curve falls as we move right, so the slope is negative . Downhill is now to the right .
Update. θ 1 = − 4 − 0.1 ( − 8 ) = − 4 + 0.8 = − 3.2 .
Why this step? Minus a negative becomes plus — the formula automatically flips direction. No special case needed; the sign of ∇ L does the steering.
Confirm the mirror. θ 2 = − 2.56 , θ 3 = − 2.048 , i.e. θ t = − 4 ( 0.8 ) t .
Why this step? This is the exact mirror image of Ex 1 — proving the rule works on both sides without us thinking about which side we're on.
Verify: θ 1 = − 3.2 and ∣ θ 1 ∣ < ∣ θ 0 ∣ ✓ (closer to θ ∗ = 0 ). The single formula handled positive and negative gradients identically.
Worked example Ex 3 — start
θ 0 = 0 on L ( θ ) = θ 2 , and start θ 0 = 0 on L ( θ ) = θ 3
Forecast: if the slope is 0 , what does the update do? Is "nothing moves" always good news?
Bowl case, L = θ 2 . ∇ L ( 0 ) = 2 ( 0 ) = 0 , so θ 1 = 0 − η ( 0 ) = 0 .
Why this step? Zero gradient ⇒ zero step. We are exactly at the bottom θ ∗ = 0 , so staying is correct — this is convergence.
Flat-inflection case, L = θ 3 . ∇ L ( θ ) = 3 θ 2 , so ∇ L ( 0 ) = 0 again — the update also freezes at 0 .
Why this step? But θ 3 has no minimum at 0 (it keeps falling for θ < 0 ). A zero gradient means "flat here", not "lowest here."
Diagnose the difference. Nudge left to θ = − 0.1 : for θ 2 the loss rises (0.01 > 0 ) — true minimum. For θ 3 the loss drops (− 0.001 < 0 ) — a flat inflection point (in 1-D), not a minimum.
Why this step? Gradient descent gets stuck at any zero-gradient point. In one dimension we call such a non-minimum flat spot an inflection point ; the multivariable cousin (flat in some directions, downhill in others) is a saddle point — see Local Minima and Saddle Points . Whether a zero-gradient point is actually good is a separate question from whether descent halts there.
Verify: ∇ L ( 0 ) = 0 for both, so both freeze ✓. Yet L ( − 0.1 ) = 0.01 > 0 for θ 2 but L ( − 0.1 ) = − 0.001 < 0 for θ 3 ✓ — zero gradient ≠ minimum.
L ( θ ) = θ 2 , start θ 0 = 4 , but now η = 1.5
Forecast: we found η = 0.1 shrinks by 0.8 each step. What does η = 1.5 do — faster, or disaster?
One step. ∇ L ( 4 ) = 8 , so θ 1 = 4 − 1.5 ( 8 ) = 4 − 12 = − 8 .
Why this step? We wanted to nudge toward 0 but we flew past it to the other side, and further out than we started (∣ − 8 ∣ > ∣4∣ ).
Next step. ∇ L ( − 8 ) = − 16 , so θ 2 = − 8 − 1.5 ( − 16 ) = − 8 + 24 = 16 .
Why this step? Now we overshoot back the other way, even further. The loss θ 2 went 16 → 64 → 256 — growing .
General multiplier. θ t + 1 = ( 1 − η ⋅ 2 ) θ t = ( 1 − 3 ) θ t = − 2 θ t .
Why this step? The step multiplier is ∣ − 2 ∣ = 2 > 1 , so magnitude doubles each step and the sign flips — the signature of divergence. This runaway zig-zag is drawn in figure s02 below.
Stability threshold. Convergence needs ∣1 − 2 η ∣ < 1 , i.e. 0 < η < 1 . Any η ≥ 1 fails.
Why this step? This is the 1-D version of the parent's bound η < 2/ λ m a x ; here the relevant number is 2 , so η < 1 . (What λ m a x means is unpacked in Ex 8.)
Verify: θ 1 = − 8 , θ 2 = 16 ✓, and ∣1 − 2 ( 1.5 ) ∣ = 2 > 1 ✓ (diverges). Contrast Ex 1's ∣1 − 2 ( 0.1 ) ∣ = 0.8 < 1 (converges).
Figure s02 — η = 1.5 overshoots the valley: each iterate (θ 0 → θ 1 → θ 2 → θ 3 ) lands higher and further out, so the loss explodes.
Worked example Ex 5 — linear regression
y = m x + b , data ( 1 , 3 ) , ( 2 , 5 ) , start m 0 = b 0 = 0 , η = 0.01
Forecast: now θ = ( m , b ) is a pair . Which way does each coordinate move on the first step?
Loss: L ( m , b ) = 2 1 ∑ i ( m x i + b − y i ) 2 , where y ^ i = m x i + b is our prediction.
Derive ∂ L / ∂ m . Treat b as frozen and differentiate one term 2 1 ( m x i + b − y i ) 2 with respect to m . The chain rule says: differentiate the outside ("half of something squared" → "something"), then multiply by the derivative of the inside ( m x i + b − y i ) with respect to m , which is x i . Term-by-term:
∂ m ∂ L = ∑ i ( m x i + b − y i ) ⋅ x i .
Why this step? We need to know how the loss reacts to wiggling m alone ; that is exactly what the partial derivative measures. The inner derivative is x i because only the m x i piece depends on m .
Derive ∂ L / ∂ b . Same trick, differentiating the inside ( m x i + b − y i ) with respect to b , whose derivative is 1 :
∂ b ∂ L = ∑ i ( m x i + b − y i ) ⋅ 1 = ∑ i ( m x i + b − y i ) .
Why this step? b shifts every prediction up or down equally, so its inner derivative is 1 — no x i factor. This is why the two partials differ by an x i weight.
Predictions at start. y ^ 1 = 0 ⋅ 1 + 0 = 0 , y ^ 2 = 0 .
Why this step? The gradient depends on the error y ^ i − y i ; we need the current predictions first.
Errors. e 1 = 0 − 3 = − 3 , e 2 = 0 − 5 = − 5 .
Why this step? Negative errors mean we predict too low — the line should tilt up and lift.
The two partials, evaluated.
∂ m ∂ L = ( − 3 ) ( 1 ) + ( − 5 ) ( 2 ) = − 13 , ∂ b ∂ L = − 3 + ( − 5 ) = − 8 .
Why this step? Both are negative, so both parameters should increase to cut the error.
Update both together.
m 1 = 0 − 0.01 ( − 13 ) = 0.13 , b 1 = 0 − 0.01 ( − 8 ) = 0.08 .
Why this step? Each coordinate uses its own partial. A classic bug is to compute the two partials but then accidentally apply the same one to both parameters (e.g. subtracting ∂ L / ∂ m from both m and b ) — always pair each parameter with its matching partial.
Verify: m 1 = 0.13 , b 1 = 0.08 ✓. Sanity: new prediction y ^ 2 = 0.13 ( 2 ) + 0.08 = 0.34 > 0 — closer to the target 5 than 0 was ✓. See Backpropagation for computing such gradients at scale.
Worked example Ex 6 — a bakery's price setting
A bakery sells θ loaves/day at price shaped so daily loss of profit is L ( θ ) = ( θ − 60 ) 2 dollars², where θ ∗ = 60 is the ideal output. Today they make θ 0 = 90 loaves. Use η = 0.2 loaves per (dollar²/loaf).
Forecast: should tomorrow's output rise or fall, and by how much?
Gradient with units. ∇ L ( θ ) = 2 ( θ − 60 ) , units dollar 2 / loaf . At θ 0 = 90 : 2 ( 30 ) = 60 .
Why this step? Positive gradient ⇒ making more loaves raises profit-loss ⇒ we should make fewer .
Update. θ 1 = 90 − 0.2 × 60 = 90 − 12 = 78 loaves.
Why this step? Units cancel: loaf / ( loaf dollar 2 ) × loaf dollar 2 = loaf — the answer is genuinely in loaves. Good.
Iterate the meaning. θ 2 = 78 − 0.2 ⋅ 2 ( 18 ) = 78 − 7.2 = 70.8 , heading to θ ∗ = 60 .
Why this step? The multiplier is 1 − 0.2 ⋅ 2 = 0.6 , so each day the gap from 60 shrinks by 40% — a business-friendly gradual glide.
Verify: θ 1 = 78 ✓, and ∣78 − 60∣ = 18 < ∣90 − 60∣ = 30 ✓ (closer to optimum). Units are loaves ✓.
L ( θ ) = θ 4 − 4 θ 2 (a double-well), η = 0.05
Forecast: this curve has two bottoms. Two different starts — do they reach the same place?
Gradient: ∇ L ( θ ) = 4 θ 3 − 8 θ = 4 θ ( θ 2 − 2 ) . Zeros at θ = 0 , ± 2 ≈ ± 1.414 . The two minima are at θ ∗ = ± 2 ; θ = 0 is a local max .
Start A: θ 0 = 1 . ∇ L ( 1 ) = 4 ( 1 ) − 8 ( 1 ) = − 4 ; θ 1 = 1 − 0.05 ( − 4 ) = 1.2 .
Why this step? Negative slope pushes us right , toward the positive well + 2 .
Start B: θ 0 = − 1 . ∇ L ( − 1 ) = − 4 + 8 = + 4 ; θ 1 = − 1 − 0.05 ( 4 ) = − 1.2 .
Why this step? Now the slope is positive, pushing us left , toward the negative well − 2 .
Conclusion. Same algorithm, same η , but the basin of attraction decides the outcome — one start converges to + 2 , the other to − 2 (figure s03 traces both paths).
Why this step? In non-convex landscapes gradient descent finds a minimum, not the global one. Compare Convex Optimization (one bowl, no such ambiguity).
Verify: ∇ L ( 2 ) = 4 ( 2 2 ) − 8 2 = 8 2 − 8 2 = 0 ✓ (a genuine rest point). Step-1 signs: 1 → 1.2 (rightward) and − 1 → − 1.2 (leftward) ✓.
Figure s03 — the double-well L = θ 4 − 4 θ 2 : the amber path from θ 0 = 1 falls into the right well + 2 ; the white path from θ 0 = − 1 falls into the left well − 2 . The cyan dot at θ = 0 is the local max separating the two basins.
Before the example, we owe you one definition — the symbol λ m a x (read "lambda-max") in the stability bound η < 2/ λ m a x .
Definition Eigenvalue and
λ m a x — "curvature along a direction"
For a bowl-shaped loss L ( θ ) = 2 1 θ ⊤ A θ , the matrix A describes how steeply the bowl curves in each direction. An eigenvalue λ of A is simply the curvature number along one special axis of that bowl: a big λ means a steep, narrow direction; a small λ means a shallow, wide direction. λ m a x (read "lambda-max") is the largest of these — the steepest, most sensitive direction.
Why it sets the speed limit: along a direction with curvature λ , one gradient step multiplies your distance-to-bottom by ( 1 − η λ ) . That shrinks the error only when ∣1 − η λ ∣ < 1 , i.e. η < 2/ λ . The steepest direction (largest λ ) has the smallest such limit, so it is the one that decides whether the whole run is stable. For a plain 1-D L = θ 2 the single curvature number is 2 — exactly the "2 " you saw in Ex 4's bound η < 1 .
Worked example Ex 8 — pick the biggest stable
η for a stretched bowl
L ( θ ) = 2 1 θ ⊤ A θ with A = [ 10 0 0 2 ] . What is the largest η for which gradient descent still converges?
Forecast: two directions with different steepness — which one limits us?
Read the curvatures (eigenvalues). A is diagonal, so its eigenvalues are just its diagonal entries: λ = 10 (steep axis) and λ = 2 (shallow axis).
Why this step? For a diagonal A , each coordinate curves independently, and its curvature is its own diagonal number — no extra computation needed. The stability bound cares about λ m a x , the steepest of these.
Apply the bound. η < λ m a x 2 = 10 2 = 0.2 .
Why this step? Along the steep axis the update multiplier is 1 − η ⋅ 10 ; convergence needs ∣1 − 10 η ∣ < 1 , i.e. η < 0.2 . Any bigger and the steep direction diverges even though the shallow one is fine.
The boundary η = 0.2 exactly. At η = 0.2 the steep-axis multiplier is 1 − 10 ( 0.2 ) = − 1 , whose magnitude is exactly 1 .
Why this step? A multiplier of − 1 neither shrinks nor grows the coordinate — it just flips its sign each step, so the steep component oscillates forever at constant size instead of settling. That is why the bound is a strict inequality η < 0.2 : the endpoint is not convergence but perpetual bouncing.
Check the shallow axis is safe. At η = 0.2 : ∣1 − 2 ( 0.2 ) ∣ = 0.6 < 1 ✓ — the λ = 2 direction converges comfortably; it never sets the limit.
Why this step? Confirms the max eigenvalue, not the min, is the binding constraint — a classic exam trap.
Verify: η m a x = 2/10 = 0.2 ✓. At η = 0.2 : steep multiplier ∣1 − 10 ( 0.2 ) ∣ = 1 (borderline, oscillates), shallow ∣1 − 2 ( 0.2 ) ∣ = 0.6 < 1 ✓. Use Learning Rate Schedules or Momentum and Adam to cope when λ m a x ≫ λ m i n .
Recall Quick self-test
Which case has the step multiplier exactly 0.8 ? ::: Ex 1/Ex 2 with η = 0.1 , L = θ 2 : 1 − 2 ( 0.1 ) = 0.8 .
Why does θ 0 = 0 freeze on both θ 2 and θ 3 ? ::: Both have ∇ L ( 0 ) = 0 ; zero gradient ⇒ zero step, regardless of whether it's a true minimum.
What is λ m a x in plain words? ::: The curvature of the loss along its steepest direction — the biggest eigenvalue of the curvature matrix; it sets the learning-rate limit η < 2/ λ m a x .
In Ex 8, what happens exactly at η = 2/ λ m a x = 0.2 ? ::: The steep-axis multiplier is − 1 , so that component oscillates at constant size forever — it does not converge; hence the bound is strict.
In Ex 7, what decides which well you reach? ::: The sign of the starting point — its basin of attraction — since the landscape is non-convex.
Mnemonic Cover-the-matrix check
S ign left/right (A,B) · Z ero flat spots (C) · B low-up big η (D) · V ector 2-D (E) · W ord units (F) · N on-convex wells (G) · E igen-bound exam (H). "Some Zebras Blow Very Weird New Echoes. "