Newton, quasi-Newton and Gauss–Newton methods
Before this lesson: lesson 02 (condition number, strong convexity), lesson 03 (rates of gradient descent, Armijo and Wolfe conditions), linear algebra 07 (positive definite matrices, Cholesky), linear algebra 12 (least squares), calculus 03 (Jacobian, Hessian, Taylor's theorem). Time: about 95 minutes, plus the notebook. This is a difficult lesson; take a break after section 3.
Why this matters #
Gradient descent needs about steps (lesson 03). Second-order methods remove most of this dependence on the condition number . They are the standard tools when the number of parameters is moderate and the gradients are exact (full batch):
- logistic regression and other generalized linear models (scikit-learn's
LogisticRegressionuses L-BFGS by default; Newton's method for logistic regression is iteratively reweighted least squares); - fitting physical models to data (
scipy.optimize.curve_fituses Levenberg–Marquardt); - inverse problems with partial differential equations (PDEs), physics-informed neural networks (PINNs), and weather data assimilation, where the main method (incremental 4D-Var) is a Gauss–Newton method.
In deep learning they come back as approximations. The Gauss–Newton and Fisher matrices of this lesson are the starting point of K-FAC and Shampoo (lesson 12). "Why don't we train neural networks with Newton's method?" is also a standard interview question.
1. Predict first #
2. The picture #
Notation for this lesson: is a minimizer and is the error. We write the Hessian as . The letters and are reserved for quasi-Newton methods: approximates the Hessian and approximates its inverse (as in Nocedal and Wright).
Newton in one dimension: fit a parabola, jump to its bottom #
At the current point , Taylor's theorem gives a parabola with the same value, slope and curvature as :
If , the parabola opens upward. Its minimum is where :
This is also Newton's root-finding method applied to the equation : replace by its tangent line and find where the line crosses zero. If is itself a parabola, the model is exact and one step lands on the minimum.
Press Step several times. The grey curve is ; the dashed magenta parabola is the local model at the current point, and the step goes to its stationary point. On from , the log chart of falls faster and faster: the exponent doubles (quadratic convergence). Then try the presets. From the curvature is tiny and the jump goes far away. On the double well from the curvature is negative: the model opens downward and pure Newton moves towards the maximum at 0. Switch to "damped" to see the fixes of section 3.
Newton on a quadratic: the perfect preconditioner #
Take with symmetric positive definite. Then and , so the Newton step from any is
One step, for any condition number. To see why, write the error in the eigenvectors of (eigenvalues ), as in lesson 03. Gradient descent multiplies the component along by : one step size must serve all directions. Newton multiplies the gradient component along by : a large step in a flat direction and a small step in a steep one. Every component becomes exactly 0.
A second way to see it: change variables to . Then , whose level sets are circles, and gradient descent with jumps to the centre. Mapped back to , this is exactly the Newton step. Newton's method is gradient descent in the coordinates where the function is round.
Drag the point in the left plot. On the left are the elliptic level sets of . The blue arrow is a gradient step : it is perpendicular to the level set, so it does not point at the minimum. The magenta arrow is the Newton step: it points straight at the minimum. On the right the same point is drawn in the coordinates ; the grey grid is the left grid after the change of variables. The level sets are circles, and the gradient step is the magenta arrow again. Set : both arrows on the left point the same way.
with symmetric positive definite and . From any start, how many pure Newton steps reach the minimizer (in exact arithmetic)?
and , so . The quadratic model is the function itself. The condition number changes the cost of solving with in floating point, not the number of Newton steps.
The race on 2D surfaces #
On a non-quadratic function the model is only correct near , so Newton needs several steps. But near a minimizer the model gets better and better, and the error shrinks very fast. The figure compares four methods. Damped Newton shortens the step with a line search when the full step does not decrease enough. BFGS (section 3) does not use the Hessian at all; it learns it from gradients.
Pick a surface, then drag the large start dot. Blue: gradient descent (best fixed step on the quadratic, backtracking elsewhere). Magenta: pure Newton. Violet: damped Newton. Dashed magenta: BFGS. On the rotated quadratic, Newton needs one step for every , while gradient descent needs more steps as grows. On Rosenbrock, pure Newton needs 6 steps and gradient descent about 19,000. On the double well from the default start, pure Newton stops at the saddle point : the Hessian there is not positive definite. Damped Newton (which also fixes negative curvature) and BFGS reach a minimum.
Near , Newton's errors satisfy with . Now . What is , approximately?
: two correct digits become four. The next step gives , then . or would be linear convergence (a fixed factor per step), which is what gradient descent does.
3. Definitions and main results #
The Newton step #
The quadratic model of at is
If , the model is strictly convex and its minimizer solves the linear system
is the Newton step, and pure Newton sets . Solve the system with a Cholesky factorization (about operations; see linear algebra 07). Never form the inverse matrix. If Cholesky fails, the Hessian is not positive definite, and that is useful information.
The number is the Newton decrement (Boyd and Vandenberghe write ). The model predicts the decrease . Stopping when is the standard rule.
Local quadratic convergence #
Why this is true (intuition). The Newton step is exact for a quadratic. A smooth function differs from its quadratic model by a term of order (Taylor), so after division by the Hessian the new error is of order . Squaring a small number makes it much smaller.
Theorem 1 (local quadratic convergence). Let be twice differentiable with an -Lipschitz Hessian, (spectral norm). Let and with . If , then pure Newton satisfies, for every ,
So satisfies and : .
Proof of Theorem 1 (6 steps)
- Since , the Newton step gives .
- Along the segment from to (fundamental theorem of calculus): .
- Put 2 into 1 and write : .
- The two points and are apart. By the Lipschitz condition, the bracket has norm at most .
- So .
- If , Weyl's inequality (linear algebra 17) gives . Then step 5 gives , and gives . So is again in the ball, and induction finishes the proof.
In words: the number of correct digits roughly doubles at every step, once you are close enough. The theorem is local. It says nothing about a start far away (worked example (b) shows a bad one).
Damped Newton, and what goes wrong without positive curvature #
Damped Newton sets , where comes from backtracking from with the Armijo condition (lesson 03). For strongly convex with a Lipschitz Hessian, Boyd and Vandenberghe (§9.5.3) prove two phases:
- Damped phase. Far from , each step decreases by at least a fixed amount .
- Quadratic phase. Once is small enough, the line search always accepts , and Theorem 1 applies.
The total number of steps is at most . The second term is about 6 for any accuracy you can reach in double precision.
If is not positive definite (a nonconvex ), the model has no minimum. Its stationary point can be a maximum or a saddle, so can point uphill or towards a saddle point. In the 1D figure, and Newton moves towards the maximum. In 2D, Newton is attracted to saddle points (lesson 11 studies saddles in neural networks). Common fixes:
- use when the Newton step is not a descent direction;
- add a multiple of the identity, (Nocedal and Wright §3.4);
- replace each eigenvalue of the Hessian by (the "saddle-free Newton" idea, used for the damped Newton path in the 2D figure);
- use a trust region: minimize the model only inside a ball where you trust it (Levenberg–Marquardt below is an example).
Affine invariance #
Let with an invertible matrix , and . The chain rule gives and . So the Newton step in is
The step in is the step in , written in the new coordinates. An Armijo line search uses only values of and the slope , which are also the same. So the iterates satisfy : Newton's method is affine invariant. Its speed does not depend on how you scale or rotate the variables, and so not on . Gradient descent is not: its step in is , which is in . This is why feature scaling matters for gradient descent and not for Newton.
Quasi-Newton methods: the secant condition and BFGS #
Computing and factorizing costs per step. But every step gives, almost for free, the pair
By Taylor, : the change of the gradient shows how the Hessian acts on one direction. A quasi-Newton method keeps a matrix (or ) and asks the new matrix to reproduce the observed change. This is the secant condition:
In 1D it fixes : the secant method. In dimensions it gives equations for unknowns, so we choose the smallest change that satisfies it.
Derivation of BFGS. Change by a symmetric rank-2 matrix built from the two vectors we have: . The secant condition reads
It holds when and . So
The Sherman–Morrison–Woodbury formula inverts this rank-2 change. With , the BFGS inverse update (Broyden, Fletcher, Goldfarb, Shanno, 1970) is
Check of the secant condition: , so the first term vanishes on and . The method then steps along with a line search. Each update costs and no linear system is solved.
Proposition 2 (BFGS keeps positive definiteness). If and , then .
Proof.
- Take and set .
- Then . Both terms are , because and .
- If , the second term is . If , then and the first term is . In both cases .
Where comes from. For strictly convex it always holds. In general the Wolfe curvature condition gives it (lesson 03): with , so , because . This is why BFGS runs with a Wolfe line search.
Two facts about BFGS (Nocedal and Wright, ch. 6). Near a minimizer with it converges superlinearly: with . On a strictly convex quadratic with exact line searches it stops after at most steps, with .
Press Step twice. Left: BFGS with exact line searches on , from the slider, starting from . Right: the ellipse of the current estimate (magenta) and of the true inverse Hessian (dashed). After one step the two ellipses pass through the same point (orange arrow, ): this is the secant condition. After two steps the ellipses coincide and .
On a nonconvex function, a BFGS step gives . You apply the update anyway. What is wrong with ?
The update still satisfies , so . A positive definite matrix gives for every , so is not positive definite, and may point uphill. Implementations skip (or damp) the update, and a Wolfe line search prevents the case.
L-BFGS: BFGS with a short memory #
For , the matrix has entries (8 TB). L-BFGS (limited-memory BFGS) stores only the newest pairs , with . It defines as the result of the BFGS updates with these pairs (oldest first), applied to , where for the newest pair (a scalar estimate of the inverse curvature). The two-loop recursion computes without forming :
- . For from newest to oldest: , then .
- .
- For from oldest to newest: , then .
- .
Why the two loops compute
One BFGS update is with . Unroll updates: is a sum of terms of the form , plus . The first loop applies the to , newest first, and stores the scalars that the terms need. The second loop applies the in the opposite order and adds the terms through . Nocedal and Wright (Algorithm 7.4) give the full proof.
Each loop costs dot products and vector updates: time per step and stored
numbers. Typical memories are to (SciPy's L-BFGS-B uses 10, torch.optim.LBFGS keeps 100).
L-BFGS is the default method for smooth, full-batch problems of any size.
Gauss–Newton for nonlinear least squares #
Many problems have the form , with residuals (model minus data) and Jacobian of size . The chain rule (calculus 08) gives
Linearize the residual, not the gradient: . Then
is a linear least-squares problem (linear algebra 12). Its minimizer is the Gauss–Newton step
This is the Newton equation with the residual-curvature term dropped. Three properties:
- It needs only first derivatives of .
- always. If has full column rank, then : the step is always a descent direction. A Newton step need not be.
- Compute it as the least-squares solution of (QR or
lstsq), not by forming , because .
When is dropping safe? Near , , so
- Zero residual, : then , and convergence is quadratic, like Newton.
- Small residuals or nearly linear : is small and the linear rate is fast.
- Large residuals and curved : the rate is the spectral radius of . If it is larger than 1, Gauss–Newton fails even close to (worked example (d)).
Levenberg–Marquardt: damping as a trust region #
The Levenberg–Marquardt (LM) step adds a damping term (here is the damping parameter, not an eigenvalue):
- : , fast near a small-residual solution.
- : , a short gradient step, safe far from the solution.
- For every the matrix is positive definite, so is a descent direction.
- Trust-region view. minimizes the model among all with (Nocedal and Wright, Theorem 4.1). A large means a small trusted ball; is the Lagrange multiplier of the constraint (lesson 08).
Choosing : the gain ratio. Compare the actual decrease with the decrease the model predicted:
If , accept the step and set and . Otherwise reject it and set , . Start with ; is a common choice (Madsen, Nielsen and Tingleff, Algorithm 3.16, Nielsen's rule). A good model ( near 1) shrinks ; a bad model grows it. Marquardt's variant uses in place of , which makes the step independent of the scale of each parameter.
Press Step, then try the presets. We fit to 9 data points. Left: contours of with the paths of Gauss–Newton (magenta) and Levenberg–Marquardt (violet, adaptive ). Right: the data and the current fits, and on a log scale. With small residuals both methods converge in a few steps. "Start far away" (): the first Gauss–Newton step jumps to and the fit explodes, while LM rejects bad steps, increases and converges. "Large residuals" (data that no decaying exponential fits well): the dropped term is no longer small, and the log chart shows a slower, linear rate. Choose "fixed " and move the slider: a huge gives tiny gradient steps.
In Levenberg–Marquardt you set , much larger than the entries of . What is the step, approximately?
, and for huge the term dominates: . It points downhill but has length about . It is small, not exactly zero. Gauss–Newton is the opposite limit .
Generalized Gauss–Newton, the Fisher matrix, and Hessian-free methods #
For a loss of a model output , the chain rule gives
The generalized Gauss–Newton (GGN) matrix keeps the first term. It is positive semidefinite when is convex in . For the squared error it is . When is the negative log-likelihood of an exponential family with natural parameters (softmax cross-entropy is one), it equals the Fisher information matrix (Martens, arXiv 1412.1193). K-FAC and Shampoo approximate this matrix layer by layer (lesson 12).
You never need the full matrix to use it. The conjugate gradient method (linear algebra 14) solves with products only, and such products cost about two gradient evaluations (calculus 08). Stopping CG early gives truncated Newton or Newton-CG; with the GGN it is the Hessian-free optimization of Martens (2010). Lesson 11 uses the same Hessian-vector products to measure sharpness.
Why not Newton for neural networks? #
- Cost. For parameters, the Hessian has entries, and a Cholesky factorization needs about operations per step.
- Nonconvexity. The Hessian of a network loss has negative eigenvalues; pure Newton is attracted to saddle points.
- Noise. Minibatch curvature is noisy; a quasi-Newton pair from two different minibatches measures noise more than curvature.
What deep learning uses instead: diagonal scaling (Adam, lesson 06), structured approximations of the GGN or Fisher (K-FAC, Shampoo), and orthogonalized updates (Muon), all in lesson 12.
Answers to section 1. (1) One step in both cases. The quadratic model is exact, and Newton is affine invariant, so the substitution changes nothing. Gradient descent with the best step would need about steps at . (2) Towards the maximum : , the model parabola opens downward, and its stationary point is its maximum. The iterates go . (3) Problems with zero residual at the solution, , where . If is linear, everywhere and one step solves the problem.
4. Worked example #
(a) Newton on a 2D quadratic. and . Then and . The Newton step solves , so and .
(b) Newton in 1D: the quadratic rate. , so , and . The Newton map is
From :
| 0 | 2 | 1 | |
| 1 | 1.416667 | 0.417 | 0.417 |
| 2 | 1.110534 | 0.111 | 0.637 |
| 3 | 1.010637 | 0.871 | |
| 4 | 1.000112 | 0.986 | |
| 5 | 1.0000000124 | 1.000 |
The ratio in the last column tends to , so : the exponent doubles at each step.
A bad start. From , the curvature is tiny. The pure step goes to , where (it was ). Far out, , so the iterates come back slowly (22.3, 14.8, 9.9, …) and reach only at . An Armijo line search would reject the first jump: this is the damped phase.
(c) BFGS learns in two steps. Same quadratic, , , , exact line searches for the direction .
- : , , , so . Then , and the update gives . It is already correct in the steep direction, which the first step explored.
- : the step with gives up to rounding, and .
(d) Gauss–Newton, Newton and LM with a nonzero residual (Madsen et al., Example 3.3). with one parameter . For , is a local minimizer with and : the residual is not zero. At :
- , so ;
- only is curved, with , so and ;
- the Gauss–Newton error factor is .
Three cases:
- : is linear, and one Gauss–Newton step solves the problem.
- , : , , and . Gauss–Newton: , then , (factor , linear). Newton uses : , then , (quadratic).
- : factor . From , Gauss–Newton jumps around (, , , …) and never converges, although it starts close to .
One LM step for , , : , so . The predicted decrease is . The actual decrease is . So : accept the step. The new damping is .
In worked example (d), what is the Gauss–Newton error factor near when , and does Gauss–Newton converge there?
The factor is . Its size is below 1, so the error shrinks by about 0.8 per step: slow linear convergence. Newton, which keeps , would converge quadratically here, because .
5. In code #
The code checks examples (b), (c) and (d) and shows what SciPy's quasi-Newton methods learn.
Fraction gives exact rational arithmetic, so the table of (b) has no rounding.
from fractions import Fraction
import numpy as np
from scipy.optimize import minimize, least_squares, rosen, rosen_der, rosen_hess
# (b) Newton on f(x) = x^4/4 - x: the map x+ = (2x^3 + 1)/(3x^2), in exact arithmetic
x, errors = Fraction(2), []
for k in range(6):
errors.append(abs(x - 1))
x = (2 * x**3 + 1) / (3 * x**2)
print([f"{float(e):.2e}" for e in errors])
# ['1.00e+00', '4.17e-01', '1.11e-01', '1.06e-02', '1.12e-04', '1.24e-08']
print([round(float(errors[k + 1] / errors[k] ** 2), 3) for k in range(5)])
# [0.417, 0.637, 0.871, 0.986, 1.0]
# (c) BFGS on f = ½(x1² + 10 x2²) with exact line searches: H2 = A^{-1}
A = np.diag([1.0, 10.0])
x, H = np.array([1.0, 1.0]), np.eye(2)
for k in range(2):
g = A @ x
p = -H @ g
alpha = -(g @ p) / (p @ A @ p) # exact line search on a quadratic
s = alpha * p
y = A @ (x + s) - g
rho = 1.0 / (y @ s)
V = np.eye(2) - rho * np.outer(y, s)
H = V.T @ H @ V + rho * np.outer(s, s) # BFGS inverse update
x = x + s
print(np.allclose(H, np.linalg.inv(A)), np.abs(x).max() < 1e-12) # True True
# Quasi-Newton on Rosenbrock from (-1.2, 1)
x0 = np.array([-1.2, 1.0])
for method in ["BFGS", "L-BFGS-B", "CG"]:
res = minimize(rosen, x0, jac=rosen_der, method=method)
print(f"{method:8s} iterations={res.nit:3d} gradient calls={res.njev:3d}")
# BFGS 32/39, L-BFGS-B 36/44, CG (nonlinear conjugate gradient) 36/77 (SciPy 1.18)
# BFGS learns the curvature: its H at the end vs the true inverse Hessian at (1, 1)
res = minimize(rosen, x0, jac=rosen_der, method="BFGS")
print(np.round(res.hess_inv, 3)) # [[0.502 1.003] [1.003 2.01 ]]
print(np.round(np.linalg.inv(rosen_hess(np.ones(2))), 3)) # [[0.5 1. ] [1. 2.005]]
# (d) Gauss-Newton factor and LM, Madsen et al. Example 3.3; local minimizer x* = 0
def residual(x, a):
return np.array([x[0] + 1, a * x[0] ** 2 + x[0] - 1])
def jac(x, a):
return np.array([[1.0], [2 * a * x[0] + 1]])
for a in [0.0, 0.5, -2.0]:
J, r = jac(np.zeros(1), a), residual(np.zeros(1), a)
JtJ = (J.T @ J)[0, 0]
F2 = JtJ + r[1] * 2 * a # F'' = JᵀJ + Σ r_i r_i''
sol = least_squares(residual, [0.1], jac=jac, args=(a,), method="lm")
print(f"a={a:4.1f} JᵀJ={JtJ:.0f} F''={F2:.0f} GN factor={1 - F2 / JtJ:+.1f} LM x={sol.x[0]:.0e}")
# a= 0.0 JᵀJ=2 F''=2 GN factor=+0.0 LM x=-1e-16 r is linear: one step
# a= 0.5 JᵀJ=2 F''=1 GN factor=+0.5 LM x=4e-05 linear rate; LM stops on its F tolerance
# a=-2.0 JᵀJ=2 F''=6 GN factor=-2.0 LM x=1e-07 Gauss-Newton diverges, LM converges
The iteration counts on Rosenbrock can change a little between SciPy versions. The final BFGS matrix is close to the true inverse Hessian: BFGS has learned the curvature from gradients alone.
6. Where it shows up #
- Logistic regression, generalized linear models, curve fitting. Newton's method for logistic
regression is iteratively reweighted least squares (IRLS). scikit-learn's
LogisticRegressionuses L-BFGS by default.scipy.optimize.minimizeuses BFGS by default (L-BFGS-B when there are bounds), andcurve_fituses Levenberg–Marquardt. - Physics-informed neural networks and other full-batch problems. PINN losses are badly conditioned
because of the differential operators. Rathore et al. (ICML 2024) found that Adam followed by L-BFGS
works better than either one alone. In PyTorch:
torch.optim.LBFGS(params, line_search_fn="strong_wolfe"), with full batches. - Inverse problems with PDEs. Adjoint gradients plus L-BFGS or truncated Gauss–Newton; seismic full-waveform inversion is the classic case (Virieux and Operto, 2009).
- Weather data assimilation. Strong-constraint 4D-Var finds the initial state that minimizes ( a prior "background" state, the forecast model up to time , the observation operator, the observations, and error covariances). This is nonlinear least squares. Incremental 4D-Var linearizes the model in an outer loop and solves the quadratic problem for the increment with conjugate gradients in an inner loop: a truncated Gauss–Newton method (Gratton, Lawless and Nichols, SIAM J. Optim. 2007).
- Deep learning. Not plain Newton, but its approximations: the GGN and Fisher in Hessian-free optimization and K-FAC, Kronecker factors in Shampoo, diagonal scaling in Adam (lessons 06 and 12). Laplace approximations of the posterior also use the GGN.
7. Common mistakes #
- Inverting the Hessian. Solve the linear system with Cholesky. If Cholesky fails, the Hessian is not positive definite, and the Newton step may not be a descent direction.
- Calling Newton "globally quadratic". The quadratic rate is local. Far away you need damping or a trust region (worked example (b), from ).
- Pure Newton on a nonconvex function. It finds stationary points, including saddles and maxima. Check the curvature or use a modified Hessian.
- BFGS with a line search that does not enforce the curvature condition. Without , loses positive definiteness.
- L-BFGS on noisy minibatch gradients. Gradient differences then measure noise, not curvature. Use it with full batches (or large, fixed batches).
- Forming in a badly conditioned problem. It squares the condition number of . Use QR
or
lstsqon .
8. Check yourself #
- Gauss–Newton on the Rosenbrock residuals from . Compute the
first two steps. What happens to ?
Answer
is square and invertible, so . Step 1: gives . Step 2: gives , the solution. But rose from 12.1 to 1171.3 at step 1: LM or a line search would not take this step. - Why do Newton's method on and on give corresponding iterates, and what does this mean
for feature scaling?
Answer
The Newton step in is , and the Armijo test uses only values and slopes, which are the same. So . Rescaling the features does not change Newton's speed; it does change the speed of gradient descent. - A BFGS step on a nonconvex gives . What do implementations do, and what prevents the case?
Answer
They skip the update (keep ) or use a damped update. A line search that satisfies the Wolfe curvature condition guarantees , so the case does not happen. - In LM, how does change after a step with , and after one with ?
Answer
: accept, and (the model was good). : reject, (for example ) and (the model was bad). - L-BFGS with on parameters: memory and cost per direction, compared with BFGS?
Answer
L-BFGS stores numbers (160 MB in float64) and does about multiplications per direction. BFGS would store numbers (8 TB). - Write the Hessian of . Which term does Gauss–Newton drop, and when does it vanish?
Answer
. Gauss–Newton drops . It vanishes at the solution when the residuals are zero there, and everywhere when is linear.
What is the Newton step at ?
The solution of : the minimizer of the local quadratic model (when ).
What are the assumptions of local quadratic convergence of Newton's method?
A Lipschitz Hessian, , with , and a start close enough ().
Under quadratic convergence with constant about 1, the error is . What is it after the next step?
About : the number of correct digits doubles.
What does "Newton's method is affine invariant" mean?
For , Newton on gives . Its speed does not depend on scaling, rotation or .
State the secant condition.
(or ), with and .
Why does BFGS need , and what guarantees it?
The update stays positive definite exactly when (since ). The Wolfe curvature condition guarantees it.
Memory and time per step of L-BFGS with memory in dimension ?
stored numbers and time (two loops of dot products and vector updates).
What matrix does Gauss–Newton use, and what does it drop?
. It drops the residual-curvature term of .
When does Gauss–Newton converge quadratically?
When the residuals are zero at the solution (), so the dropped term vanishes there.
Write the Levenberg–Marquardt step and its two limits.
. : Gauss–Newton. : , a short gradient step.
9. Interview angle #
- "Why not Newton for a large neural network?" — memory and solves, an indefinite Hessian (saddles attract Newton), and noisy minibatch curvature. People use Hessian-vector products (Newton-CG), GGN or Fisher approximations (K-FAC, Shampoo) or Adam instead.
- "Newton vs BFGS vs L-BFGS?" — Exact Hessian, quadratic local rate, per step; learned inverse Hessian, superlinear, ; pairs, , the default for smooth full-batch problems.
- "Why does BFGS need a Wolfe line search?" — The curvature condition gives , which keeps positive definite, so every direction is a descent direction.
- "Gauss–Newton vs Newton for least squares?" — Gauss–Newton drops , needs only , always gives a descent direction, and is quadratic for zero residuals; with large residuals it can be slow or fail, and Levenberg–Marquardt makes it safe.
- "What is 4D-Var, as an optimizer?" — Nonlinear least squares in the initial state, solved by incremental (truncated Gauss–Newton) iterations with adjoint gradients.
10. Practice #
The notebook for this lesson runs in Colab. It has four exercises, each with a check cell and a folded solution:
- Newton's method with backtracking for -regularized logistic regression on the breast cancer data set (standardized features); compare the number of iterations with gradient descent.
- Implement the BFGS inverse update; check the secant condition and positive definiteness; run BFGS
with a Wolfe line search on Rosenbrock and compare with
scipy.optimize.minimize(method="BFGS"). - Implement the L-BFGS two-loop recursion and check it against the dense BFGS matrix built from the same pairs.
- Gauss–Newton and Levenberg–Marquardt for an exponential curve fit; compare with
scipy.optimize.least_squares(method="lm").
11. Watch and read #
- Boyd and Vandenberghe, Convex Optimization, free PDF: §9.5 (Newton step, Newton decrement, affine invariance, the two-phase analysis).
- Lieven Vandenberghe, ECE236C lectures (slides): "Newton's method" and "Quasi-Newton methods" (BFGS, positive definiteness, superlinear convergence, L-BFGS).
- Nocedal and Wright, Numerical Optimization, 2nd edition (Springer, 2006): ch. 3.4 (modified Newton), ch. 6 (BFGS), ch. 7.2 (L-BFGS, the two-loop recursion), ch. 10.3 (Gauss–Newton and Levenberg–Marquardt).
- Madsen, Nielsen and Tingleff, Methods for Non-Linear Least Squares Problems (2004), free: §3.1–3.2 (Gauss–Newton, Example 3.3, Levenberg–Marquardt, Algorithm 3.16).
- James Martens, Deep learning via Hessian-free optimization (ICML 2010), and New insights and perspectives on the natural gradient method (the GGN and the Fisher).
- SciPy,
scipy.optimize.least_squares(methodslmandtrf) andscipy.optimize.minimize.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.