AnyLearn
All lessons
Mathadvanced

Newton's method and the interior point revolution

Second derivatives buy something gradients cannot: a step shaped by curvature, immune to conditioning, converging quadratically. This lesson builds Newton's method, then layers it on a log barrier to get interior point methods, the machinery that made large constrained problems solvable with a certificate rather than a hope.

Updated · AI-authored, review-gated · how lessons are made

Not signed in: your progress and quiz score won't be saved.
Progress1 / 13

Fitting a bowl instead of a plane

Gradient descent builds a linear model at the current point and steps along it, with a scalar η\eta standing in for everything the model does not know. Newton's method builds a quadratic model instead:

f(x+v)f(x)+f(x)v+12v2f(x)vf(x + v) \approx f(x) + \nabla f(x)^\top v + \tfrac{1}{2} v^\top \nabla^2 f(x)\, v

Minimising that over vv is a calculus exercise. Differentiate, set to zero, and solve:

vnt=[2f(x)]1f(x)v_{\text{nt}} = -\left[\nabla^2 f(x)\right]^{-1} \nabla f(x)

Notice what replaced the step size. Gradient descent multiplies the gradient by a scalar, shrinking every direction equally. Newton multiplies it by the inverse Hessian, which stretches and rotates: long steps along flat directions, short steps along steep ones, decided separately for each direction at every iteration.

Full lesson text

All 13 steps on one page, for reading, reference, and search.

Show

1. Fitting a bowl instead of a plane

Gradient descent builds a linear model at the current point and steps along it, with a scalar η\eta standing in for everything the model does not know. Newton's method builds a quadratic model instead:

f(x+v)f(x)+f(x)v+12v2f(x)vf(x + v) \approx f(x) + \nabla f(x)^\top v + \tfrac{1}{2} v^\top \nabla^2 f(x)\, v

Minimising that over vv is a calculus exercise. Differentiate, set to zero, and solve:

vnt=[2f(x)]1f(x)v_{\text{nt}} = -\left[\nabla^2 f(x)\right]^{-1} \nabla f(x)

Notice what replaced the step size. Gradient descent multiplies the gradient by a scalar, shrinking every direction equally. Newton multiplies it by the inverse Hessian, which stretches and rotates: long steps along flat directions, short steps along steep ones, decided separately for each direction at every iteration.

2. Quadratic convergence, in digits

Near the solution, Newton's method satisfies an error recursion of the form

xk+1xCxkx2\|x_{k+1} - x^\star\| \le C \|x_k - x^\star\|^2

The error is squared each step. In terms of correct decimal digits, that means the count doubles.

IterationCorrect digits
kk2
k+1k+14
k+2k+28
k+3k+316

Gotcha: This holds only in the local phase, once the iterate is close enough. Started far away, an undamped Newton step can overshoot badly or head uphill, since the quadratic model is only trustworthy nearby. Real implementations run a damped phase first, scaling the step until progress is verified, and switch to full steps once the local criterion is met.

3. One step, exactly, on a quadratic

If the function really is quadratic, the model is not an approximation, so Newton lands on the optimum immediately. Compare this with the previous lesson, where gradient descent on κ=1000\kappa = 1000 was still at about 0.45 after a hundred steps.

import numpy as np

A = np.diag([1.0, 1000.0])          # condition number 1000
x = np.array([1.0, 1.0])            # f(x) = 0.5 * x.T @ A @ x

grad = A @ x
step = np.linalg.solve(A, grad)     # the Newton step, inverse Hessian times gradient
x_next = x - step

print(x_next, 0.5 * x_next @ A @ x_next)
# [0. 0.] 0.0

The Hessian here is AA itself, so the Newton step is A1Ax=xA^{-1}Ax = x, landing exactly on zero. The condition number never entered the calculation. That is not a coincidence, and the next step explains why.

4. Affine invariance

Change variables by any invertible linear map, x=Tyx = Ty, and run Newton's method on the transformed problem. The iterates you get are the images under TT of the iterates you would have got on the original. The method is affine invariant: it produces the same sequence of points regardless of how the problem is parameterised.

Key idea: Gradient descent is not affine invariant, and its entire dependence on the condition number is a symptom of that. Conditioning is a property of the coordinates you chose. Newton's method effectively chooses its own coordinates at every step, using the Hessian as the metric, so a badly scaled problem and a well scaled one look identical to it.

This is why feature normalisation transforms how gradient descent behaves and does essentially nothing for a Newton-based solver.

