Lie theory is the common language for carrying optimization over "curved spaces" — rotations, poses — back into ordinary vector calculus. This note walks from manifolds and tangent spaces to hat/vee and exp/log, assembles them into one optimization step on a manifold, and closes with a hand-written code sample.
A study note based on Aalok Patwardhan's A Visual Introduction to Lie Theory[1], with the concrete derivations and code filled in.
§1Prerequisites
The main text keeps returning to the following concepts, each written as an "English term = Chinese name = minimal definition" triple:
- manifold = 流形 = a smoothly curved space that looks locally like flat but is globally curved.[2]
- Lie group = 李群 = an object that is both a manifold and a group whose operations (matrix multiplication and inversion) are smooth.[4]
- tangent space = 切空间 = the flat tangent plane attached to the manifold at a given point.[2]
- Lie algebra = 李代数 = the special tangent space of a Lie group at the identity element (written for rotation groups).[2]
- skew-symmetric matrix = 反对称矩阵 = a matrix satisfying ; elements of a rotation group's Lie algebra take exactly this form.[2]
- exponential map / logarithm map = 指数映射 / 对数映射 = a pair of mutually inverse maps travelling between the tangent space and the manifold; for rotations they are the matrix exponential and matrix logarithm.[4]
§2Recap: optimization in Euclidean space
Start with the case where everything goes smoothly. Given a cost function , we want the that minimizes it. The gradient descent recipe is:
- perturb: nudge by a tiny amount;
- gradient: compute , which points in the direction of steepest ascent;
- step: take a small step along .
The crucial premise here is that is a free vector. Each of its components can independently absorb a small increment , and the result is still a valid input. is "flat" and addition is unconstrained, so perturbing and stepping are entirely natural.
§3The dilemma: optimizing over a rotation
Take 2D rotations as an example; the rotation matrix is:
It has 4 entries, but they are not free — two constraints must hold simultaneously:
Suppose we do what we would in and add a small increment to the top-left :
This is exactly where ordinary optimization hits a wall: the valid rotations do not form a flat vector space but a curved, constrained subset. Doing calculus on it requires a different toolset.
§4Manifolds and Lie groups
The set of all valid 2D rotations is called the special orthogonal group ; the 3D version is :
They are manifolds: smoothly curved spaces that locally look like flat (much as a patch of the Earth's surface is well approximated by a flat map) but are globally curved. An object that is both a manifold and a group with smooth operations (matrix multiplication and inversion) is a Lie group[4].
Figure 1. A point on a Lie group; its tangent space is a "plane" attached at that point, and that plane is in turn isomorphic to . All the optimization happens on the far right.
§5Lie algebra and tangent space
At a point on the manifold, one can attach a flat tangent plane called the tangent space. The special tangent space at the identity element is the Lie algebra of the Lie group, written [2].
For rotations, the elements of the Lie algebra turn out to be exactly the skew-symmetric matrices (反对称矩阵, ):
Only one free parameter:
Three free parameters :
It doubles as the cross-product operator: .
Note that the number of independent components of a skew-symmetric matrix (1 for , 3 for ) is exactly the intrinsic dimension of the manifold. This is no accident — the dimension of the tangent space is the number of degrees of freedom. That hands us a flat, unconstrained space in which to do the math.
§6hat and vee: as a proxy tangent space
The tangent space (those skew-symmetric matrices) is flat, but written as matrices it is still awkward to feed straight into an optimizer. Fortunately it is isomorphic to the ordinary vector space — two mutually inverse operators ferry elements between them:
- hat : lifts a workspace vector into the Lie algebra;
- vee : flattens a Lie algebra element back into a workspace vector.
So the object we actually hand to gradient descent is that plain 3-dimensional vector — it carries no constraints and can be perturbed however we like.
§7exp and log: connecting the curved and the flat
The last piece of the puzzle is the bridge that travels between the manifold and the tangent space:
- exponential map : "wraps" an element of the tangent space back onto the curved manifold;
- logarithm map : conversely, "unrolls" an element of the manifold onto the tangent space.
For rotations, here are just the matrix exponential and matrix logarithm.
: transparent at a glance
Substituting into the matrix exponential series and using , the terms assemble themselves into :
Conversely , i.e. . The number living in the tangent space is the rotation angle itself.
: the Rodrigues formula
Let , where is the rotation angle and is the unit rotation axis. Using the identity to collapse the series gives Rodrigues' rotation formula[2][3]:
The inverse (log map):
§8Putting it together: one optimization step on a manifold
Now chain the three spaces into a closed loop. Let the cost function be defined on the manifold (). The key trick is to use a right perturbation to parameterize by a local, unconstrained small vector :
(The notation follows the convention of micro Lie theory[2].)
Take the gradient of with respect to at (this step happens entirely inside flat , with the ordinary chain rule), obtain the gradient , and then:
This is the diagram of the whole note, made concrete: log to flatten → optimize in → exp to wrap back. The constraints are guaranteed automatically by , and all the optimizer ever sees is one free little vector.
§9Code sample: hand-writing hat / vee / exp / log for
NumPy implementation
import numpy as np
def hat(w): # R^3 -> so(3)
wx, wy, wz = w
return np.array([[0, -wz, wy],
[wz, 0, -wx],
[-wy, wx, 0]])
def vee(W): # so(3) -> R^3
return np.array([W[2, 1], W[0, 2], W[1, 0]])
def exp_so3(w): # Rodrigues: R^3 -> SO(3)
theta = np.linalg.norm(w)
W = hat(w)
if theta < 1e-8: # θ→0: fall back to Taylor
return np.eye(3) + W
a = np.sin(theta) / theta
b = (1 - np.cos(theta)) / theta**2
return np.eye(3) + a * W + b * (W @ W)
def log_so3(R): # SO(3) -> R^3
theta = np.arccos(np.clip((np.trace(R) - 1) / 2, -1.0, 1.0))
if theta < 1e-8:
return vee(R - np.eye(3))
return theta / (2 * np.sin(theta)) * vee(R - R.T)Self-check
w = np.array([0.3, -0.7, 1.1])
R = exp_so3(w)
assert np.allclose(R.T @ R, np.eye(3)) # still orthogonal
assert np.allclose(np.linalg.det(R), 1.0) # det = 1
assert np.allclose(log_so3(R), w) # log ∘ exp = idOff-the-shelf libraries
In a real project, don't reinvent the wheel — reach for a mature implementation:
- Sophus (C++,
SO3/SE3, Jacobians included) - manif (C++/Python, the reference implementation of micro Lie theory[2])
- GTSAM / Ceres (wrap manifold optimization as factor graphs / a
Manifoldtype)
§10Why all this matters
Lie theory is the lingua franca of modern robotic state estimation[2][3]. Almost anywhere rotations or poses have to be optimized or integrated, it is at work:
| Setting | Where Lie theory enters |
|---|---|
| SLAM / bundle adjustment | Camera poses live in ; Gauss–Newton runs in the tangent space |
| pose graph optimization | Nodes are poses, edges are relative constraints; residuals and Jacobians are computed in the Lie algebra |
| IMU preintegration | A gyroscope measures angular velocity; integration happens on rather than by Euclidean accumulation |
| state estimation / EKF | Uncertainty is modelled as a Gaussian in the tangent space (error-state Kalman filter) |
§11References
- Aalok Patwardhan, A Visual Introduction to Lie Theory, aalok.uk interactive tutorial — the original source of this note.
- J. Solà, J. Deray, D. Atchuthan, A micro Lie theory for state estimation in robotics, arXiv:1812.01537 (2018) — the authoritative short treatment from an engineering perspective, with manif as its companion library.
- T. D. Barfoot, State Estimation for Robotics, Cambridge University Press (2017) — a systematic textbook; Chapter 7 covers .
- B. C. Hall, Lie Groups, Lie Algebras, and Representations: An Elementary Introduction, 2nd ed., Springer, Graduate Texts in Mathematics 222 (2015).