MAP inference as sparse nonlinear least squares
This is the central theoretical identity of modern SLAM: maximum a posteriori (MAP) estimation over a factor graph, under Gaussian noise, is exactly a sparse nonlinear least-squares problem. Everything the back-end does follows from this one derivation.
From Bayes to least squares
Start from Bayes’ rule. We want the most probable states given the measurements:
With a motion model , and an observation model , , taking the negative log of the Gaussian product turns maximizing probability into minimizing a sum of squared, covariance-weighted residuals:
Each factor in the factor graph contributes one term; for visual SLAM the observation terms are reprojection errors, and the problem specializes to bundle adjustment. A useful bookkeeping identity: the covariance weighting can be absorbed into the residual, (“whitening”), so every weighted problem is a plain least-squares problem on whitened residuals.
Solving it: Gauss-Newton and Levenberg-Marquardt
The problem is nonlinear (projection, rotations) and is solved iteratively. Gauss-Newton linearizes the stacked residual around the current estimate :
Substituting into the cost and minimizing over yields the normal equations:
The matrix approximates the Hessian (dropping second-order terms). Gauss-Newton converges fast near the solution but can diverge from a poor initial estimate. Levenberg-Marquardt fixes this by damping:
As it behaves like Gauss-Newton (fast near the minimum); as it becomes a small steepest-descent step (robust far away). is adapted per iteration — decreased when a step reduces the cost, increased when it doesn’t. LM is the standard algorithm in Ceres and most SLAM back-ends.
The full iteration loop, with the manifold machinery from the Lie groups note:
- Linearize all residuals at the current estimate (Jacobians with respect to tangent-space perturbations ).
- Solve the sparse (damped) normal equations for .
- Update on the manifold: for each pose, plain addition for Euclidean variables.
- Repeat until the cost or update norm converges.
Robust kernels. Real correspondence sets contain outliers, and a single bad squared residual can dominate the sum. Practical systems wrap each term in a robust loss (Huber: quadratic for small residuals, linear beyond a threshold; Cauchy: logarithmic growth that strongly down-weights gross outliers). The optimization is then solved as iteratively reweighted least squares — each residual gets weight — which fits into the exact same normal-equations machinery.
Sparsity: the other half of the story
Each factor touches only a few variables (an observation involves one pose and one landmark), so and are overwhelmingly sparse and block-structured. Exploiting this is what makes SLAM tractable at scale — via sparse Cholesky/QR factorization, and via the Schur complement that eliminates all landmarks first in bundle adjustment (reducing a -dimensional system to camera variables, huge when landmarks vastly outnumber poses).
Variable elimination and the Bayes tree. Solving the sparse system can be viewed graph-theoretically: eliminate variables one by one from the factor graph, each elimination producing a conditional density and new induced factors on the remaining variables. The elimination order determines how much fill-in (density) is created — good orderings (e.g., COLAMD) keep the factorization sparse. Running elimination to completion yields a Bayes net, whose cliques organize into the Bayes tree: a directed tree of cliques in which each variable’s solution depends only on its ancestors. The Bayes tree is more than an implementation detail — it reveals which parts of the solution are affected by a new measurement, which is precisely the structure iSAM2 exploits for incremental updates, and it explains marginalization (eliminating a variable permanently) as the same algebraic operation.
Two families of solving schedules build on this foundation:
- Batch / full smoothing: solve over all variables (bundle adjustment, pose graph optimization); most accurate, cost grows with trajectory length.
- Incremental / fixed-lag: update the Bayes tree incrementally (iSAM2), or bound the window and marginalize old variables (sliding-window VIO).
Why it matters for SLAM
This formulation is the reason the field moved from filtering to optimization (“smoothing”): it re-linearizes wherever needed, handles arbitrary factor types uniformly, and scales via sparsity. Every back-end library (Ceres, g2o, GTSAM) is an implementation of exactly this pipeline, and every back-end paper you will read — from ORB-SLAM’s BA to VINS-Mono’s sliding window to iSAM2 — is a particular answer to “which variables, which factors, which elimination/solving schedule.”