Rates of Convergence
"Converges" is not enough: a method that gains one digit per thousand iterations and one that doubles its digits every iteration both converge. The rate of convergence classifies how fast the error goes to zero, and it is the main way to compare the methods of this part.
The four classes
| Rate | Definition | Digits gained per step | Typical method |
|---|---|---|---|
| sublinear | slower than any geometric sequence, e.g. | fewer and fewer | gradient descent on non-strongly-convex , SGD |
| linear | with | constant, | gradient descent on strongly convex |
| superlinear | growing | BFGS, L-BFGS (often) | |
| quadratic | doubling | Newton's method near the solution |
Linear convergence with gains one digit every 22 steps; with , one digit every 3.3 steps. Quadratic convergence goes from to to to : four steps from two digits to full double precision.
Measuring the rate from a run
Given a sequence of errors, the ratios reveal linear convergence and approaches the order (1 for linear, 2 for quadratic):
import numpy as np
# solve x^2 = 2 three ways and record errors
root = np.sqrt(2.0)
def errors(update, x0, n):
x, out = x0, []
for _ in range(n):
x = update(x); out.append(abs(x - root))
return out
newton = errors(lambda x: x - (x * x - 2) / (2 * x), 1.0, 5)
fixed = errors(lambda x: x - 0.2 * (x * x - 2), 1.0, 12) # gradient-like fixed step
print("Newton errors:", [f"{e:.1e}" for e in newton])
print("fixed-step errors:", [f"{e:.1e}" for e in fixed[::2]])
ratios = [fixed[k + 1] / fixed[k] for k in range(6, 11)]
print("fixed-step ratios e(k+1)/e(k):", np.round(ratios, 4))
print("Newton orders log e(k+1)/log e(k):", np.round([np.log(newton[k + 1]) / np.log(newton[k]) for k in range(2)], 3))Newton errors: ['8.6e-02', '2.5e-03', '2.1e-06', '1.6e-12', '0.0e+00']
fixed-step errors: ['2.1e-01', '4.6e-02', '9.0e-03', '1.7e-03', '3.2e-04', '6.1e-05']
fixed-step ratios e(k+1)/e(k): [0.4347 0.4345 0.4344 0.4343 0.4343]
Newton orders log e(k+1)/log e(k): [2.447 2.173]
The fixed-step ratios settle at , the derivative of the update map at the root, so that iteration is linear. Newton's errors square at each step until they hit rounding level.
Sublinear rates
Without strong convexity, gradient descent on an -smooth convex function only guarantees ; accelerated methods get ; SGD with decreasing steps gets . To gain one more digit, a method needs 10 times as many iterations.
import numpy as np
# f(x) = x^4 is convex but not strongly convex at 0: gradient descent is sublinear
x, t = 1.0, 0.1
for k in range(1, 100001):
x -= t * 4 * x**3
if k in (10, 100, 1000, 10000, 100000):
print(f"k = {k:6d}: f - f* = {x**4:.2e}")k = 10: f - f* = 8.47e-03
k = 100: f - f* = 1.41e-04
k = 1000: f - f* = 1.54e-06
k = 10000: f - f* = 1.56e-08
k = 100000: f - f* = 1.56e-10
Each factor of 10 in iterations buys only a factor of about 100 in , a power law, not a geometric decay.
Rates versus cost per iteration
The rate is only half the story; total work is the number of iterations times the cost per iteration:
| Method | Cost per iteration ( variables) | Rate |
|---|---|---|
| gradient descent | one gradient, extra | linear |
| L-BFGS | one gradient, extra | superlinear-ish |
| BFGS | one gradient, extra | superlinear |
| Newton | gradient + Hessian, to solve | quadratic |
For in the millions, Newton's solve is impossible, which is why deep learning lives with first-order methods.
In software
- Solver logs (
scipy.optimize.minimize(..., options={"disp": True}), IPOPT, Gurobi) print the residual per iteration; reading the pattern of exponents tells you which rate you are getting and whether something is wrong. - A method that is supposed to be quadratic but looks linear usually has a wrong Hessian or gradient.
Exercises
Exercise 1: Classify
Classify the error sequences: (a) ; (b) ; (c)
Answer
(a) linear, ; (b) quadratic; (c) sublinear.
Solution
(a) has constant ratio 0.1. (b) squares the error each step. (c) has ratios .
Exercise 2: Iterations for linear convergence
With , how many iterations reduce the error from 1 to ?
Answer
About 1375.
Solution
gives .
Exercise 3: Measure an order (code)
The secant method for uses . Estimate its order from the errors.
Answer
Between 1.6 and 1.8, heading for the golden ratio : superlinear but not quadratic.
Solution
import numpy as np
f = lambda x: x * x - 2
a, b, errs = 1.0, 2.0, []
for _ in range(6):
a, b = b, b - f(b) * (b - a) / (f(b) - f(a))
errs.append(abs(b - np.sqrt(2)))
print([f"{e:.1e}" for e in errs])
print([round(float(np.log(errs[k + 1]) / np.log(errs[k])), 3) for k in range(1, 4)])['8.1e-02', '1.4e-02', '4.2e-04', '2.1e-06', '3.2e-10', '2.2e-16']
[1.828, 1.68, 1.675]
The ratios of logarithms (1.83, 1.68, 1.68) drift down toward the theoretical order 1.618; after six steps the error is already at rounding level, so the estimate cannot be refined further.
Test yourself
Errors show…
- linear convergence
- quadratic convergence
- sublinear convergence
- divergence
A linearly convergent method with ratio gains about… decimal digits per iteration.
- 0.3
- 0.5
- 1
- 2
Why don't deep learning frameworks use Newton's method despite its quadratic rate?
- It diverges on all functions
- Forming and solving with the Hessian costs memory and time for millions of parameters
- It needs integer variables
- It only works in one dimension