Why does gradient descent zig-zag on an elliptical bowl with condition number 100?
answer
- two axes, one shared step size
- the steepest curvature sets the ceiling
- the flattest curvature sets the pace
- iterations scale with the curvature ratio
- smaller steps do not change that ratio
basics
~20 sThe steepest direction limits the step size while the flattest direction needs progress. A step small enough to stay stable along the curvature-100 axis moves the curvature-1 axis by only about one percent per iteration, so the path bounces across the narrow valley and creeps along it.
solid answer
~50 sTake `f(x, y) = 0.5 * (x^2 + 100 * y^2)`, curvature 1 along x and 100 along y, so the condition number is 100. The gradient is `(x, 100 * y)` and the two coordinates decouple: `x <- (1 - eta) * x` and `y <- (1 - 100 * eta) * y`. Stability is governed by the steeper axis, forcing `eta < 2 / 100 = 0.02`. Push eta near that limit and the y factor is close to -1, so y flips sign every step — that is the visible zig-zag across the valley. But the same eta gives x a factor near 0.98, so the long axis contracts by about two percent per iteration and needs hundreds of steps. Iteration count scales roughly linearly with the condition number. Shrinking eta removes the oscillation but slows the flat direction further; the real fix is to rescale the coordinates so the curvatures are comparable.
go deeper
Recall that a stretched, elongated bowl makes gradient descent bounce across the narrow direction and crawl along the long one, and that feature scales are a common cause.
Split the quadratic into its two decoupled coordinate recursions, show that the steep axis caps the step size and the shallow axis then contracts at roughly 1 - eta, and state that iterations scale with the condition number.
Recognise the signature in real runs — sharp drop then long plateau, some parameters oscillating while others drift — and reach for rescaling or reparametrising rather than another step-size sweep.
Own conditioning as a modelling and pipeline decision: which feature transforms and parametrisation the team standardises on, so training cost is not silently multiplied by geometry nobody inspected.
## The model surface Use `f(x, y) = 0.5 * (x^2 + 100 * y^2)`. Its level sets are ellipses stretched ten times further along x than along y, and the second derivatives are 1 along x and 100 along y. The condition number of the problem — here the ratio of the largest curvature to the smallest, written kappa — is 100. This single number predicts almost everything about how gradient descent behaves on the surface. ## Why the two axes fight each other The gradient is `(x, 100 * y)`, so with a constant step size eta the update splits into two independent scalar recursions: ``` x <- (1 - eta) * x y <- (1 - 100 * eta) * y ``` Each one converges only if its multiplier has absolute value below 1. The y recursion demands `eta < 2 / 100 = 0.02`; the x recursion would happily accept anything up to `eta < 2`. A single shared eta must satisfy the stricter constraint, so the steepest direction sets the ceiling and the flattest direction pays for it. Pick `eta = 0.019`, just inside the limit. Then the y multiplier is `1 - 1.9 = -0.9`: y alternates sign each iteration while shrinking by ten percent — that alternation, drawn on the contour plot, is the zig-zag across the narrow valley. Meanwhile the x multiplier is `1 - 0.019 = 0.981`, so the long axis shrinks by under two percent per iteration. Reducing x by a factor of a thousand takes roughly 360 iterations. The picture is a path that rattles rapidly from wall to wall while inching toward the far end. ## The rate in terms of kappa For a quadratic with smallest curvature mu and largest curvature L, the best constant step size is `2 / (L + mu)`, and the distance to the optimum then contracts by a factor `(kappa - 1) / (kappa + 1)` per iteration, where `kappa = L / mu`. With kappa = 100 that is `99 / 101`, about 0.980 per step. Because `(kappa - 1) / (kappa + 1)` is approximately `1 - 2 / kappa`, the number of iterations for a fixed accuracy grows roughly **linearly in kappa**. Ten times more elongation, ten times more iterations. That is the headline result to be able to state. ## Curved valleys make it worse The elliptical bowl is the easy version because the valley floor is a straight line. The classic hard case is the Rosenbrock banana: a long, narrow, *curved* valley. There the direction of the shallow axis rotates as you move, so a fixed step that is safe against the local wall curvature also has to keep re-aiming along a floor that keeps bending. Descent crawls along the banana valley with many tiny zig-zag steps, and the loss curve shows a fast initial drop into the valley followed by an extremely long, nearly flat tail. Seeing that shape should make you suspect conditioning, not a bug. ## What you actually observe Three symptoms travel together: 1. The loss drops sharply for a few iterations and then flattens into a long plateau that is still, on close inspection, decreasing. 2. Some parameter traces oscillate in sign from iteration to iteration while others drift slowly and monotonically. 3. Lowering the learning rate removes the oscillation but makes the plateau even flatter — a strong signal that you are conditioning-limited rather than step-size-limited in the naive sense. ## What helps, and what does not **Shrinking eta does not fix it.** It cures the visible bouncing, but the slow direction was already the bottleneck and now moves even slower. Nothing about the ratio of the two curvatures has changed. **Rescaling the coordinates does.** The condition number is a property of the objective *as parametrised*. If the elongation comes from features measured on wildly different scales — one in units of 1 and another in units of 10,000 — standardising them so each has comparable spread pulls the curvatures toward one another and drops kappa directly. The same goes for reparametrising a variable that enters the loss with a very different sensitivity. This is why input scaling has such an outsized effect on how a first-order method trains: it is not cosmetic, it changes the geometry the algorithm has to traverse. **Reformulating the objective** can help too — for example, centring predictors so that an intercept term does not sit on a wildly different curvature from the slopes. ## The interview point The answer that scores is not just the word oscillation. It is the mechanism: one shared step size must satisfy the steepest curvature, the flattest curvature therefore converges at a rate set by the ratio, the ratio is the condition number, iteration count scales with it, and the leverage is in changing the ratio rather than in changing the step size.
- Would simply lowering the learning rate fix the slow progress on such a bowl?No. A smaller eta removes the alternating overshoot along the steep axis, so the path looks tidier, but the shallow axis contracts by a factor 1 - eta per step and shrinking eta makes that even closer to one. The bottleneck is the ratio of the curvatures, which the step size cannot change.
- How does standardising input features change the condition number of a least-squares loss?Feature scale enters the curvature directly: a predictor with a much larger spread produces a much steeper direction in the loss. Putting predictors on comparable scales, and centring them, brings the curvatures closer together and lowers kappa, which cuts the iteration count roughly proportionally. It is a reparametrisation of the same problem, not a change to the model being fitted.
- Roughly how many more iterations does kappa = 1000 need than kappa = 10?About a hundred times more, since the per-iteration contraction factor behaves like 1 - 2 / kappa and the iterations to a fixed accuracy therefore grow roughly linearly in kappa. That linear scaling is the practical reason a badly scaled problem can look untrainable even when it is perfectly convex and has a unique minimum.
Rolling a marble down a long narrow trough: it races back and forth between the steep side walls while barely making progress along the gentle slope toward the far end.
saying these in an interview costs you the question
- Says zig-zagging means the learning rate is simply too large
- Claims a smaller step size fixes ill-conditioning
- Thinks the plateau means the method has converged
- Believes convexity alone guarantees fast convergence
- Cannot connect elongated contours to a ratio of curvatures