5. What the second derivative costs

Newton's advantage is bought with work per iteration, and the trade is stark.

Gradient descentNewton's method
Per-iteration costO(n)O(n) beyond the gradientforms and solves an n×nn \times n system, O(n3)O(n^3) dense
Memorythe gradient, O(n)O(n)the Hessian, O(n2)O(n^2)
Iterations neededdepends on κ\kappafew, and largely independent of conditioning
Practical ceilingvery large nnmodest nn, unless structure is exploited

At n=109n = 10^9, which is ordinary for a neural network, an n×nn \times n Hessian cannot be written down, let alone factorised. This is the honest reason deep learning runs on first-order methods: not that curvature would fail to help, but that nobody can afford it.

The middle ground is quasi-Newton methods such as L-BFGS, which build a low-rank approximation of the inverse Hessian from past gradients at O(n)O(n) memory.

6. Constraints, and a wall you cannot step through

Everything so far minimised over all of Rn\mathbb{R}^n. Real problems have constraints:

minimise f0(x)subject to fi(x)0,  i=1,,m,Ax=b\text{minimise } f_0(x) \quad \text{subject to } f_i(x) \le 0,\; i = 1,\dots,m, \quad Ax = b

The previous lesson in this path built the machinery for reasoning about such problems: the Lagrangian, the dual, and the KKT conditions that characterise an optimum. What that machinery does not supply is an algorithm. KKT tells you how to recognise a solution; it does not tell you how to walk to one.

The obstacle is that the feasible region has a boundary, and the optimum usually sits on it. A method that steps freely will leave the region; a method that stops at the boundary loses the smoothness Newton depends on.

7. Replacing the wall with a slope

The interior point idea is to delete the constraints and add a term that makes approaching the boundary expensive. The logarithmic barrier does exactly that:

ϕ(x)=i=1mlog(fi(x))\phi(x) = -\sum_{i=1}^{m} \log\bigl(-f_i(x)\bigr)

Each term is finite while fi(x)<0f_i(x) < 0, strictly inside the region, and diverges to ++\infty as the constraint becomes tight. Now minimise

tf0(x)+ϕ(x)t f_0(x) + \phi(x)

for a positive parameter tt. This is unconstrained and smooth, so Newton's method applies directly.

Key idea: Small tt weights the barrier heavily and pulls the solution toward the middle of the region. Large tt weights the true objective and lets the solution press against the boundary where the real optimum lives. The barrier turned a hard wall into a slope Newton can descend.

8. The central path, and a certificate that comes free

Let x(t)x^\star(t) be the minimiser for a given tt. As tt sweeps from small to large, those points trace a smooth curve through the interior called the central path, ending at the true optimum.

What makes this more than a heuristic is that each point on the path carries its own proof of quality. Boyd and Vandenberghe show that the construction yields feasible dual variables for which the duality gap is exactly

f0(x(t))pmtf_0(x^\star(t)) - p^\star \le \frac{m}{t}

where mm is the number of inequality constraints.

Key idea: That is a certificate, and it is why the duality lesson had to come first. At t=106t = 10^6 with m=100m = 100 constraints, you are provably within 10410^{-4} of optimal. Not estimated, not converged-looking. Bounded, by weak duality.

9. The barrier method loop

The outer loop moves along the central path; the inner loop is Newton's method solving one smooth unconstrained problem. Warm starting each inner solve from the previous centre is what keeps the total Newton count low.

flowchart LR
  A["Choose t and a strictly feasible starting x"] --> B["Minimise t*f0 + barrier, by Newton"]
  B --> C["Duality gap is at most m/t"]
  C --> D["Is the gap below tolerance?"]
  D --> E["Return x with a certified bound"]
  D --> F["Multiply t by a constant factor"]
  F --> B

10. Why the inner solves stay cheap

Newton's method converges quickly near a solution, but the classical analysis depends on constants tied to the coordinate system, which is unsatisfying for a method that is supposed to be affine invariant.

Nesterov and Nemirovski resolved this in 1994 with self-concordance, a condition on how fast a function's third derivative can change relative to its second. Log barriers satisfy it. For a self-concordant function, using the Newton decrement λ\lambda as the measure of proximity, the analysis gives a clean statement: once λ1/4\lambda \le 1/4, a full Newton step yields λ+2λ2\lambda^{+} \le 2\lambda^2.

That bound is affine invariant, involves no unknown problem constants, and converts the whole barrier method into a polynomial-time algorithm rather than a procedure that merely works well.

