From First-Order Change to Curvature
A first differential describes how a scalar function changes under a small matrix perturbation. To understand local curvature, we need the next-order change: how the first-order rate itself varies as the matrix moves. For a scalar matrix function, that second-order information is naturally a bilinear function of two perturbation directions. A Hessian matrix is one coordinate representation of this bilinear object.
The distinction matters because the second differential takes two matrix directions as inputs and returns a scalar, whereas a Hessian matrix takes vectorized coordinates as its representation. Stating the vectorization convention makes that representation unambiguous.
Here \(D^2f(X)[U,V]\) is a scalar. In particular, it is not itself a matrix. We use column-wise vectorization: \(\operatorname{vec}(X)\) stacks the columns of \(X\) into a vector in \(\mathbb{R}^{mn}\). The matrix gradient \(\nabla f(X)\) is defined by \(df_X[U]=\operatorname{tr}(\nabla f(X)^T U)\).
The Hessian has \(mn\) rows and \(mn\) columns, regardless of the shape of \(X\). One may also describe the same second-order information as a four-index array, but that representation depends more heavily on how indices are ordered. The vectorized definition fixes the ordering explicitly.
Directional Derivatives and Hessian Symmetry
A practical way to calculate curvature in a direction \(U\) is to restrict \(f\) to the line through \(X\) in that direction: define \(g(t)=f(X+tU)\) wherever \(X+tU\in\mathcal{D}\). The ordinary one-variable second derivative \(g''(0)\) is exactly \(d^2f_X[U,U]\). This gives a direct interpretation of the second differential as the rate of change of the first directional derivative.
Proof. Write \(x=\operatorname{vec}(X)\), \(u=\operatorname{vec}(U)\), and \(v=\operatorname{vec}(V)\). Since \(\mathcal{D}\) is open, the points \(x+su+tv\) remain in the coordinate domain for sufficiently small \(s,t\). Define \(\phi(s,t)=f(\operatorname{unvec}(x+su+tv))\), where \(\operatorname{unvec}\) reverses the column-wise vectorization. The chain rule gives \(\frac{\partial^2\phi}{\partial s\,\partial t}(0,0)=d^2f_X[U,V]\) and \(\frac{\partial^2\phi}{\partial t\,\partial s}(0,0)=d^2f_X[V,U]\). Because the second partial derivatives of \(f\), and therefore those of \(\phi\), are continuous, the equality of mixed partial derivatives gives \(d^2f_X[U,V]=d^2f_X[V,U]\). Taking \(U\) and \(V\) to be coordinate basis matrices shows that the corresponding Hessian entries satisfy \(\mathbf{H}_{ij}=\mathbf{H}_{ji}\). \(\square\)
Worked Example: The Squared Frobenius Norm
Let \(f(X)=\frac{1}{2}\|X\|_F^2=\frac{1}{2}\operatorname{tr}(X^T X)\), with \(X\in\mathbb{R}^{2\times2}\). At \(X=\begin{pmatrix}1&2\\-1&0\end{pmatrix}\), take \(U=\begin{pmatrix}2&-1\\3&4\end{pmatrix}\). Find the gradient, Hessian, and second directional derivative.
For any perturbation \(U\), expand the function along \(X+tU\): \[ f(X+tU)=\frac{1}{2}\operatorname{tr}\big((X+tU)^T(X+tU)\big) =f(X)+t\operatorname{tr}(X^T U)+\frac{t^2}{2}\operatorname{tr}(U^T U). \] Thus \(df_X[U]=\operatorname{tr}(X^T U)\), so \(\nabla f(X)=X\). The coefficient of \(t^2/2\) gives \(d^2f_X[U,U]=\operatorname{tr}(U^T U)=\|U\|_F^2\); by bilinearity, \(d^2f_X[U,V]=\operatorname{tr}(U^T V)\). Therefore the vectorized Hessian is the \(4\times4\) identity matrix.
At the stated \(X\), \(f(X)=\frac{1}{2}(1+4+1+0)=3\), and the directional derivative is \(\operatorname{tr}(X^T U)=1(2)+2(-1)+(-1)(3)+0(4)=-3\). The second directional derivative is \(\|U\|_F^2=2^2+(-1)^2+3^2+4^2=30\). The Hessian is constant, so this curvature value does not depend on the base point \(X\).
Worked Example: Curvature of the Log-Determinant
For \(X\) in the open set of real matrices with positive determinant, let \(f(X)=\log\det X\). Find its second differential and evaluate the second directional derivative at \(X=\begin{pmatrix}2&0\\0&3\end{pmatrix}\) in direction \(U=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\).
The first differential is \(df_X[U]=\operatorname{tr}(X^{-1}U)\), so the Frobenius gradient is \(X^{-T}\). The inverse differential is \(d(X^{-1})[V]=-X^{-1}VX^{-1}\); transposing gives \(d(X^{-T})[V]=-X^{-T}V^T X^{-T}\). Hence \[ d^2f_X[U,V]=\operatorname{tr}\big((-X^{-1}V X^{-1})U\big) =-\operatorname{tr}(X^{-1}V X^{-1}U). \] By cyclicity of trace, this is also \(-\operatorname{tr}(X^{-1}U X^{-1}V)\), displaying the symmetry in \(U\) and \(V\).
For the specified \(X\), \(X^{-1}=\begin{pmatrix}1/2&0\\0&1/3\end{pmatrix}\). Thus \(X^{-1}U=\begin{pmatrix}1/2&0\\0&-1/3\end{pmatrix}\), and \[ d^2f_X[U,U]=-\operatorname{tr}\big((X^{-1}U)^2\big) =-\left(\frac{1}{4}+\frac{1}{9}\right)=-\frac{13}{36}. \] This is the second derivative of \(t\mapsto\log\det(X+tU)\) at zero. The line remains in the positive-determinant domain for sufficiently small \(t\), as its determinant is \((2+t)(3-t)>0\) near zero.
Second-Order Taylor Approximation
The second differential describes the quadratic term in a local approximation to \(f\). The following result makes that statement precise. The remainder is smaller than the squared size of the perturbation, measured in Frobenius norm.
Proof. Since \(\mathcal{D}\) is open, for all sufficiently small \(E\) the segment \(X+tE\), \(0\le t\le1\), lies in \(\mathcal{D}\). Let \(g(t)=f(X+tE)\). Then \(g'(t)=df_{X+tE}[E]\) and \(g''(t)=d^2f_{X+tE}[E,E]\). Applying the fundamental theorem of calculus twice gives \[ f(X+E)=f(X)+df_X[E]+\int_0^1(1-t)d^2f_{X+tE}[E,E]\,dt. \] After subtracting \(\frac{1}{2}d^2f_X[E,E]\), the remainder is \[ \int_0^1(1-t)\big(d^2f_{X+tE}[E,E]-d^2f_X[E,E]\big)\,dt. \] Continuity of the second derivative at \(X\) implies that the operator norm of \(D^2f(X+tE)-D^2f(X)\) tends uniformly to zero over \(0\le t\le1\) as \(\|E\|_F\to0\). The absolute remainder is therefore at most \[ \frac{1}{2}\|E\|_F^2\sup_{0\le t\le1}\|D^2f(X+tE)-D^2f(X)\|_{\mathrm{op}} =o(\|E\|_F^2). \] This proves the expansion. \(\square\)
Worked Example: An Exponential of a Linear Matrix Function
Let \(f(X)=\exp(\operatorname{tr}(C^T X))\), with \(C=\begin{pmatrix}1&2\\0&-1\end{pmatrix}\). At \(X=0\), compute the gradient, Hessian, and second directional derivative for \(U=\begin{pmatrix}1&0\\0&2\end{pmatrix}\).
Write \(s(X)=\operatorname{tr}(C^T X)\). Its differential is \(ds_X[U]=\operatorname{tr}(C^T U)\), so the chain rule gives \(df_X[U]=e^{s(X)}\operatorname{tr}(C^T U)\) and \(\nabla f(X)=e^{s(X)}C\). Differentiating this gradient in direction \(V\) yields \(e^{s(X)}\operatorname{tr}(C^T V)C\). Consequently, \[ d^2f_X[U,V]=e^{s(X)}\operatorname{tr}(C^T U)\operatorname{tr}(C^T V), \qquad \mathbf{H}_f(X)=e^{s(X)}\operatorname{vec}(C)\operatorname{vec}(C)^T. \]
At \(X=0\), \(s(0)=0\), so \(e^{s(0)}=1\). Also \(\operatorname{tr}(C^T U)=1(1)+2(0)+0(0)+(-1)(2)=-1\). Therefore \(d^2f_0[U,U]=(-1)^2=1\). The Hessian is a rank-one \(4\times4\) matrix, since it is \(\operatorname{vec}(C)\operatorname{vec}(C)^T\) and \(C\ne0\).
Common Pitfall: Mixing Up the Objects
A common mistake is to call \(d^2f_X[U,U]\) “the Hessian.” It is only one scalar curvature value, for one direction. The Hessian \(\mathbf{H}_f(X)\) records all coordinate second derivatives; inserting a direction into both slots of the second differential gives the scalar \(\operatorname{vec}(U)^T\mathbf{H}_f(X)\operatorname{vec}(U)\). Another source of errors is silently changing vectorization order. A Hessian computed under column-wise stacking cannot be combined with coordinates stacked in a different order without changing its entries.
The directional form is often the clearest way to state what curvature means, while the Hessian matrix is useful for coordinate calculations and software implementations. Both describe the same second-order information when the coordinate convention is fixed. In later optimization work, Hessians will be used to study objectives; here the essential point is how to define and interpret that object.
Check Your Understanding
Use the column-wise vectorization convention in your answers.
- For a function on \(\mathbb{R}^{3\times2}\), what are the dimensions of its matrix Hessian?
- Explain the difference between \(d^2f_X[U,U]\) and \(\mathbf{H}_f(X)\).
- Under what regularity condition does equality of mixed partial derivatives imply symmetry of the Hessian?
- For \(f(X)=\frac{1}{2}\|X\|_F^2\), what is \(d^2f_X[U,U]\) for an arbitrary perturbation \(U\)?
- Why must a Taylor expansion along \(X+tE\) be restricted to a segment that stays inside the function's domain?