Gradient descent on a quadratic bowl splits into one simple race per eigenvalue. Derive the largest safe step, the best fixed step and its rate (kappa - 1)/(kappa + 1), and see why rescaling the features turns a slow zigzag into one straight step.
M03.8.4L2 Intermediate25 minIn review (what this means)
The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
Derive that gradient descent on f(x) = x-transpose S x / 2 multiplies each eigen-coordinate by 1 - eta lambda_i per step.
State and prove the stability condition eta < 2 / lambda_max.
Derive the best fixed step 2 / (lambda_min + lambda_max) and its rate (kappa - 1) / (kappa + 1), and estimate the number of steps it needs.
Explain why rescaling the features is a form of preconditioning, and when it is not enough.
The question
Gradient descent with its best fixed step needs 20 steps to cut the error of the running bowl \({2x^2 + 2xy + 2y^2}\) a million-fold. Measure one feature in different units, so that the bowl becomes long and thin, and the same method needs 62 steps, or 691, or more. Nothing about the minimum has changed. What sets the speed, and how do we get it back?
From the last lesson
1. Which cause of ill-conditioning does standardising the features cure?
Show answer
Features on very different scales or in different units. It does not cure features that nearly repeat one another.
2. What is \({\kappa(\mat{A}\T\mat{A} + \alpha\mat{I})}\)?
Take the bowl \({f(\vect{x}) = \tfrac12\vect{x}\T\mat{S}\vect{x}}\) with the running symmetric matrix \(\mat{S}\), rows \({(2, 1)}\) and \({(1, 2)}\). Its eigenvectors \({\vect{q}_1 = (1, 1)/\sqrt2}\) and \({\vect{q}_2 = (1, -1)/\sqrt2}\) are the axes of the bowl, with curvatures \({\lambda_1 = 3}\) and \({\lambda_2 = 1}\).
M03.8.4-F1
Gradient descent with step \({\eta = 0.3}\) on the running bowl. Along the steep axis the error shrinks tenfold each step; along the flat axis only by 0.7. The flat axis decides the speed.
Seen in the bowl’s own axes, gradient descent is not one process but two, one per eigenvector, and the two never interfere. Each is shrunk by its own fixed factor at every step. The steep direction wants a small step, or it overshoots; the flat direction wants a large one, or it crawls. One step size has to serve both, and the ratio of the two curvatures, the condition number, decides how badly they disagree.
Build it up
Step 1. The update. The gradient of \(f\) is \(\mat{S}\vect{x}\) (M04.10 and M03.4.4), so a step of size \(\eta\) is
The minimum is at \(\vect{0}\), so \(\vect{x}_t\) is also the error.
Step 2. Change to eigen-coordinates. Write \({\mat{S} = \mat{Q}\mat{\Lambda}\mat{Q}\T}\) and \({\vect{y}_t = \mat{Q}\T\vect{x}_t}\), the coordinates of \(\vect{x}_t\) along \(\vect{q}_1, \vect{q}_2\). Multiply the update by \(\mat{Q}\T\) and use \({\mat{Q}\T\mat{Q} = \mat{I}}\):
With \({\eta = 0.3}\) the factors are \({1 - 0.9 = 0.1}\) and \({1 - 0.3 = 0.7}\), the two slopes in the figure.
Step 4. Plot the factors against the step size. Each factor \({\abs{1 - \eta\lambda_i}}\) falls to 0 at \({\eta = 1/\lambda_i}\) and rises again. The error shrinks only while every factor is below 1, and it shrinks at the pace of the largest.
M03.8.4-F2
The factor for each eigenvalue of the running bowl, and their maximum. The best step balances the two at \({\eta^* = 0.5}\); beyond \({\eta = 2/3}\) the steep direction grows.
The formal statement
NoteTheorem: gradient descent on a quadratic
Let \(\mat{S}\) be symmetric positive definite with eigenvalues \(\lambda_{\max} = \lambda_1 \ge \dots \ge \lambda_n = \lambda_{\min} > 0\), and \({\kappa = \lambda_{\max}/\lambda_{\min}}\). Gradient descent on \({f(\vect{x}) = \tfrac12\vect{x}\T\mat{S}\vect{x}}\) with a fixed step \({\eta > 0}\) satisfies
It converges from every start exactly when \({\eta < 2/\lambda_{\max}}\).
The best fixed step is \({\eta^* = 2/(\lambda_{\min} + \lambda_{\max})}\), with factor \({(\kappa - 1)/(\kappa + 1)}\).
The bound.\(\mat{Q}\) keeps lengths, so \({\norm{\vect{x}_t} = \norm{\vect{y}_t}}\). Each coordinate of \(\vect{y}_t\) is that of \(\vect{y}_0\) times \({(1 - \eta\lambda_i)^t}\), which is at most the largest factor to the power \(t\) in size. Square, add and take the root.
Part 1. Since every \({\lambda_i > 0}\), each factor satisfies \({1 - \eta\lambda_i < 1}\). It is above \({-1}\) exactly when \({\eta\lambda_i < 2}\). The hardest case is \(\lambda_{\max}\), so all factors lie strictly between \({-1}\) and \(1\) exactly when \({\eta < 2/\lambda_{\max}}\). If instead \({\eta \ge 2/\lambda_{\max}}\), a start along \(\vect{q}_1\) keeps or grows its size forever.
Part 2. For \(\lambda\) between \(\lambda_{\min}\) and \(\lambda_{\max}\), the function \({\abs{1 - \eta\lambda}}\) is largest at one of the two ends, so the speed is set by \({\max(\abs{1 - \eta\lambda_{\min}}, \abs{1 - \eta\lambda_{\max}})}\). Below the step where the two meet, the first is the larger, and raising \(\eta\) shrinks it; above that step, the second is the larger, and raising \(\eta\) grows it. So the maximum is smallest where they meet:
after dividing top and bottom by \(\lambda_{\min}\).
How many steps. The error is sure to shrink to a fraction \(\epsilon\) of its start (say \({10^{-6}}\)) once \({\big((\kappa - 1)/(\kappa + 1)\big)^t \le \epsilon}\), that is once
\[
t \ge \frac{\ln(1/\epsilon)}{\ln\big((\kappa + 1)/(\kappa - 1)\big)}
\]
steps. For large \(\kappa\), \({\ln\big((\kappa + 1)/(\kappa - 1)\big) \approx 2/\kappa}\) (exercise 3), so
\[
t \approx \frac{\kappa}{2}\,\ln\frac{1}{\epsilon} .
\]
The work grows in proportion to the condition number: a bowl ten times thinner costs ten times the steps. The same holds for \({f(\vect{x})} = {\tfrac12\vect{x}\T\mat{S}\vect{x} - \vect{b}\T\vect{x}}\), with \({\vect{x}_t - \mat{S}^{-1}\vect{b}}\) in place of \(\vect{x}_t\).
M03.8.4-F3
Steps of gradient descent with the best fixed step, against \(\kappa\). The count is about \({6.9\,\kappa}\) for a million-fold cut.
Rescaling is preconditioning. Suppose the bowl is the squared error of a model with two uncorrelated, centred features whose standard deviations are 3 and 1. Its matrix is \({\mat{S} = \operatorname{diag}(9, 1)}\), with \({\kappa = 9}\). Divide the first feature by 3. Its weight must then be 3 times larger, \({w_1 = z_1/3}\), and in the new weights
a round bowl with \({\kappa = 1}\). Changing the variables by a matrix \(\mat{D}\) turns \(\mat{S}\) into \(\mat{D}\mat{S}\mat{D}\), and choosing \(\mat{D}\) to make that better conditioned is called preconditioning. Standardising features is the simplest kind.
Frontier note: the spectral norm of a weight matrix in deep learning
The map \(\vect{h} \mapsto \mat{W}\vect{h}\) can change the distance between two inputs by at most the factor \({\norm{\mat{W}}_2 = \sigma_1(\mat{W})}\), its Lipschitz constant. By the submultiplicative rule of M03.8.1, a whole network of such layers, with activations like ReLU that never stretch, is bounded by the product of the layers’ spectral norms. Spectral normalisation (Miyato and co-authors, ICLR 2018) divides each weight matrix by an estimate of its \(\sigma_1\), so that every layer has spectral norm 1, and finds that estimate cheaply with one step of the power method (M03.2.4) per update, reusing the vector from the step before. The full theory of step sizes is in M08.3, and the error analysis of algorithms in M10.3.
Worked example
Run gradient descent by hand on the running bowl with the best step.
The eigenvalues are 3 and 1, so \({\eta^* = 2/(1 + 3) = 0.5}\) and the factor is \({(3 - 1)/(3 + 1) = 0.5}\). The matrix of one step is
The length halves every step, \({\norm{\vect{x}_t} = 0.5^t}\), because both eigen-coordinates are multiplied by a factor of size 0.5: by \({1 - 0.5 \times 3 = -0.5}\) along \(\vect{q}_1\), which flips its sign, and by \({1 - 0.5 \times 1 = 0.5}\) along \(\vect{q}_2\). A million-fold cut needs \({0.5^t \le 10^{-6}}\), that is \({t = 20}\).
The limit is \({2/\lambda_{\max} = 2/3}\). With \({\eta = 0.7}\) the steep factor is \({1 - 2.1 = -1.1}\), and the error grows by 10% a step along \(\vect{q}_1\).
M03.8.4-F4
The first five steps with \({\eta = 0.5}\). The iterate alternates between the two axes and its length halves every time.
Code
Gradient descent from scratch, with a counter, on the three bowls of this lesson.
import numpy as npdef descend(S, x0, eta, tol=1e-6, max_steps=100_000):"""Gradient descent on x^T S x / 2. Returns the number of steps to shrink ||x|| by tol, or None.""" x = np.array(x0, dtype=float) start = np.linalg.norm(x)for k inrange(1, max_steps +1): x = x - eta * (S @ x) size = np.linalg.norm(x)if size <= tol * start:return kif size >1e6* start: # clearly divergingreturnNonereturnNonedef best_step(S): lam = np.linalg.eigvalsh(S)return2/ (lam[0] + lam[-1]), (lam[-1] - lam[0]) / (lam[-1] + lam[0])S = np.array([[2.0, 1.0], [1.0, 2.0]])thin = np.diag([9.0, 1.0])rescaled = np.eye(2) # the thin bowl after dividing feature 1 by 3for name, M, x0 in [("running bowl", S, [1, 0]), ("thin bowl", thin, [1, 2.5]), ("rescaled", rescaled, [3, 2.5])]: eta, rate = best_step(M)print(f"{name:13s} kappa={np.linalg.cond(M):.0f} eta*={eta:.2f} factor={rate:.2f} steps={descend(M, x0, eta)}")print("running bowl, eta=0.1 (safe, slow):", descend(S, [1, 0], 0.1), "steps")print("running bowl, eta=0.7 (too big): ", descend(S, [1, 0], 0.7))
This module’s interactive, the condition explorer, lives in lesson M03.8.2. The thinness of its ellipse of solutions is measured by the same kind of ratio, \(\sigma_1/\sigma_2\); for a symmetric positive definite \(\mat{S}\) the singular values are the eigenvalues, so it is the \(\kappa\) that sets the zigzag here. Try the Identity and Nearly parallel presets and compare their read-outs. One caution: gradient descent on a least-squares loss \({\tfrac12\norm{\mat{A}\vect{w} - \vect{y}}^2}\) walks on the bowl of \(\mat{A}\T\mat{A}\), whose condition number is \({\kappa(\mat{A})^2}\) (M03.8.2).
Pitfalls
M03.8.4-F5
Wrong beside right. On the thin bowl the best fixed step zigzags across the steep direction and needs 62 steps; after rescaling, one step reaches the minimum.
“If it is slow, take bigger steps.”
The step size is capped by the steepest direction: beyond \(2/\lambda_{\max}\) the error grows along \(\vect{q}_1\). On the running bowl \({\eta = 0.7}\) diverges, although it is only 40% above the best step. The flat direction stays slow because the steep one forbids the step it would need. Deep Learning (section 4.3.1) describes the same trade-off for the Hessian of a loss.
“The zigzag is a bug in the step size.”
The zigzag is the steep coordinate flipping sign, \({1 - \eta\lambda_{\max} < 0}\), and it happens at the best fixed step itself. A smaller step removes it but makes the flat coordinate slower still. Only changing the shape of the bowl, by rescaling or by a method that uses curvature (M08.5), removes the trade-off.
“After standardising, gradient descent is always fast.”
Standardising makes every feature’s variance 1, so for two standardised features with correlation \(r\) the bowl’s matrix is the correlation matrix, with eigenvalues \({1 + r}\) and \({1 - r}\) and \({\kappa = (1 + r)/(1 - r)}\). Two features with \({r = 0.99}\) still give \({\kappa = 199}\). Rescaling cures units, not near-repeats, exactly as in M03.8.3.
Check yourself
Recall
1. In eigen-coordinates, what does one step of gradient descent on \(\tfrac12\vect{x}\T\mat{S}\vect{x}\) do?
Show answer
It multiplies the coordinate along \(\vect{q}_i\) by \({1 - \eta\lambda_i}\), each independently of the others.
2. For which step sizes does gradient descent converge on a positive definite quadratic?
Show answer
For \({0 < \eta < 2/\lambda_{\max}}\).
3. What are the best fixed step and its factor per step?
4. Roughly how does the number of steps grow with \(\kappa\)?
Show answer
In proportion to it: about \({(\kappa/2)\ln(1/\epsilon)}\) steps to shrink the error to a fraction \(\epsilon\) of its start, about \({6.9\,\kappa}\) for a million-fold cut.
5. Why is rescaling the features a form of preconditioning?
Show answer
Changing the variables by a diagonal matrix \(\mat{D}\) turns the bowl’s matrix \(\mat{S}\) into \(\mat{D}\mat{S}\mat{D}\); a good choice of \(\mat{D}\) lowers its condition number and so speeds up gradient descent.
Exercises
1.★ For \({\mat{S} = \operatorname{diag}(4, 1)}\), find the range of stable steps, the best fixed step, its factor, and the number of steps for a million-fold cut.
Show solution
\({\lambda_{\max} = 4}\), so the steps with \({0 < \eta < 0.5}\) are stable. The best step is \({2/(1 + 4) = 0.4}\), and the factors are \({1 - 1.6 = -0.6}\) and \({1 - 0.4 = 0.6}\), both of size \({0.6 = (4 - 1)/(4 + 1)}\). Then \({0.6^t \le 10^{-6}}\) needs \({t \ge 6\ln 10/\ln(1/0.6) \approx 27.05}\), so 28 steps.
2.★★ Run gradient descent on the running saddle, \(\mat{S}\) with rows \({(1, 2)}\) and \({(2, 1)}\) and eigenvalues 3 and \({-1}\). Show that for every \({\eta > 0}\) the coordinate along the eigenvector for \({-1}\) grows, and say what that means.
Show solution
The derivation of steps 1 to 3 never used positive definiteness, so the coordinate along the eigenvector for \({\lambda = -1}\) is multiplied by \({1 - \eta(-1) = 1 + \eta > 1}\) each step. Unless it is exactly 0 at the start, it grows like \({(1 + \eta)^t}\): the iterates slide off the saddle along \({(1, -1)/\sqrt2}\), downhill for ever, because \(f\) has no minimum. This is the escape seen in the interactive of M03.4.
3.★★★ Show that \({\ln\big((\kappa + 1)/(\kappa - 1)\big)} \approx {2/\kappa}\) for large \(\kappa\), and deduce the step count \({t \approx (\kappa/2)\ln(1/\epsilon)}\).
Show solution
Write \(\frac{\kappa + 1}{\kappa - 1} = \frac{1 + 1/\kappa}{1 - 1/\kappa}\), so its logarithm is \({\ln(1 + h) - \ln(1 - h)}\) with \({h = 1/\kappa}\). The Taylor series of M04.8 give \({\ln(1 + h) = h - h^2/2 + \dots}\) and \({\ln(1 - h) = -h - h^2/2 - \dots}\), so the difference is \({2h + }\) terms in \(h^3\), about \(2/\kappa\). The steps needed satisfy
For \({\kappa = 100}\) and \({\epsilon = 10^{-6}}\) this gives 690.8, against the exact count of 691.
Summary card
On a quadratic bowl, gradient descent runs one race per eigenvalue, and \(\kappa\) sets the pace.
M03.8.4-F1
Steep races finish fast; flat races decide.
\({\vect{x}_{t+1}} = {(\mat{I} - \eta\mat{S})\vect{x}_t}\); along \(\vect{q}_i\): multiply by \({1 - \eta\lambda_i}\).
Stable exactly when \({0 < \eta < 2/\lambda_{\max}}\).
Best fixed step \({\eta^* = 2/(\lambda_{\min} + \lambda_{\max})}\), factor \({(\kappa - 1)/(\kappa + 1)}\), about \({(\kappa/2)\ln(1/\epsilon)}\) steps.
Rescaling features is preconditioning: \(\mat{S} \to \mat{D}\mat{S}\mat{D}\).
Sources and next steps
Sources. Each was opened and checked against this lesson on 15 November 2026.
Gilbert Strang, Lecture 22: Gradient descent: downhill to a minimum, MIT OpenCourseWare 18.065 (Spring 2018). Its example is \({F = \tfrac12(x^2 + by^2)}\): for small \(b\) the path zigzags towards the origin and each step multiplies by \({(b - 1)/(b + 1)}\).
Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning, section 4.3.1: the condition number of the Hessian measures how much the second derivatives differ, gradient descent performs poorly when it is large, the step must be small enough not to overshoot in the steep directions; figure 4.6 shows the path bouncing between the walls of a quadratic whose Hessian has condition number 5.
Takeru Miyato, Toshiki Kataoka, Masanori Koyama and Yuichi Yoshida, Spectral Normalization for Generative Adversarial Networks, ICLR 2018. Section 2.1: the spectral norm as the Lipschitz constant of a linear layer (6), the product bound over layers (7) and the normalisation \({\mat{W}/\sigma(\mat{W})}\) (8); section 2.2: estimating \({\sigma(\mat{W})}\) by power iteration; appendix A: reusing the vector from the step before, so that one round of power iteration per update was enough.
Next. The module ends here. M03.9, Markov matrices, graphs and PageRank, uses the max-norm of M03.8.1 to bound eigenvalues; M08.3 develops step sizes for general losses, and M10.3 the error analysis of algorithms.