TExcelTAD
Home › Optimization › Smoothness, Strong Convexity and Conditioning

Smoothness, Strong Convexity and Conditioning

Convexity tells you that a method will find the minimum. Two more numbers tell you how fast: the smoothness constant LL bounds how sharply the function curves up, and the strong convexity constant μ\mu guarantees it curves up at least a little. Their ratio, the condition number, predicts the speed of almost every first-order method.

Definitions

A differentiable ff is LL-smooth if its gradient is LL-Lipschitz, ∥∇f(x)−∇f(y)∥≤L∥x−y∥\lVert \nabla f(\mathbf{x}) - \nabla f(\mathbf{y}) \rVert \le L\lVert \mathbf{x} - \mathbf{y} \rVert. For twice-differentiable ff this means all Hessian eigenvalues are at most LL. It gives a quadratic upper bound:

f(y)≤f(x)+∇f(x)T(y−x)+L2∥y−x∥2f(\mathbf{y}) \le f(\mathbf{x}) + \nabla f(\mathbf{x})^T(\mathbf{y} - \mathbf{x}) + \frac{L}{2}\lVert \mathbf{y} - \mathbf{x} \rVert^2

ff is μ\mu-strongly convex (μ>0\mu > 0) if f(x)−μ2∥x∥2f(\mathbf{x}) - \frac{\mu}{2}\lVert \mathbf{x} \rVert^2 is convex, i.e. all Hessian eigenvalues are at least μ\mu. It gives a quadratic lower bound:

f(y)≥f(x)+∇f(x)T(y−x)+μ2∥y−x∥2f(\mathbf{y}) \ge f(\mathbf{x}) + \nabla f(\mathbf{x})^T(\mathbf{y} - \mathbf{x}) + \frac{\mu}{2}\lVert \mathbf{y} - \mathbf{x} \rVert^2

For a quadratic f(x)=12xTQxf(\mathbf{x}) = \frac{1}{2}\mathbf{x}^TQ\mathbf{x}, L=λmax⁡(Q)L = \lambda_{\max}(Q) and μ=λmin⁡(Q)\mu = \lambda_{\min}(Q), and the condition number is κ=L/μ\kappa = L/\mu.

What the upper bound buys: the step 1/L1/L

Minimizing the upper bound over y\mathbf{y} gives y=x−1L∇f(x)\mathbf{y} = \mathbf{x} - \frac{1}{L}\nabla f(\mathbf{x}), the gradient step with step size 1/L1/L, and guarantees a decrease:

f(x−1L∇f(x))≤f(x)−12L∥∇f(x)∥2f\left(\mathbf{x} - \tfrac{1}{L}\nabla f(\mathbf{x})\right) \le f(\mathbf{x}) - \frac{1}{2L}\lVert \nabla f(\mathbf{x}) \rVert^2

With strong convexity as well, the distance to the minimum shrinks by at least the factor 1−μ/L=1−1/κ1 - \mu/L = 1 - 1/\kappa per step. Since (1−1/κ)k≈e−k/κ(1 - 1/\kappa)^k \approx e^{-k/\kappa}, each extra digit of accuracy costs a number of steps proportional to κ\kappa.

python · try it yourself
import numpy as np

def gd_steps(kappa, tol=1e-8):
    Q = np.diag([1.0, kappa])            # mu = 1, L = kappa
    x = np.array([1.0, 1.0]); f0 = 0.5 * x @ Q @ x
    for k in range(1, 10**6):
        x = x - (1 / kappa) * (Q @ x)
        if 0.5 * x @ Q @ x < tol * f0:
            return k
for kappa in (2, 10, 100, 1000):
    print(f"kappa = {kappa:5d}: {gd_steps(kappa):6d} steps to reduce f by 1e8")
kappa =     2:     13 steps to reduce f by 1e8
kappa =    10:     77 steps to reduce f by 1e8
kappa =   100:    687 steps to reduce f by 1e8
kappa =  1000:   5754 steps to reduce f by 1e8

The step count grows in proportion to κ\kappa.

Seeing conditioning

Level sets of a well-conditioned function are round; of an ill-conditioned one, long thin ellipses. Gradient descent steps across the narrow direction and barely moves along the long one, zig-zagging. Rescaling the variables (preconditioning) makes the level sets rounder:

