121. Hessian Matrix

121.1. Hessian Matrix

Square matrix of second-order partial derivatives

Describes the local curvature of a multivariable function

𝑓:𝑛

Input: 𝐱=[𝑥1𝑥2𝑥𝑛]

Output: Scalar

𝐻𝑓(𝐱)=[𝜕2𝑓𝜕𝑥12𝜕2𝑓𝜕𝑥1𝜕𝑥2𝜕2𝑓𝜕𝑥1𝜕𝑥𝑛𝜕2𝑓𝜕𝑥2𝜕𝑥1𝜕2𝑓𝜕𝑥22𝜕2𝑓𝜕𝑥2𝜕𝑥𝑛𝜕2𝑓𝜕𝑥𝑛𝜕𝑥1𝜕2𝑓𝜕𝑥𝑛2𝜕𝑥2𝜕2𝑓𝜕𝑥𝑛2]

Diagonal entries: 𝜕2𝑓𝜕𝑥𝑖2

Second derivative of 𝑓 with respect to a single variable twice

How the slope of 𝑓 changes as you move along the 𝑥1 direction

Off-diagonal entries: 𝜕2𝑓𝜕𝑥𝑖𝜕𝑥𝑗 where 𝑖𝑗

How the slope in one direction changes when you move in a different direction

𝜕2𝑓𝜕𝑥1𝜕𝑥2: How the rate of change of 𝑓 along 𝑥1 changes as you move in the 𝑥2 direction

Symmetric (Clairaut-Schwarz theorem):

𝜕2𝑓𝜕𝑥𝑖𝜕𝑥𝑗=𝜕2𝑓𝜕𝑥𝑗𝜕𝑥𝑖𝐻𝑓(𝑥)=𝐻𝑓(𝑥)𝑇
Example
𝑓(𝑥,𝑦)=𝑥3𝑦+𝑦2
  • Symbolic Hessian
2𝑓(𝑥,𝑦)=[𝜕2𝑓𝜕𝑥2𝜕2𝑓𝜕𝑥𝜕𝑦𝜕2𝑓𝜕𝑦𝜕𝑥𝜕2𝑓𝜕𝑦2]=[6𝑥𝑦3𝑥23𝑥22]
  • Evaluate at (𝑥,𝑦)=(1,2)
2𝑓(1,2)=[6123123122]=[12332]

Each entry is now a scalar, and the Hessian is numeric