Trading Dev AcademyFree quant education

Free lesson · Partial derivatives

Hessians, mixed derivatives and second-order scenarios

Open interactive lessonPractice calculationsExplore labs

Start with the idea

  • A Hessian gathers second derivatives.
  • Its diagonal entries describe curvature in one coordinate; its off-diagonal entries describe how one sensitivity changes as another input changes.
  • Those interactions matter when inputs move together.
Symbols, units & horizon
  • H: Hessian matrix, not a candle high here
  • fₓₓ,fᵧᵧ: pure second partial derivatives
  • fₓᵧ,fᵧₓ: mixed second partials
  • h=(Δx,Δy): input-change vector
  • ∇f: gradient at the starting point
  • hᵀHh: quadratic form
  • Δf: output change
  • Each Hessian entry: output units divided by the two associated input units

When and why to use this

Use Hessians to inspect local curvature, compare first- and second-order scenario estimates, and understand optimisation conditioning.

  • For a function with continuous second partials in a neighbourhood, mixed partial derivatives agree.
  • Without the regularity assumptions that symmetry cannot simply be assumed.
  • A Hessian is local, just like a gradient.
  • The second-order multivariable Taylor term is one half of a quadratic form in the input changes.
  • Off-diagonal terms appear twice in the full sum, so the two-variable cross contribution has no remaining one-half factor when the Hessian is symmetric.
H=(fxxfxyfyxfyy),Δf≈∇f𝖳h+12h𝖳Hh
Calculus: derivation and arithmetic

Hessians, mixed derivatives and second-order scenarios

  1. For f=x²+xy+2y², compute fₓ=2x+y and fᵧ=x+4y. Differentiate again to obtain H=[[2,1],[1,4]].
  2. Expand hᵀHh=2(Δx)²+2ΔxΔy+4(Δy)². Multiplying by one half gives the curvature correction.
  3. At (1,1), gradient=(3,5). With h=(.1,−.2), the linear term is −.7. Curvature is .01−.02+.08=.07, giving total −.63.
Work it by hand

Original value f(1,1)=4. New value f(1.1,.8)=3.37. The change is exactly −.63 because this function is quadratic and has no higher-order remainder.

An analogy to remember

Bending a sheet in two directions can create an interaction that neither one-direction bend captures. Mixed derivatives quantify that local interaction.

How this becomes a building block

Gamma is one entry of a pricing Hessian. Cross sensitivities such as spot–volatility interaction can matter in a joint market shock. In portfolio optimisation, the covariance quadratic form supplies curvature of a mean–variance objective.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def quadratic_value(x,y): return x*x+x*y+2*y*y

def quadratic_change(x,y,dx,dy):
    linear=(2*x+y)*dx+(x+4*y)*dy
    curvature=dx*dx+dx*dy+2*dy*dy
    return linear,curvature,linear+curvature

print(quadratic_change(1,1,.1,-.2),quadratic_value(1.1,.8)-quadratic_value(1,1))

Continue learning

Multivariable Calculus & Partial Derivatives — all lessons
  1. Start with two inputs: change only one
  2. Partial derivatives: holding the other inputs fixed
  3. Gradients, directional derivatives and Jacobians
  4. Hessians, mixed derivatives and second-order scenarios
  5. Constrained optimisation and multiple integrals

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations