Bring the mental model from Derivatives; this page will reuse it instead of restarting from zero.
Gradient Descent
Gradient descent turns local slope information into an iterative update rule for reducing a loss.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
A model can receive one scalar complaint, the loss is high, while having thousands or millions of parameters. Which way should those parameters move?
Gradient descent is the basic answer behind most neural-network training: measure which way the loss rises, then step the other way.
Imagine standing on a landscape in fog. You cannot see the whole terrain, but you can feel the local slope under your feet. The gradient points in the steepest uphill direction. If your goal is to lower the loss, you walk against that direction.
The method is deliberately local. It does not know whether a better valley exists far away, and it can move too slowly or overshoot if the step size is wrong. But it gives a reusable training loop: compute a loss, differentiate it, update parameters, repeat.
This page assumes the gradient is already available. Backpropagation explains how computation graphs and reverse-mode autodiff produce that gradient for neural networks; gradient descent explains how an optimizer consumes it.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let L:Rp→R be a loss function and let θt∈Rp be the current parameter vector. Under the standard Euclidean inner product, the gradient
points in the direction of steepest local increase. Gradient descent uses the update
where η>0 is the learning rate.
If L is differentiable near θ and ∇L(θ)=0, the first-order Taylor approximation says
That is the local reason stepping against the gradient should reduce the loss. The learning rate controls how much you trust this local approximation. If η is too small, training makes slow progress. If η is too large, the update can jump across a valley or even increase the loss. On a quadratic loss, this tradeoff is governed by curvature: steep directions demand smaller stable steps than flat directions.
At a stationary point, ∇L(θ)=0, so this first-order decrease argument disappears. In a nonconvex loss, such a point might be a minimum, a saddle, or a maximum.
For the quadratic used below,
with A symmetric positive definite, the gradient is ∇L(θ)=Aθ. In an eigen-direction of A with curvature λi, the update becomes
Fixed-step descent is stable only when ∣1−ηλi∣<1 for every direction, so
This is the stability bound used by the code and the demo.
In deep learning, the exact gradient over the whole dataset is often too expensive. For a training set of n examples, define the empirical risk
For a mini-batch Bt, we instead compute
With uniform sampling, gt estimates ∇Lemp(θt). That turns gradient descent into stochastic gradient descent. The update is the same shape, but the direction is noisy:
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
# Minimize L(theta) = 0.5 * theta^T A theta.
# The second coordinate has much higher curvature.
# Shapes: A is (2, 2), theta is (2,), grad(theta) is (2,).
A = np.diag([1.0, 20.0])
theta = np.array([5.0, 5.0])
lr = 0.08
def loss(theta):
return 0.5 * theta @ A @ theta
def grad(theta):
return A @ theta
for step in range(20):
theta = theta - lr * grad(theta)
if step in [0, 1, 2, 5, 19]:
print(step + 1, "theta=", np.round(theta, 3), "loss=", round(loss(theta), 3))
For this quadratic, λmax=20, so stable fixed-step descent needs 0<η<2/λmax=0.1. Try lr = 0.005, 0.08, and 0.12 to see slow movement, stable zig-zagging, and instability.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Live Concept Demo
Explore Gradient Descent
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Choose what to inspect in Gradient Descent. This shared fallback is an observation guide, not evidence of learning.
Use the learning-rate slider on the stretched quadratic bowl. The contours show the loss, the blue path shows repeated gradient-descent updates, and the brown arrow shows the first local step.
The presets start with the same high curvature as the code example, λmax=20, so η=0.08 is stable while η=0.12 is not. The key comparison is the learning rate against the stability bound 2/λmax for this quadratic. A tiny learning rate crawls. A large but stable learning rate zig-zags across the high-curvature direction while still reducing loss. A learning rate above the bound eventually escapes instead of descending.
Change curvature while keeping the same learning rate. The gradient formula has not changed, but the safe step size has: steeper curvature makes the local slope become stale faster.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
Concept: Gradient Descent
What is the smallest example that makes Gradient Descent click without losing the math?
Object contextOptimization
concept:optimization/gradient-descentGradient Descent
What is the smallest example that makes Gradient Descent click without losing the math?
Start with the prediction checkpoint, then compare the reveal to the mental model.
Take this moveStudy modes
Keep the object fixed; change the lens.Route back through the notebook
Carry the same object through intuition, math, code, and demo.
Gradient descent turns local slope information into an iterative update rule for reducing a loss.
The next edge should feel earned: use the demo prediction here before following SGD & Momentum: The Workhorses of Optimization.
After The First Pass
Turn the concept into an inspected object.
The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.Mechanism Storyboard
See the idea move before the page explains it
Gradient descent turns local slope information into an iterative update rule for reducing a loss.

Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Gradient Descent should make visible.
Visual Inquiry
Make the image answer a mathematical question
Gradient descent turns local slope information into an iterative update rule for reducing a loss.
Which visible object should carry the first intuition?
Pick the cue that should make Gradient Descent easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
What is the smallest example that makes Gradient Descent click without losing the math?
concept:optimization/gradient-descentsources: boyd-2004-convex-optimization, goodfellow-2016-deep-learning
Open the closest source note before trusting the local explanation.
2 selected-object sources shown first; 2 references total.
Audit the claim boundary, then ask from the same selected object.
Grounds descent methods, gradients, step sizes, and convex-optimization intuition.
Boyd and Vandenberghe ground descent methods, gradients, and step-size reasoning in convex optimization; Goodfellow et al. frame neural-network training as optimizing parameters of a cost...
This checks the local first-order update mechanism, not a guarantee of global convergence for nonconvex neural-network losses.
Grounds gradient-based learning as the optimization language used by neural networks.
Boyd and Vandenberghe ground descent methods, gradients, and step-size reasoning in convex optimization; Goodfellow et al. frame neural-network training as optimizing parameters of a cost...
This checks the local first-order update mechanism, not a guarantee of global convergence for nonconvex neural-network losses.
Claim Review
Gradient descent turns local slope information into an iterative update rule for reducing a loss.
What is the smallest example that makes Gradient Descent click without losing the math?
concept:optimization/gradient-descentsources: boyd-2004-convex-optimization, goodfellow-2016-deep-learning
Treat every claim as provisional until source support and a local witness agree.
1 structured claim check on this concept.
Run the prediction or practice transfer before asking for a grounded review.
Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 2 references and 3 local witnesses are available for inspection.
Boyd and Vandenberghe ground descent methods, gradients, and step-size reasoning in convex optimization; Goodfellow et al. frame neural-network training as optimizing parameters of a cost function with gradi...
This checks the local first-order update mechanism, not a guarantee of global convergence for nonconvex neural-network losses.
Checked Goodfellow et al. chapters 4.3 and 8.3 plus Boyd/Vandenberghe chapter 9: Goodfellow gives directional derivative u^T grad f, says -grad is downhill, gives x' = x - eps grad f with eps as positive learning rate, and uses Taylor expansion to show curvature can make too-large steps move uphill. Boyd frames descent as direction plus step size and states Euclidean steepest descent coincides with gradient descent.
Reviewer: codex+oracle; reviewed 2026-05-06Practice notebook
Use the idea, then test it somewhere new
Gradient descent turns local slope information into an iterative update rule for reducing a loss.
What is the smallest example that makes Gradient Descent click without losing the math?
concept:optimization/gradient-descentsources: boyd-2004-convex-optimization, goodfellow-2016-deep-learning
Use one state from Gradient Descent to explain what changes, why it changes, and which assumption the explanation needs.
No learner move yet; no learning state is inferred.
Write first, use only the help you need, then try a new case without it.
Use one state from Gradient Descent to explain what changes, why it changes, and which assumption the explanation needs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Write an attempt before asking the companion.
0 of 3 progressive hints opened.
This draft and any AI response do not establish mastery; a later unassisted case can.
- ObjectConceptGradient Descent
- PredictBefore revealGradient Descent prediction
- WitnessCompare codeGradient Descent code witness 1
- RoomAsk groundedChecking local snapshot
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Gradient Descent
What is the smallest example that makes Gradient Descent click without losing the math?
These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.
Source ids boyd-2004-convex-optimization, goodfellow-2016-deep-learning must support the exact object, not just the surrounding topic.
Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.
Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.
The learner can state the mechanism in their own words
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:optimization/gradient-descent.
- Source ids to inspect: boyd-2004-convex-optimization, goodfellow-2016-deep-learning
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Gradient Descent Object key: concept:optimization/gradient-descent Context: Optimization Anchor id: concept/concept-notebook/optimization/gradient-descent Open question: What is the smallest example that makes Gradient Descent click without losing the math? Evidence to inspect: - Source ids to inspect: boyd-2004-convex-optimization, goodfellow-2016-deep-learning - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids boyd-2004-convex-optimization, goodfellow-2016-deep-learning must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Gradient Descent" feel predictable rather than familiar." | assumption: Source ids boyd-2004-convex-optimization, goodfellow-2016-deep-learning must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: boyd-2004-convex-optimization, goodfellow-2016-deep-learning" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Gradient Descent" feel predictable rather than familiar. - Assumption to keep visible: Source ids boyd-2004-convex-optimization, goodfellow-2016-deep-learning must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words
concept/concept-notebook/optimization/gradient-descent
concept:optimization/gradient-descent