44.03.07 · optimization-control / 03-unconstrained-optimization

Gauss-Newton and Levenberg-Marquardt for Nonlinear Least Squares

shipped3 tiersLean: none

Anchor (Master): Nocedal & Wright 2006 Numerical Optimization 2e (Springer) §10.3-10.4 (LM as the exact trust-region subproblem of the Gauss-Newton model, global convergence, large-residual failure, and the local convergence rate with governed by the omitted curvature); Björck 1996 Numerical Methods for Least Squares Problems (SIAM) Ch. 9 (Gauss-Newton, damping, and separable least squares / variable projection); Golub & Pereyra 1973 SIAM J. Numer. Anal. (the variable-projection algorithm)

Intuition Beginner

A great many problems boil down to the same request: pick the numbers that make a model match a pile of measurements as closely as possible. You have a curve with a few dials on it, you have data points, and for each data point there is a residual — the gap between what the model predicts and what was actually measured. The goal is to turn the dials so the gaps are as small as possible overall, measured by adding up the squares of all the gaps.

If the dials entered the model in a straight-line way, this would be the ordinary least-squares fit you already know: one clean solve. The catch is that the dials usually enter in a bent, curved way. So the trick is to pretend, for one step, that things are straight. Stand at your current dial settings, replace each curved residual by its best straight-line stand-in, solve the easy fit that results, and move the dials there. Then repeat from the new spot. This is the Gauss-Newton idea: a sequence of ordinary least-squares solves that chase the true bent problem.

Why not just use the general curvature-aware method from the previous units? Because least-squares problems hand you a gift. The very same slopes you compute to build the straight-line stand-in also give you most of the curvature information for free, with no extra second-derivative work. You exploit the structure instead of ignoring it.

There is one place this gift runs thin. When the model can match the data well, the leftover gaps are small and the shortcut is excellent. When the model is a poor fit and the gaps stay large no matter how you turn the dials, the part of the curvature you threw away starts to matter, and the plain method slows down or wanders. The fix is to add a brake — a damping dial — that shortens and steadies each step when the shortcut is misbehaving, and releases when it is working well.

Visual Beginner

Picture fitting a curve through scattered dots. At your current guess the curve sits a bit off; each dot has a short vertical line connecting it to the curve — that line is its residual. Gauss-Newton looks at how each residual would change if you nudged the dials, builds a flat (straight-line) picture of all those changes, and solves for the nudge that shrinks the squared gaps the most.

The damped version, Levenberg-Marquardt, adds a brake. With the brake off, you take the full straight-line-fit step, which is bold and fast when the fit is good. With the brake on hard, you take a short, cautious step pointed almost straight downhill. The method turns the brake automatically: a step that worked releases the brake, a step that overshot tightens it.

situation what the method does brake setting
good fit, small gaps full Gauss-Newton step, fast loose (small damping)
step improved the fit accept, loosen the brake decreases
step made things worse reject, tighten the brake increases
brake very tight short step, nearly straight downhill large damping

The takeaway: Gauss-Newton turns a bent fitting problem into a sequence of straight-line fits, and the damping brake of Levenberg-Marquardt keeps those steps trustworthy when the shortcut would otherwise mislead.

Worked example Beginner

Fit the one-dial model — a line through the origin with slope — to two points: at the value is , and at the value is . The residuals are the model-minus-data gaps,

Nudging by one unit changes by and by ; those two numbers are the slopes (the Jacobian). Start at , where the residuals are and .

The Gauss-Newton step solves the straight-line fit: find the nudge that makes and as small as possible in squared total. The recipe (the normal equation) divides the slope-weighted residual sum by the slope-squared sum:

So the new dial setting is .

Because this model is straight-line in , the slopes never change, so one step lands on the exact best fit. Check it: at the residuals are and . The total squared gap is . Trying a nearby value like gives , which is larger — so really is better.

What this tells us: Gauss-Newton converts each fitting step into a weighting of residuals by their slopes, and when the model is straight in its dials it finishes in a single step, exactly like ordinary least squares.

Check your understanding Beginner

Formal definition Intermediate+

