Levenberg-Marquardt
Levenberg-Marquardt (LM) is the workhorse solver for nonlinear least-squares problems in SLAM. It is a damped version of Gauss-Newton that interpolates between Gauss-Newton (fast near the minimum) and gradient descent (safe far from it), making it much more robust to poor initialization.
From Gauss-Newton to LM
For a cost , Gauss-Newton linearizes the residual and solves the normal equations
This can diverge when the linearization is a bad approximation, or when is (nearly) singular. LM adds a damping term :
where:
- is the Jacobian of the residual vector at the current estimate ,
- is the damping parameter,
- is the update, applied as (or via the exponential map for poses on a manifold).
The two limits explain the behavior:
- : the equation reduces to Gauss-Newton — large, aggressive steps with near-quadratic convergence close to the minimum.
- : the equation approaches , i.e. a short step along the negative gradient — slow but reliable descent.
Marquardt’s refinement scales the damping by the curvature of each coordinate, replacing with , so that weakly constrained directions get damped more and the method becomes invariant to per-parameter rescaling.
Adapting the damping
is adjusted every iteration based on whether the step actually helped:
- Solve for with the current .
- Evaluate the true cost at .
- If the cost decreased: accept the step and decrease (trust the linearization more).
- If the cost increased: reject the step and increase (take a smaller, more gradient-like step), then re-solve.
A common refinement compares the actual cost reduction against the reduction predicted by the linearized model (the gain ratio): a ratio near 1 means the local quadratic model is trustworthy and can shrink aggressively; a small or negative ratio means the model is poor and must grow. This is exactly the logic of a trust-region method — LM can be read as implicitly maintaining a region around within which the linearization is trusted, with inversely related to the region’s radius.
Practical notes for SLAM problems
- The damped system matrix is always positive definite for , so Cholesky factorization always succeeds — important for gauge-underconstrained problems such as monocular bundle adjustment.
- The sparsity of the SLAM Hessian is preserved: damping only touches the diagonal, so the Schur complement trick for bundle adjustment works unchanged.
- Robust kernels (M-estimators) fold into LM as iteratively reweighted least squares — weights modify and , the LM loop is otherwise identical.
- LM is the default optimizer in Ceres Solver, g2o, and GTSAM, and hence the algorithm actually running inside most SLAM back-ends.
Why it matters for SLAM
Nearly every optimization in a modern SLAM pipeline — bundle adjustment, pose graph optimization, PnP refinement, camera calibration — is solved with LM. SLAM problems are highly nonlinear (projection, rotation manifolds) and initializations are often mediocre (motion-model predictions, noisy triangulations), so the pure Gauss-Newton step frequently overshoots. LM’s automatic damping is what makes these solvers converge reliably frame after frame without hand-tuning, which is why it has been the default in SLAM back-ends for decades.