Logarithm & Exponential
Exponential and logarithm functions appear throughout SLAM in the context of Lie groups and Lie algebras. Beyond their familiar scalar forms, their matrix versions are the bridge between rotations (which are hard to optimize) and vectors (which are easy to optimize).
Scalar refresher
The exponential and its inverse satisfy the identities that make them useful:
The log identity already earns its keep in probability: likelihoods are products of many small numbers, which underflow floating point; taking the logarithm turns the product into a numerically stable sum — this is why estimators minimize a negative log-likelihood rather than maximize the likelihood itself.
The problem with rotations
Rotation matrices are not a vector space — you cannot add two rotations and get a rotation, so you cannot apply vanilla gradient descent to them. But their Lie algebra (the tangent space at the identity) is a vector space: an element is just a 3-vector (axis-angle), written as a skew-symmetric matrix .
Exponential and logarithm maps
The matrix exponential is defined by the same power series as the scalar one, , and for skew-symmetric arguments the series collapses to a closed form:
- The exponential map converts a Lie algebra element to a rotation matrix. For a rotation by angle around unit axis (so ):
This is Rodrigues’ formula — a closed form of the matrix exponential series, obtained because powers of a unit skew-symmetric matrix cycle: .
- The logarithm map is the inverse: it extracts the axis-angle vector from a rotation matrix. The angle comes from the trace, , and the axis from the antisymmetric part of .
For small rotations, keeping only the first-order term gives the ubiquitous approximation
which is exactly the linearization used when deriving Jacobians of residuals with respect to rotation perturbations.
The same construction extends to full rigid-body poses: maps (6-vectors: translation + rotation) to (homogeneous transformation matrices), and maps back.
Why the scalar intuition still helps
The familiar identities carry over in spirit: the exponential turns addition into composition ( for commuting arguments), and the logarithm turns composition back into something additive. This is exactly what optimization needs: express a small correction as a vector , apply it multiplicatively as , and measure pose errors as .
One caveat worth remembering: for matrices, holds only when and commute — and rotations about different axes do not. That non-commutativity is precisely why 3D rotations need Lie theory rather than plain vector addition.
Common pitfalls
- Numerical instability of the log map near and : the axis formula divides by ; robust implementations switch to a Taylor-expanded branch near these angles.
- Assuming additivity: composing two axis-angle vectors by adding them is only approximately right for small angles; the exact composition goes through /.
- Mixing conventions: some libraries store tangent vectors as (translation, rotation), others as (rotation, translation) — check before copying Jacobians between codebases.
Why it matters for SLAM
Logarithms and exponentials let us “linearize” rotations and poses, making them amenable to gradient-based optimization — every modern SLAM back-end (g2o, GTSAM, Ceres with manifold parameterizations) updates poses through the exponential map, and pose graph errors are defined through the logarithm map. Getting comfortable with now pays off directly when you study Lie groups properly at Level 2.