Let with be a twice continuously differentiable residual map, , and consider the nonlinear least-squares objective

Write for the Jacobian of . Differentiating gives the gradient and Hessian in the structured form

where is the residual-curvature term. The first piece uses only first derivatives — the same data as the gradient — while requires the second derivatives of each residual and is weighted by the residuals themselves.

The Gauss-Newton step drops , approximating by , and solves

Equivalently, minimises the linearised residual : it is the linear least-squares solution of , the exact subproblem one would solve if were replaced by its first-order model . When has full column rank the normal-equation matrix is positive definite, is unique, and , so is a descent direction whenever . In practice the normal equations are not formed; instead a QR factorisation 43.04.01 reduces to the triangular solve , halving the condition number relative to . The Gauss-Newton iteration is with from a line search 44.03.01.

The Levenberg-Marquardt step damps the normal equations,

Since , the shift makes for every , so exists and is a descent direction even when is rank-deficient. As , ; as , , a short step along the steepest-descent direction . The damping is the Lagrange multiplier of a trust region 44.03.02: solves for a radius tied to by the trust-region characterisation , . The parameter is updated by the gain ratio

the ratio of actual to predicted decrease: decrease (loosen damping) when is large, increase (tighten) when is small or negative. The new symbols (residual), (Jacobian), (residual-curvature term), , , and (LM damping) are recorded in _meta/NOTATION.md.

Counterexamples to common slips Intermediate+

  • "Gauss-Newton is Newton's method for ." It is Newton applied to the approximate Hessian , omitting . The two coincide only when vanishes — at a zero-residual solution, or when every residual is affine in . With large residuals at the solution the methods differ and Gauss-Newton loses Newton's quadratic rate.

  • " is always invertible, so the Gauss-Newton step always exists." Only when has full column rank. A rank-deficient or ill-conditioned makes singular or nearly so, and the Gauss-Newton step is undefined or wildly large. This is precisely the failure Levenberg-Marquardt repairs through the shift .

  • "Levenberg-Marquardt is just Gauss-Newton with a fixed regularisation." The whole method is in the adaptive control of via the gain ratio. A fixed either over-damps (slow) or under-damps (unstable); LM converges because it lets near a good solution (recovering the Gauss-Newton rate) and raises when steps fail.

  • "Form the normal equations and solve them." Forming squares the condition number, , and can lose half the available digits. The stable route is the QR factorisation of (or, for LM, of the stacked matrix ), which works with directly.

Key theorem with proof Intermediate+

The signature result is the local convergence dichotomy of Gauss-Newton: it explains both the method's speed on well-fitting models and its degradation on poorly fitting ones, isolating the omitted residual-curvature term as the single quantity that decides the rate.

Theorem (local convergence of Gauss-Newton, small- versus large-residual). Let be a solution with , of full column rank, twice continuously differentiable with Lipschitz Jacobian near , and write and . Then the undamped Gauss-Newton iteration from a start near satisfies

for a constant . Hence if the iteration converges linearly with asymptotic rate ; if in addition (the zero-residual case) then and the convergence is quadratic.

Proof. Write , , , and for the Gauss-Newton matrix. Full column rank of and continuity make invertible with on a ball about , so the step exists there. Since ,

The fundamental theorem of calculus applied to along the segment from to 44.03.03 gives , so

Split the integrand: , using . The first bracket has norm because is Lipschitz (a product of Lipschitz Jacobians), contributing the term after the outer factor of . The second bracket converges to as , contributing . Collecting,

since (the matrices agree at because multiplies via ). When every so , the linear term drops, and is quadratic.

Bridge. This dichotomy is the foundational reason Gauss-Newton is the method of choice for least squares yet must be globalised for hard fits: the rate is set entirely by , the size of the curvature the method throws away relative to the curvature it keeps, and this is exactly the term that distinguishes Gauss-Newton from the full Newton method 44.03.03 of the previous unit, whose Hessian retains and so always converges quadratically. The construction builds toward Levenberg-Marquardt, which appears again in the Advanced results as the trust-region 44.03.02 regularisation that supplies global convergence when makes the undamped iteration diverge. The central insight is that the residual structure generalises the linear least-squares normal equations 43.04.01 — at a zero-residual solution the nonlinear problem is locally a linear least-squares problem, is the exact Hessian, and the QR solve of inherits the linear theory verbatim. Putting these together, the damping parameter is dual to the trust-region radius , and the same gain-ratio test that drove the radius update of 44.03.02 now drives , so the globalisation is the previous unit's trust-region machinery specialised to the Gauss-Newton model.

