30 / 90

Day 30: Optimization — gradient descent and its failure modes

Derive gradient descent steps by hand on a convex bowl, produce divergence and slow-crawl counterexamples, explain a saddle point, and practice failure analysis without fabricated success. This day closes the mathematics track.

Mathematics & Algorithmic Foundations 480 active minutes (8 hours focused study)
01 120 min

Gradient descent mechanics on a convex bowl

Assistance allowed only after prediction and observed evidence are recorded.

Prerequisites

Day 29 evaluation; single-variable derivative (power rule) from the mathematics block.

Learning Objective

Derive the gradient-descent update x ← x − η·2x = x(1 − 2η) and predict the whole optimization trajectory from the factor (1 − 2η).

Instructions

Optimization here means iteratively lowering a loss. On f(x) = x² the gradient is 2x, so each step multiplies x by (1 − 2η). Starting at x₀ = 4 with η = 0.1 the factor is 0.8: x₁ = 3.2, x₂ = 2.56, x₃ = 2.048, and in general x_k = 4·0.8^k. Trace by hand first, then confirm with a short Python loop. Note η = 0.5 gives factor 0 — one-step convergence on this pure quadratic.

Practice & Prediction Log

For f(x) = x² with x₀ = 4: (a) write x_k in closed form; (b) compute x₁, x₂, x₃ and x₁₀ for η = 0.1; (c) for f(x) = (a/2)x² the factor is (1 − ηa) — derive the stability condition |1 − ηa| < 1 and the learning-rate bound it implies.

Independent Mastery Criterion

Closed form derived, all four iterates correct, and the η < 2/a condition stated with its a = 2 specialization.

Authoritative Source Resources & Provenance

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

Author: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | Original Source Link ↗

Relevant Section / Range: Chapter Optimization Algorithms: Gradient Descent

Verified Version & Date: Current online edition (Verified: 2026-10-30)

Selection Rationale:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

Source Prerequisites:

Linear algebra, calculus, and probability at the Days 19-28 level.

Safe Fallback (Offline Resilience):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

