skoro v0.0.0

Gradients and Hessians in tangent charts

The gradient of a scalar function and its Hessian product, read in the tangent charts a retraction provides, and why the passes of automatic differentiation compute them unchanged.

Updated 2026-11-25 · 3 min read

The first note reads the derivative of a map between manifolds in tangent coordinates, as a matrix, and computes it through a retraction. This note reads the first and second derivatives of a scalar function the same way: its gradient as a vector, and its second derivative along a direction. Each is what an optimizer or a sampler needs at a point, and none needs a metric. It ends by showing that the passes of automatic differentiation compute them unchanged.

By Proposition 3, derivatives in tangent coordinates compose exactly as Jacobians do, so the passes apply to a program whose steps are maps between manifolds, as long as each step’s derivative is read in tangent coordinates, by Proposition 10. The transpose of a derivative is taken in coordinates: a cotangent at y\otherPoint is a column of dy\dimy numbers acting on tangent coordinates, and DF(x)⊤\D \map(\point)\transpose maps it to a cotangent at x\point. No inner product on the tangent spaces is involved.

The gradient#

For a scalar function f:X→Rf : \manifold \to \R, its gradient in the chart at x\point is

g(x)≔∇(f∘Rx)(0)=Df(x)⊤1∈Rxd,(1) g(\point) \defeq \nabla (f \circ R_\point)(0) = \D f(\point)\transpose 1 \in \R^\dimx, \tag{1}
(1)

the cotangent that a reverse pass seeded with 11 delivers. It says how ff changes along a step: f(x⊕v)=f(x)+g(x)⊤v+O(∣v∣2)f(\point \oplus \tangent) = f(\point) + g(\point)\transpose \tangent + O(\lvert\tangent\rvert^2). With no metric in play, it is the differential of ff written in chart coordinates, not a Riemannian gradient.

The Hessian product#

The second derivative needs a choice that the first does not, because moving along a direction moves the chart as well. The chart Hessian differentiates the gradient along a direction v\tangent, reading the gradient at each point in that point’s own chart. It compares the tangent coordinates at nearby points, so it is defined where ⊕\oplus is smooth near x\point (Proposition 7), which this note assumes from here on:

H(x) v≔ddt∣t=0g(x⊕tv).(2) H(\point)\, \tangent \defeq \frac{\dd}{\dd t}\Big|_{t=0} g(\point \oplus t \tangent) . \tag{2}
(2)

The other candidate is the Hessian of the pull-back f∘Rxf \circ R_\point, which keeps the chart at x\point fixed. On a flat manifold the two are the same matrix, the ordinary Hessian. On a curved one they differ by a term proportional to the gradient.

Proposition 3(The chart Hessian and the Hessian of the pull-back).

Let ⊕\oplus be smooth near x\point, and let xt=x⊕tv\point_t = \point \oplus t \tangent and φt=Rx−1∘Rxt\varphi_t = R_\point^{-1} \circ R_{\point_t}, defined near 00 for small tt. Then

H(x) v=∇2(f∘Rx)(0) v+(ddt∣t=0Dφt(0))⊤g(x), H(\point)\,\tangent = \nabla^2 (f \circ R_\point)(0)\, \tangent + \Bigl(\frac{\dd}{\dd t}\Big|_{t=0} \D\varphi_t(0)\Bigr)\transpose g(\point),

so H(x) v=∇2(f∘Rx)(0) vH(\point)\,\tangent = \nabla^2 (f \circ R_\point)(0)\, \tangent at every stationary point, where g(x)=0g(\point) = 0.

Proof.

For small tt and uu near 00, Rxt(u)=Rx(φt(u))R_{\point_t}(u) = R_\point(\varphi_t(u)), with φ0\varphi_0 the identity and φt(0)=Rx−1(xt)=tv\varphi_t(0) = R_\point^{-1}(\point_t) = t \tangent by (9). So f∘Rxt=(f∘Rx)∘φtf \circ R_{\point_t} = (f \circ R_\point) \circ \varphi_t near 00, and

g(xt)=Dφt(0)⊤ ∇(f∘Rx)(tv). g(\point_t) = \D \varphi_t(0)\transpose\, \nabla (f \circ R_\point)(t \tangent) .

Differentiating at t=0t = 0, with Dφ0(0)=I\D \varphi_0(0) = I and ∇(f∘Rx)(0)=g(x)\nabla (f \circ R_\point)(0) = g(\point), gives the claim.

∎

On the rotations, with the retraction Rx(u)=xExp⁡(u)R_\point(u) = \point \operatorname{Exp}(u), the Baker–Campbell–Hausdorff formula gives φt(u)=tv+u+t2 v×u\varphi_t(u) = t \tangent + u + \tfrac{t}{2}\, \tangent \times u, up to terms of order t2∣u∣t^2 \lvert u\rvert and t∣u∣2t \lvert u\rvert^2, so the correction is 12[g(x)]×v\tfrac12 [g(\point)]_\times \tangent: the chart Hessian is the Hessian of the pull-back plus the skew-symmetric matrix 12[g(x)]×\tfrac12 [g(\point)]_\times, and it is not symmetric away from a stationary point. On the positive reals, with Rx(u)=x euR_\point(u) = \point\, e^{u}, the charts commute instead: φt(u)=tv+u\varphi_t(u) = t \tangent + u, whose derivative does not move with tt, so the correction vanishes and the two Hessians agree everywhere. Which symmetric matrix to use where they differ, if one is needed, is the algorithm’s decision. At a stationary point, which is where curvature is most often read (a Laplace approximation, a Newton step’s convergence), the two agree.

Programs over manifolds#

The chart Hessian is the one a forward-over-reverse pass computes, provided each step’s second-order map is read in charts the same way.

Proposition 4(The passes compute chart derivatives).

Let a program’s steps be maps between manifolds, with partial derivatives ∂jF\partial_j \map taken in tangent charts. Then for a scalar target ff, the reverse pass delivers the chart gradient g(x)g(\point) at the roots. If moreover ⊕\oplus is smooth near each slot’s value, and each step’s second-order map at its inputs ss, with velocities vs\tangent_s, is

hvp⁡j(α)=ddt∣t=0∂jF(s⊕tvs)⊤α, \hvp_j(\alpha) = \frac{\dd}{\dd t}\Big|_{t=0} \partial_j \map(s \oplus t\tangent_s)\transpose \alpha ,

then forward-over-reverse with velocities v\tangent delivers the chart Hessian product H(x) vH(\point)\,\tangent.

Proof.

First order is Proposition 3 applied step by step. For the second, the reverse recurrence holds identically in x\point, with every ∂jF\partial_j \map evaluated at the slot values computed from x\point and read in the charts at those values. Differentiate it along xt=x⊕tv\point_t = \point \oplus t \tangent. Each slot traces a curve s(xt)s(\point_t) through s(x)s(\point) whose velocity in the chart at s(x)s(\point) is vs=Ds(x) v\tangent_s = \D s(\point)\, \tangent, the velocity the forward pass computes. The derivative of the smooth function s↦∂jF(s)⊤αs \mapsto \partial_j \map(s)\transpose \alpha along a curve depends only on the curve’s velocity, so it equals the derivative along s⊕tvss \oplus t \tangent_s, which is hvp⁡j(α)\hvp_j(\alpha). The product rule then gives the forward-over-reverse recurrence, and at a root the differentiated quantity is g(xt)g(\point_t), whose derivative is (2).

∎

Built on by