11. How linear programming became polynomial

Two separate questions run through this timeline: whether a polynomial-time algorithm exists at all, settled in 1979, and whether one could also be fast in practice, settled in 1984. Simplex remains competitive and is still widely used.

timeline
  title Complexity of linear programming
  1947 : Dantzig publishes the simplex method
  1972 : Klee and Minty construct an instance forcing 2^n vertices
  1979 : Khachiyan proves the ellipsoid method is polynomial at O(n^6 L)
  1984 : Karmarkar gives an interior point method at O(n^3.5 L)
  1994 : Nesterov and Nemirovski generalise it through self-concordance

12. How many Newton steps does this really take?

The theory bounds the work. What surprises people is the empirical behaviour.

Predict first

A barrier method solves a convex problem with thousands of variables and hundreds of constraints. Roughly how many Newton steps in total, across all outer iterations?

This is why a convex problem with a million variables is a scheduling exercise rather than a research project.

13. Where this leaves you

Modern solvers refine all of this. Primal-dual interior point methods work on the primal and dual iterates together rather than following the central path exactly, and they exploit sparsity so the O(n3)O(n^3) factorisation cost applies to structure rather than to raw dimension.

The honest boundary is worth stating plainly. These guarantees are guarantees about convex problems. Point an interior point solver at a nonconvex objective and the barrier still keeps you feasible, Newton still converges to something, and the certificate is gone: m/tm/t bounds the gap to the local optimum only, and weak duality no longer closes.

That is the arc of this path. Convexity said a global optimum exists and can be certified. Duality supplied the certificate. Newton made the steps cheap enough to be worth taking, and the barrier let them reach a constrained boundary. None of it survives the loss of the first assumption.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. What replaces the scalar step size when you move from gradient descent to Newton's method?
    • A larger constant, since curvature permits bigger steps
    • The inverse Hessian, which rescales each direction separately
    • A line search over the gradient direction
    • The gradient norm, used to normalise the step
  2. Why is Newton's method insensitive to a problem's condition number?
    • It uses a much smaller step size, avoiding the zigzag
    • It is affine invariant, so a rescaling of variables produces the same iterate sequence
    • It converges before conditioning has time to matter
    • It only applies to problems with condition number near 1
  3. In the barrier method, what does increasing the parameter t do?
    • Pulls the iterate toward the centre of the feasible region
    • Weights the true objective more, letting the solution approach the boundary
    • Reduces the number of inequality constraints considered
    • Guarantees the Hessian becomes positive definite
  4. A barrier method runs with 200 inequality constraints at t = 10^5. What can you certify?
    • The iterate is exactly optimal
    • The iterate is within 2 x 10^-3 of the optimal value
    • The iterate is within 200 of the optimal value
    • Nothing, since the barrier is only a heuristic
  5. What did Khachiyan's 1979 ellipsoid result establish that Karmarkar's 1984 method then improved on?
    • That linear programs can be solved in polynomial time, but not yet practically
    • That the simplex method is exponential in the worst case
    • That interior point methods converge quadratically
    • That linear programming is NP-hard

Related lessons

Math
intermediate

Gradient descent: choosing the step and knowing the rate

Gradient descent is three lines of code and a hundred years of theory. This lesson derives why a safe step size is one over the smoothness constant, why the condition number governs everything, and why acceleration reaching order one over k squared is provably the best any first-order method can do.

11 steps·~17 min
Math
intermediate

Convexity: the property that decides what is solvable

Convexity is what separates optimization problems you can solve with a guarantee from ones you can only hope about. This lesson defines convex sets and functions, proves why every local minimum is global, and gives you the operations that let you recognise convexity without touching a Hessian.

11 steps·~17 min
Math
intermediate

Gradients, Jacobians, and Hessians: Calculus in Many Dimensions

One derivative becomes three objects once a function has many inputs and many outputs. This lesson builds the gradient, the Jacobian and the Hessian, shows what each one actually tells you, and explains why curvature decides how many steps an optimiser needs and why nobody ever writes the Hessian down.

10 steps·~15 min
Programming
intermediate

Benchmarks That Hold Up, and Knowing When to Stop

A benchmark is an experiment, and most are badly designed enough to produce confident wrong answers. This lesson covers what a measurement must control to mean anything, the ways microbenchmarks lie including code the compiler deletes, how to catch regressions in continuous integration despite noisy machines, and how to recognise the point where optimising stops paying.

7 steps·~11 min