Exercises Intermediate+

Advanced results Master

The Gauss-Newton model is one approximation — replace by — and the results below organise its theory around three axes: the descent and convergence consequences of the omitted term , the Levenberg-Marquardt damping that realises the Gauss-Newton model inside a trust region and so converges globally, and the separable structure that lets a subset of parameters be eliminated in closed form.

Theorem 1 (Gauss-Newton step, descent, and the small-residual rate). For full-column-rank the Gauss-Newton step is the unique minimiser of and satisfies , so it is a descent direction whenever ; the quantity is the orthogonal projector onto the column space of , so the directional derivative equals , the squared length of the residual's projection onto the reachable directions 43.04.01. At a solution with , full rank, and Lipschitz Jacobian, the iteration converges locally with asymptotic rate , which is (quadratic convergence) in the zero-residual case and small (fast linear) for nearly-linear or well-fitting models; when the undamped iteration diverges [Nocedal, J. & Wright, S. J. — Numerical Optimization (2nd ed.)].

Theorem 2 (Levenberg-Marquardt as the Gauss-Newton trust-region subproblem). The LM step solving is exactly the solution of the trust-region subproblem for the radius , with the trust-region multiplier satisfying and 44.03.02. Because has its smallest eigenvalue , the LM "hard case" never arises: for every , so the step is always well defined and a descent direction even at rank-deficient . As ranges over the step interpolates monotonically (Exercise 6) from the full Gauss-Newton step down to the infinitesimal steepest-descent step , so LM is a blend of Gauss-Newton's speed and steepest descent's robustness selected by the data. Global convergence to a stationary point follows from the trust-region theory of 44.03.02: the predicted reduction satisfies the Cauchy sufficient-decrease bound, and the gain-ratio update of is the radius update in disguise [Nocedal, J. & Wright, S. J. — Numerical Optimization (2nd ed.)].

Theorem 3 (damping update and the Marquardt heuristic). The classical Levenberg-Marquardt control of uses the gain ratio : if the model is accurate, accept the step and set (loosen, ); if the model overpredicted, set (tighten) and, if , reject the step; otherwise hold . Marquardt's 1963 refinement scales the shift by the diagonal of rather than the identity, solving with , which makes the damping affine-invariant under coordinate rescaling and matches the local curvature of each parameter — important when parameters have widely different scales. Near a small-residual solution so , and LM recovers the Gauss-Newton (quadratic, zero-residual) rate of Theorem 1; far away, large keeps steps short and safe [Nocedal, J. & Wright, S. J. — Numerical Optimization (2nd ed.)].

Theorem 4 (separable least squares and variable projection). Suppose the residual is linear in a subset of parameters: where enters linearly through the matrix and enters nonlinearly. For fixed the optimal linear part is the linear least-squares solution (the pseudoinverse), so the problem reduces to the variable-projection functional

the squared norm of the residual projected off the column space of . Minimising over alone — a smaller nonlinear problem — recovers the joint minimiser, and the Golub-Pereyra derivative formula gives the Jacobian of the projected residual in terms of , , and , so Gauss-Newton or LM applies to directly. Variable projection typically converges in fewer iterations and is less sensitive to the starting guess for the linear parameters than treating jointly, because the linear block is solved exactly at every step [Nocedal, J. & Wright, S. J. — Numerical Optimization (2nd ed.)].

