For least-squares linear regression f(w)=12n∥Xw−y∥22, how does the condition number of X⊤X govern the convergence speed of gradient descent, and why does standardising features speed up gradient descent even though it leaves the closed-form predictions unchanged?

Linear algebra and optimisation, Gradient methods
Level L4 Advanced. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can connect the linear-algebra condition number of the Hessian 1nX⊤X directly to feature scaling and GD convergence.

Key idea

The Hessian of the least-squares loss is H=1nX⊤X, so gradient descent's convergence factor depends on the condition number κ=λmax⁡(H)/λmin⁡(H). Unscaled features on different magnitudes (e.g. 103 vs 1) stretch the error contours into narrow ellipses and inflate κ by up to 106, forcing tiny step sizes.

Steps

  1. Compute the gradient and Hessian: ∇f(w)=1nX⊤(Xw−y) and H=∇2f(w)=1nX⊤X. For full-column-rank X, the eigenvalues of H are λi=σi2/n, where σi are the singular values of X.
  2. Relate κ to GD speed: fixed-step gradient descent must keep η<2/λmax⁡ for stability. With the optimal fixed step η=2λmax⁡+λmin⁡, the parameter error ∥wt−w∗∥2 shrinks each step by κ−1κ+1≈1−2κ, where κ=λmax⁡/λmin⁡=(σmax⁡/σmin⁡)2. Thus steps needed scale linearly with κ.
  3. Show the effect of unscaled features: suppose feature 1 is in millimetres (∼1000) and feature 2 is in metres (∼1). Even if the features are orthogonal, λ1/λ2 scales as 10002/12=106. A step size safe for feature 1 barely moves feature 2.
  4. Contrast with the closed-form solution: replacing X by XD (rescaling columns by an invertible diagonal D) gives new optimal weights w~∗=D−1w∗ and identical predictions XDw~∗=Xw∗, and centring features by subtracting their means is likewise absorbed by an intercept column when present. Closed-form normal equations are invariant to invertible feature scaling, whereas Euclidean gradient descent is not.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Linear algebra and optimisation: Why can deterministic gradient descent take arbitrarily long or get trapped near a strict saddle point, and how do stochastic gradient noise (SGD) or perturbed gradient descent escape strict saddles?
Next in Linear algebra and optimisation: Minimise f(x)=12x⊤Ax−b⊤x with A=(4113), b=(1,2)⊤ and x0=0 using the conjugate gradient method. How do you show that it reaches the exact minimiser in two steps, and why does this happen?