python · try it yourself
import numpy as np

Q = np.array([[50.0, 0.0], [0.0, 1.0]])
print("kappa before:", np.linalg.cond(Q))
D = np.diag(1 / np.sqrt(np.diag(Q)))            # diagonal (Jacobi) scaling, x = D z
print("kappa after scaling:", np.linalg.cond(D @ Q @ D))
Q2 = np.array([[50.0, 7.0], [7.0, 1.0]])         # a rotated, correlated version
D2 = np.diag(1 / np.sqrt(np.diag(Q2)))
print("correlated: before", round(np.linalg.cond(Q2), 1), " after diagonal scaling", round(np.linalg.cond(D2 @ Q2 @ D2), 1))
kappa before: 50.0
kappa after scaling: 1.0
correlated: before 2599.0  after diagonal scaling 198.0

Diagonal scaling fixes axis-aligned stretching completely but cannot remove strong correlation between variables; that needs a full preconditioner such as the Hessian itself, which is Newton's Method.

Estimating LL in practice

For least squares f(x)=12∥Ax−b∥2f(\mathbf{x}) = \frac{1}{2}\lVert A\mathbf{x} - \mathbf{b} \rVert^2 the Hessian is ATAA^TA, so L=σmax⁡(A)2L = \sigma_{\max}(A)^2, computable with a few power iterations. For general functions, backtracking line search (Line Search and Backtracking) finds a usable step without knowing LL.

In software

  • Feature standardization (StandardScaler) before training is preconditioning: it lowers κ\kappa so gradient methods converge faster.
  • Batch normalization and Adam's per-coordinate scaling are learned or adaptive diagonal preconditioners (Adam and AdamW).
  • np.linalg.cond reports κ\kappa of a matrix; a huge value warns that both solving and optimizing will be hard.

Exercises

Exercise 1: Read off LL and μ\mu

For f(x,y)=3x2+12y2f(x, y) = 3x^2 + 12y^2, find LL, μ\mu, κ\kappa and the safe step 1/L1/L.

Answer

L=24L = 24, μ=6\mu = 6, κ=4\kappa = 4, step 1/241/24.

Solution

The Hessian is diag⁡(6,24)\operatorname{diag}(6, 24), so μ=6\mu = 6 and L=24L = 24.

Exercise 2: Not strongly convex

Is f(x)=x4f(x) = x^4 strongly convex? Is it LL-smooth on R\mathbb{R}?

Answer

Neither.

Solution

f′′(x)=12x2f''(x) = 12x^2 is 0 at x=0x = 0, so no μ>0\mu > 0 works, and it grows without bound, so no LL works. Gradient descent on x4x^4 slows down near 0 because the curvature vanishes there.

Exercise 3: Lipschitz constant of least squares (code)

Compute LL for 12∥Ax−b∥2\frac{1}{2}\lVert A\mathbf{x} - \mathbf{b} \rVert^2 with A=[123456]A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix} in two ways.

Answer

L≈90.74L \approx 90.74.

Solution
python · try it yourself
import numpy as np
A = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
print(round(float(np.linalg.eigvalsh(A.T @ A).max()), 4), round(float(np.linalg.norm(A, 2)**2), 4))
90.7355 90.7355

The largest eigenvalue of ATAA^TA equals the squared largest singular value of AA.

Test yourself

For f(x)=12xTQxf(\mathbf{x}) = \frac{1}{2}\mathbf{x}^TQ\mathbf{x} with Q≻0Q \succ 0, the condition number is…

  1. λmax⁡(Q)⋅λmin⁡(Q)\lambda_{\max}(Q) \cdot \lambda_{\min}(Q)
  2. λmax⁡(Q)/λmin⁡(Q)\lambda_{\max}(Q) / \lambda_{\min}(Q)
  3. det⁡Q\det Q
  4. tr⁡Q\operatorname{tr} Q

With an LL-smooth function, the step size that minimizes the quadratic upper bound is…

  1. LL
  2. 2/L2/L
  3. 1/L1/L
  4. 1/μ1/\mu

Doubling the condition number of a strongly convex quadratic roughly… the number of gradient descent steps.

  1. halves
  2. does not change
  3. doubles
  4. squares