Synthesis. Nonlinear least squares is one structure — the objective with and — and the foundational reason the whole subject is tractable is that the first Hessian piece is free from the gradient computation, so the Gauss-Newton step is a linear least-squares solve 43.04.01 disguised as a Newton step. The central insight is the division of labour set by the omitted term : when residuals are small or nearly linear, is negligible, is the true Hessian, and Gauss-Newton matches the Newton method 44.03.03 with its quadratic rate; when residuals are large, dominates and the bare iteration diverges, which is exactly the regime where Levenberg-Marquardt's damping is not optional but structural. The damping parameter is dual to the trust-region radius of 44.03.02: the LM step solves the trust-region subproblem of the Gauss-Newton model, guarantees the hard case never arises, and the gain-ratio control of is the radius update specialised to least squares. Putting these together, Gauss-Newton generalises the linear normal equations to the nonlinear setting, Levenberg-Marquardt generalises trust-region globalisation to the Gauss-Newton model, and variable projection generalises the exact-elimination of linear parameters to the separable case — three specialisations of one residual structure, and the bridge from the linear least-squares chapter to the large-scale curve-fitting and bundle-adjustment problems where this method is the workhorse.

Full proof set Master

Proposition 1 (structured gradient and Hessian). For with and Jacobian , one has and .

Proof. By the chain rule, , giving . Differentiating again,

where the first sum is the entry of and the second is the residual-weighted curvature. Assembling over gives .

Proposition 2 (Gauss-Newton descent and the projection identity). If has full column rank and , then satisfies , where is the orthogonal projector onto .

Proof. . Insert : this equals , using and (the matrix is symmetric and idempotent, hence the orthogonal projector onto 43.04.01). It is negative unless , i.e. unless , contradicting .

Proposition 3 (local convergence rate). Under , full column rank, and with Lipschitz Jacobian near , the Gauss-Newton iterates satisfy with , , .

Proof. As in the Key theorem. With , , full rank gives bounded near and . The identity and split the integrand into , of norm by Lipschitz , and . Hence , and . The linear coefficient is (up to the working-ball factor on ). If then and the bound is purely quadratic.

Proposition 4 (LM step is the augmented least-squares solution and is always a descent direction for ). For any (full rank or not) and , the LM step is the unique minimiser of and satisfies whenever .

Proof. The stacked matrix has for (the block makes it positive definite regardless of ), so has full column rank and the least-squares problem has the unique solution given by its normal equations , i.e. . For descent, since and .

Proposition 5 (step-length monotonicity in ). is non-increasing on , strictly decreasing when , from (or if is rank-deficient) at to as .

Proof. With the SVD and , Exercise 6 gives and , strict unless all . The limits follow from the closed form: as each summand vanishes; as a zero singular value with sends a term to infinity (rank deficiency), else the sum is .

Proposition 6 (variable-projection equivalence). For with full column rank, the joint minimiser of satisfies and minimises , .

Proof. For fixed the inner problem is linear least squares 43.04.01 with unique solution and optimal value , since is the orthogonal projector onto . Minimising the joint objective is , attained at , with . Conversely any joint minimiser has its -block optimal for its -block, hence equal to , so its -block minimises .

Connections Master

  • Newton's method for optimization 44.03.03 is the parent against which Gauss-Newton is defined: Gauss-Newton is Newton applied to the structured Hessian with the residual-curvature term deleted, so the two coincide at a zero-residual solution where and Gauss-Newton inherits Newton's quadratic rate, and diverge in the large-residual regime where . The integral-remainder identity proved there is the engine of the convergence-rate proof here, and the line-search globalisation of that unit's predecessor applies unchanged to the Gauss-Newton direction.

  • Trust-region methods 44.03.02 supply the exact meaning of Levenberg-Marquardt: the LM step is the trust-region subproblem solution for the Gauss-Newton model , the damping is the trust-region Lagrange multiplier, and the gain-ratio update of is the radius update of that unit specialised to least squares. The secular-equation monotonicity of established there is the same monotonicity proved here for , and because the trust-region hard case — central to the general theory there — cannot occur for LM.

  • Linear least squares: normal equations, QR, SVD, conditioning 43.04.01 is the inner solver of every Gauss-Newton and LM iteration: each step is a linear least-squares problem (or its augmented form for LM) solved by QR or SVD rather than by forming , the projector that gives the descent identity is that unit's orthogonal projection onto the column space, and the conditioning warning is what dictates the QR route. Variable projection reduces a separable problem to the pseudoinverse machinery of that unit applied at every outer step.

  • Correlation and regression analysis 26.06.01 is the principal statistical consumer: minimising is maximum-likelihood estimation under independent Gaussian errors, so the linear-regression normal equations of that unit are the single-step special case of Gauss-Newton, the Gauss-Newton matrix is the Fisher-information / observed-information approximation whose inverse gives the asymptotic parameter covariance, and Levenberg-Marquardt is the standard nonlinear-regression fitting algorithm. The same structure powers bundle adjustment in computer vision and the training of small parametric models, where the residual is the prediction error and is the sensitivity of predictions to parameters.

