1.2.12 · D4Calculus & Optimization Basics

Exercises — Gradient descent intuition and update rule

2,650 words12 min readBack to topic

Before we start, let us pin down every symbol you will see, so nothing appears unearned.


Level 1 — Recognition

Recall Solution 1.1
  • Step size is controlled by (the learning rate) — it is just a scaling number.
  • Direction is controlled by — the gradient points uphill, the minus flips it downhill.
  • What it looks like: is the arrow, is how far along that arrow you slide.
Recall Solution 1.2
  • (power rule: bring the 2 down, drop the exponent by 1).
  • At : .
  • Meaning: at the hill rises units of loss per unit of — steep and pointing right, so we step left.
Recall Solution 1.3
  • False. The gradient points toward steepest increase (uphill, away from the minimum). We deliberately walk in the opposite direction to go downhill. That is exactly why the update rule has a minus sign.

Level 2 — Application

Recall Solution 2.1

Gradient: .

  • Pattern: each step multiplies by , so , sliding toward .
Recall Solution 2.2
  • Observation: it bounces forever, never shrinking. The multiplier is , magnitude , so no progress — a perfect oscillation.

The figure below plots the bowl (violet) and draws each update as a magenta arrow. Notice the arrows jump from the right wall to the left wall at the same height every time — the ball never descends because a multiplier of only mirrors the point across the minimum without shrinking it. This is the visual signature of " exactly at the stability edge".

Figure — Gradient descent intuition and update rule
Recall Solution 2.3
  • Shrinking requires the multiplier's size below 1: .
  • Solve: .
  • So any in converges; oscillates (Ex 2.2); diverges.

Level 3 — Analysis

Recall Solution 3.1

Predictions at start: . Errors : .

  • Updates: , .
  • Why both rise? Gradients are negative, minus flips them positive — the line was flat at , both and climb to reduce error.
Recall Solution 3.2

First, where does the change formula come from? The first-order Taylor (linear) approximation says that for a small step , so the loss change is . This is the directional derivative — exact in the limit of infinitesimally small steps, which is why the argument below is a local one.

  • Rewrite the dot product geometrically: , where is the angle between the gradient and the step.
  • We want this most negative. are fixed positives, so only can be steered.
  • is smallest () at — pointing exactly opposite the gradient. Hence wins.

In the figure below, the violet arrow is the (uphill) gradient and the magenta arrow is at from it; the orange arrow is some other step at angle . Because scales with , only the magenta arrow reaches the most-negative value — every other direction leaks some of its length sideways where it does no downhill work. That "wasted sideways component" is exactly what the dot product measures.

Figure — Gradient descent intuition and update rule
Recall Solution 3.3
  1. Wrong sign — they wrote (climbing uphill). Test: even a tiny still increases loss → sign bug.
  2. too large — overshooting past the valley. Test: shrinking (e.g. ) makes loss start decreasing → learning-rate issue, not a sign bug.

Level 4 — Synthesis

Recall Solution 4.1

is diagonal, so each coordinate evolves independently with multipliers and .

  • Coordinate 1 needs .
  • Coordinate 2 needs .
  • Both converge only for the tighter bound: with . This is exactly the parent note's stability rule .
Recall Solution 4.2
  • Coordinate 1 multiplier: (shrinks per step).
  • Coordinate 2 multiplier: (shrinks to half, but flips sign each step).
  • Faster is coordinate 2: . The steep (large-eigenvalue) direction is squeezed fastest — but it is also the one that would diverge first if grew. This tension is why ill-conditioned problems are hard, motivating Momentum and Adam.
Recall Solution 4.3

Level 5 — Mastery

Recall Solution 5.1

Set-up. By the first-order Taylor approximation, the loss change for a small step is . We restrict all candidate steps to a fixed length — geometrically this is a sphere of radius around : we are asking "of all directions I could step the same distance, which drops the loss most?" The constraint forces onto that sphere so that the comparison is fair (a longer step would trivially change more just by being longer).

  • Geometric argument (no calculus needed). Write . On the sphere, and are constants; the only free quantity is . It is minimized at , i.e. antiparallel to .
  • Same result via Lagrange multipliers (for the sceptic). Minimizing subject to gives the stationarity condition for a multiplier — so must be parallel to ; picking the sign that minimizes (rather than maximizes) selects the antiparallel one.
  • The antiparallel vector of length is . Absorbing into recovers . This is why GD is called steepest descent. (See Convex Optimization for when this local step reaches the global minimum.)
Recall Solution 5.2
  • Gradient: . Update: .
  • To hit in one step for any : .
  • Check with (): — matches the "fastest" note from the L2 trap. This is precisely the Newton step, the bridge to Second-Order Methods.
Recall Solution 5.3

Gradient: .

  • From : . The -component is zero, so never moves — GD slides down the -bowl to and stalls at the saddle, never noticing falls away.
  • From : ; the -update is , so grows, escaping downhill.

The figure below draws the saddle's contour lines with two GD paths. The magenta path starts on the -axis and marches straight into the centre where it freezes — because the -slope is exactly zero there is no arrow pushing it off. The violet path starts a hair off-axis and its arrows curve outward along , rolling off the saddle. The geometry shows why symmetric starting points are dangerous: they hide the very direction that would let you escape.

Figure — Gradient descent intuition and update rule

Recall One-line summary to recite

Reveal each answer to test yourself. What is the update rule? ::: — flip the uphill arrow, scale by , repeat. Stability bound for ? ::: . Why is steepest descent? ::: minimize ; best at .