1.2.12 · D1Calculus & Optimization Basics

Foundations — Gradient descent intuition and update rule

2,604 words12 min readBack to topic

Before you can read the parent note Gradient Descent, you need to own every piece of notation it throws at you. This page builds each one from nothing, in an order where each idea leans on the one before it. Nothing here is assumed.


1. The parameter — the "settings knob"

Picture a radio with dials. Each dial is one number you can turn. Turning the dials changes the sound. In machine learning, is all the dials at once.

  • If there is one dial, is a single number, e.g. .
  • If there are many dials, is a list, e.g. for a line .

Why the topic needs it: gradient descent's whole job is deciding how to turn these dials. Without a name for "the thing we adjust," there is nothing to adjust.

Figure — Gradient descent intuition and update rule

Read the figure: the horizontal axis is the single dial ; the blue curve is a valley. Look at the yellow dot at and the red dot at — those are two different dial settings, each sitting at a different height. The green star at the very bottom is (theta-star). The little star always means "the best one" — the dial setting that makes us least wrong.


2. The loss — the "wrongness meter"

The notation reads "L of theta" — it means "feed the dial settings into the wrongness meter , and out comes a number." This is function notation: the letter outside the brackets is a machine, the thing inside the brackets is what you feed it.

Read the figure below: every horizontal position is a choice of dials . The height of the blue ground at that spot is the loss . Turning the dials = walking left or right; the height = how wrong you are.

  • The red dot on the left sits high up → large → very wrong.
  • The green star sits in the dip → small → nearly right.
  • The lowest valley point → the best settings.

Why the topic needs it: "learning" is the act of finding the valley of . See Loss Functions for how these meters are actually built.

Figure — Gradient descent intuition and update rule

3. Slope — how steep the ground is

Imagine standing on a ramp. Walk 1 metre forward (run), and you rise 2 metres (rise). The slope is . Walk forward and drop 2 metres → slope . Perfectly flat → slope .

Read the figure: it shows a run-of-1 triangle drawn on three spots of the same hill. On the left (yellow) the ground climbs — the triangle rises, slope . In the middle (green) the ground is flat — no rise, slope . On the right (red) the ground falls — the triangle drops, slope . Same picture, three signs.

Figure — Gradient descent intuition and update rule

The sign of the slope is the crucial part:

  • slope : ground goes up as you move right → to go down, move left.
  • slope : ground goes down as you move right → to go down, move right.
  • slope : you're on flat ground — possibly a valley bottom.

Why the topic needs it: the entire strategy is "walk in the downhill direction." Slope is what tells you which way is downhill without seeing the whole mountain.


4. The derivative — slope, made exact

Why a new tool and not just slope? A ramp has one slope everywhere. But the loss landscape is curved — its steepness changes at every point. Ordinary "rise over run" needs two points. The derivative is the trick that gives you the slope using an infinitely small run, so it works at a single point on a curve.

Why does ? Let's build it, not assert it. Take two points a tiny gap apart, and , and compute rise-over-run between them: Now shrink the gap: as gets infinitely small (), the leftover vanishes and we are left with exactly . That shrinking is the whole idea of a derivative — the slope you'd feel with a step so small it's a single point. The figure shows the two points closing up onto one tangent line.

Figure — Gradient descent intuition and update rule

Read the figure: the red dot sits at ; the yellow line is the tangent whose slope is — steep and climbing, so to go down you step left. The green star at shows a flat tangent: slope , the valley bottom.


5. Partial derivative — slope in one direction

Picture standing on a real 2-D hillside. Face east and ask "how steep is it if I walk east only?" — that's one partial. Face north and ask again — that's another partial. Each partial isolates one direction.

Why the topic needs it: real models have thousands of dials. You cannot describe the downhill direction with a single slope; you need one slope per dial. That is precisely what the parent note computes in Example 2 with and .


6. The directional derivative — steepness in any chosen direction

On a 2-D hill you can face infinitely many compass directions, not just east and north. Each direction has its own steepness. A beautiful fact ties them all together: the directional derivative in direction equals the dot product (defined next section) of the gradient with : where is the angle between and the gradient. Because is largest () when , the steepness is maximised when you walk exactly along . That is the reason — not a magic assertion — that the gradient points straight uphill. We'll unpack the dot product properly in section 8; keep this promise in mind.


7. The gradient — the full downhill compass

This arrow is not just a bookkeeping list — from the directional-derivative fact above, it points somewhere:

Read the figure: the blue rings are contour lines (like a map's height lines) of a bowl-shaped loss. From the white "you are here" dot, the red arrow points outward, away from the centre — that's uphill. The green arrow points inward toward the yellow star at the bottom — that's the direction gradient descent actually steps.

Figure — Gradient descent intuition and update rule

"Walk in the direction" is gradient descent in one sentence. Backpropagation is simply a fast recipe for computing inside neural networks.


8. The dot product — measuring "same direction?"

The notation (a superscript means "transpose" — for our purposes just a way of writing a dot product) asks: does my step point the same way as uphill?

Read the figure: all three green step arrows have the same length; only the angle to the red gradient changes. The value written under each is the dot product with a gradient of length and step of length .

Figure — Gradient descent intuition and update rule

A concrete number: take and a step of length .

  • If step points uphill (, ): dot . Loss rises most. Bad.
  • If step points sideways (, ): dot . Loss unchanged.
  • If step points downhill (, ): dot . Loss drops most. Best!

Why the topic needs it: this is the proof that "opposite to the gradient" is optimal. The most-negative dot product happens exactly when your step is antiparallel to — which is why the update rule has a minus sign.


9. The step , learning rate , and iteration

Putting all the symbols together gives the parent note's headline formula, and now every piece is earned:


Prerequisite map

Parameter theta - the knobs

Loss L of theta - wrongness meter

Slope - steepness of ground

Derivative dL by dtheta - exact slope

Partial derivative - slope one dial at a time

Directional derivative - steepness any direction

Gradient nabla L - full uphill arrow

Dot product - same direction check

Update rule theta minus eta times gradient

Learning rate eta - step size


Equipment checklist

Test yourself — cover the right side and answer aloud.

What does mean in one phrase?
The adjustable settings ("knobs") of the model.
What does measure?
A single number: how wrong the model is at settings ; small = good.
What is slope, in words?
Rise over run — how much height changes per small sideways step.
Why use a derivative instead of ordinary slope?
The loss curve bends, so steepness changes at every point; the derivative gives the exact slope at one point.
Show why .
, and as this becomes .
What does the curly signal?
A partial derivative — vary one dial, hold all others frozen.
What does the directional derivative give you?
The steepness along any chosen direction , equal to .
What does the gradient point toward, and why?
Steepest increase (uphill), because steepness is largest along ; so is steepest downhill.
Does guarantee a minimum?
No — it can also be a maximum or a saddle point (flat ground of any kind).
When is the dot product most negative?
When the step points exactly opposite the gradient ().
What does control?
The step size — how far you move each iteration.
Why is there a minus sign in ?
The gradient points uphill; the minus flips it to move downhill and shrink the loss.