Historical & philosophical context Master

The least-squares principle itself originates with Carl Friedrich Gauss, who used it to fit orbital parameters to astronomical observations and published the method in his 1809 Theoria Motus Corporum Coelestium [Gauss 1809], with Adrien-Marie Legendre having printed the procedure independently in 1805. The iterative linearisation that bears Gauss's name — solving a sequence of linear least-squares problems for a nonlinear fit — is a direct descendant of his Newton-style root-finding for the normal equations, transferred to the over-determined residual setting.

The damping that stabilises Gauss-Newton for ill-conditioned and large-residual problems was introduced by Kenneth Levenberg in 1944, who proposed adding a multiple of the identity to the normal-equation matrix [Levenberg 1944], and refined by Donald Marquardt in 1963, who scaled the damping by the diagonal of to respect parameter scaling and gave the adaptive update of that made the method practical [Marquardt 1963]. The recognition that the Levenberg-Marquardt shift is exactly the trust-region subproblem solution for the Gauss-Newton model came later, in the trust-region literature of the 1970s and 1980s, unifying LM with the radius-controlled methods of Powell, Moré, and Sorensen. The separable-least-squares reduction by elimination of the linear parameters was given its definitive algorithmic form by Gene Golub and Victor Pereyra in 1973, whose variable-projection differentiation formula remains the standard tool [Golub-Pereyra 1973]. The textbook synthesis organising Gauss-Newton, Levenberg-Marquardt, and the small- versus large-residual analysis around the residual Hessian structure is due to Nocedal and Wright [Nocedal, J. & Wright, S. J. — Numerical Optimization (2nd ed.)].

Bibliography Master

@book{nocedalwright2006gn,
  author    = {Nocedal, Jorge and Wright, Stephen J.},
  title     = {Numerical Optimization},
  edition   = {2},
  series    = {Springer Series in Operations Research and Financial Engineering},
  publisher = {Springer},
  year      = {2006}
}

@article{levenberg1944,
  author  = {Levenberg, Kenneth},
  title   = {A Method for the Solution of Certain Non-Linear Problems in Least Squares},
  journal = {Quarterly of Applied Mathematics},
  volume  = {2},
  number  = {2},
  year    = {1944},
  pages   = {164--168}
}

@article{marquardt1963gn,
  author  = {Marquardt, Donald W.},
  title   = {An Algorithm for Least-Squares Estimation of Nonlinear Parameters},
  journal = {Journal of the Society for Industrial and Applied Mathematics},
  volume  = {11},
  number  = {2},
  year    = {1963},
  pages   = {431--441}
}

@article{golubpereyra1973,
  author  = {Golub, Gene H. and Pereyra, Victor},
  title   = {The Differentiation of Pseudo-Inverses and Nonlinear Least Squares Problems Whose Variables Separate},
  journal = {SIAM Journal on Numerical Analysis},
  volume  = {10},
  number  = {2},
  year    = {1973},
  pages   = {413--432}
}

@book{bjorck1996,
  author    = {Bj\"{o}rck, \r{A}ke},
  title     = {Numerical Methods for Least Squares Problems},
  publisher = {SIAM},
  year      = {1996}
}

@book{gauss1809,
  author    = {Gauss, Carl Friedrich},
  title     = {Theoria Motus Corporum Coelestium in Sectionibus Conicis Solem Ambientium},
  publisher = {Friedrich Perthes and I. H. Besser},
  address   = {Hamburg},
  year      = {1809}
}