Compared Candidate Sources & Selection Analysis (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

Author: Grant Sanderson (3Blue1Brown) | Original Source Link ↗

Relevant Section / Range: Neural networks chapter 2: the gradient and the descent update

Verified Version & Date: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

Selection Rationale:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

Source Prerequisites:

High-school functions and slope intuition.

Safe Fallback (Offline Resilience):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

Compared Candidate Sources & Selection Analysis (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

02 120 min

Unstable step sizes: divergence and the slow crawl

Independent Mastery Check (no AI assistance).

Prerequisites

Activity 30-01; no AI assistance.

Learning Objective

Produce three optimization failure regimes on the same function — divergent oscillation, frozen oscillation, and the slow crawl — and classify any η by its factor (1 − 2η).

Instructions

In optimization the factor (1 − 2η) decides everything: |factor| < 1 converges; factor = −1 oscillates forever; |factor| > 1 diverges with alternating signs; a small positive factor converges too slowly to matter. Compute each regime on f(x) = x², x₀ = 4, and record the trace honestly — these are real failure modes, not anomalies.

Practice & Prediction Log

Classify and trace on f(x) = x², x₀ = 4: (a) η = 1.2 → x₁, x₂, x₃ and |x₁₀|; (b) η = 1.0 → the trajectory after step 1; (c) η = 0.01 → x₁₀, and why this 'working' learning rate is still a practical failure; (d) name the regime label for each.

Independent Mastery Criterion

All three traces correct, each regime named with its factor, and the learner explains why 'the loss decreases' is necessary but not sufficient.

Authoritative Source Resources & Provenance

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

Author: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | Original Source Link ↗

Relevant Section / Range: Chapter Optimization Algorithms: Gradient Descent; learning-rate selection

Verified Version & Date: Current online edition (Verified: 2026-10-30)

Selection Rationale:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

Source Prerequisites:

Linear algebra, calculus, and probability at the Days 19-28 level.

Safe Fallback (Offline Resilience):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

Compared Candidate Sources & Selection Analysis (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

Author: Grant Sanderson (3Blue1Brown) | Original Source Link ↗

Relevant Section / Range: Neural networks chapter 2: step size intuition

Verified Version & Date: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

Selection Rationale:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

Source Prerequisites:

High-school functions and slope intuition.

Safe Fallback (Offline Resilience):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

Compared Candidate Sources & Selection Analysis (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

03 120 min

Saddle points and honest failure analysis

Assistance allowed only after prediction and observed evidence are recorded.

Prerequisites

Activity 30-02; prediction before assistance.

Learning Objective

Explain why a zero gradient is not a minimum using f(x,y) = x² − y², and practice reporting an optimization failure without fabricating success.

Instructions

At a saddle the gradient is 0 yet the point is not a minimum: for f(x,y) = x² − y² the origin is minimal in x and maximal in y. Gradient descent updates x ← x(1−2η) but y ← y(1+2η): an exact y = 0 stays 0 in perfect arithmetic, so a run started at (0.5, 0) converges to (0,0) — a saddle — while a tiny y₀ = 0.001 slowly escapes (y₁₀ ≈ 0.006, and by k = 20 the value f is already negative). Failure-analysis rule: report the observed trace, the diagnosed cause, and the fix — never round a failure into a success.

Practice & Prediction Log

(a) Verify ∇f = (2x, −2y) vanishes at (0,0) and that f(0, ε) = −ε² < 0 for any ε ≠ 0. (b) Starting at (0.5, 0) with η = 0.1, where does gradient descent arrive after 10 steps, and is that point a minimum? (c) A training log shows loss 2.0 → 2.6 → 3.5 → 4.9 → 6.8: write the honest failure-analysis entry — cause hypothesis, fix, and re-check.

Independent Mastery Criterion

Saddle verified by the −ε² argument, the stuck run computed correctly, and the failure entry records cause, fix, and re-check with no fabricated improvement.

Authoritative Source Resources & Provenance

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

Author: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | Original Source Link ↗

Relevant Section / Range: Chapter Optimization Algorithms: Optimization and Deep Learning (local minima, saddle points)

Verified Version & Date: Current online edition (Verified: 2026-10-30)

Selection Rationale:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

Source Prerequisites:

Linear algebra, calculus, and probability at the Days 19-28 level.

Safe Fallback (Offline Resilience):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

Compared Candidate Sources & Selection Analysis (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

Author: Grant Sanderson (3Blue1Brown) | Original Source Link ↗

Relevant Section / Range: Neural networks chapter 2: valleys, plateaus, and saddle intuition

Verified Version & Date: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

Selection Rationale:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

Source Prerequisites:

High-school functions and slope intuition.

Safe Fallback (Offline Resilience):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

Compared Candidate Sources & Selection Analysis (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

04 120 min

Assessment: predict, classify, and diagnose optimization behavior

Independent Mastery Check (no AI assistance).

Prerequisites

Activities 30-01 through 30-03; independent, closed-book.

Learning Objective

Unaided, transfer the optimization machinery to a new quadratic, classify a learning rate, and diagnose a described failure.

Instructions

On g(x) = 2x² the gradient is 4x, so x ← x(1 − 4η). Predict, then classify: for x₀ = 2 and η = 0.3 the factor is −0.2 — convergent, oscillating, or divergent? Compute x₁, x₂, x₃. Give the stability bound for g. Finally diagnose a loss trace 2.0 → 2.6 → 3.5 → 4.9 and write the corrective entry.

Practice & Prediction Log

g(x) = 2x², x₀ = 2, η = 0.3: (a) closed form x_k; (b) x₁, x₂, x₃ and the regime; (c) the stability bound on η; (d) diagnose the loss trace 2.0 → 2.6 → 3.5 → 4.9 and write the one-line corrective action.

Independent Mastery Criterion

Closed form, three iterates, regime, and bound all correct without aid, and the diagnosis names cause plus corrective action — closing the mathematics track with honest failure analysis.

Authoritative Source Resources & Provenance

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

Author: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | Original Source Link ↗

Relevant Section / Range: Chapter Optimization Algorithms: Gradient Descent; Optimization and Deep Learning

Verified Version & Date: Current online edition (Verified: 2026-10-30)

Selection Rationale:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

Source Prerequisites:

Linear algebra, calculus, and probability at the Days 19-28 level.

Safe Fallback (Offline Resilience):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

Compared Candidate Sources & Selection Analysis (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

Author: Grant Sanderson (3Blue1Brown) | Original Source Link ↗

Relevant Section / Range: Neural networks chapter 2: the gradient and the descent update

Verified Version & Date: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

Selection Rationale:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

Source Prerequisites:

High-school functions and slope intuition.

Safe Fallback (Offline Resilience):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

Compared Candidate Sources & Selection Analysis (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.