CALCULUS / 6. SECOND ORDER & HESSIAN
Second Order Derivatives & The Hessian
Curvature — how fast the gradient is changing
EXPLANATION
The second derivative measures the rate of change of the derivative — the curvature of the function. d²f/dx² > 0 → concave up (bowl) → local minimum below d²f/dx² < 0 → concave down (hill) → local maximum below d²f/dx² = 0 → inflection point For multivariable functions, the second-order information is captured by the Hessian matrix H. From Raschka's appendix, for f: Rⁿ → R: Hf[i,j] = ∂²f / (∂xᵢ ∂xⱼ) The Hessian is an n×n matrix of all second-order partial derivatives. Why it matters for ML: • Positive definite Hessian → at a critical point (∇f=0), it's a minimum • Newton's method uses H⁻¹∇f for faster optimization (but H⁻¹ is expensive for big networks) • Condition number of H tells you how hard the optimization landscape is • Adam optimizer approximates second-order information without computing H The Laplacian Δf = Σ ∂²f/∂xᵢ² is the trace of the Hessian — sum of all second order partial derivatives w.r.t. the same variable.
DIAGRAM
f(x) = x³ - 3x:
f'(x) = 3x² - 3 (first derivative)
f''(x) = 6x (second derivative)
At x=-1: f'=0 (critical), f''=-6 < 0 → LOCAL MAX
At x=+1: f'=0 (critical), f''>+6 > 0 → LOCAL MIN
Hessian of f(x,y) = x²y + y:
∂²f/∂x² ∂²f/∂x∂y 2y 2x
H = [ ] = [ ]
∂²f/∂y∂x ∂²f/∂y² 2x 0
At (1,1): H = [[2,2],[2,0]]
det(H) = 0-4 = -4 < 0 → SADDLE POINT
(neither min nor max — common in neural networks!)CODE