Curvature as a second-derivative matrix
For scalar f, the Hessian Hᵢⱼ = ∂²f/(∂xᵢ∂xⱼ). For f(x,y) = x² + 3y², H = [[2, 0], [0, 6]], so curvature is stronger along y. Positive curvature in every direction indicates a strict local minimum; mixed positive and negative curvature indicates a saddle, under the usual smoothness conditions.
Newton's method uses curvature to choose a step, but a neural-network Hessian is enormous and can be indefinite. Large-scale optimisers therefore use approximations or first-order methods. See matrix calculus and convexity.
Read dimensions before multiplying derivatives
If f maps n inputs to m outputs, its Jacobian has shape m×n under the row-output convention. A small input change Δx produces the first-order approximation Δf≈JΔx. For f(x,y)=(x²+y, xy), the Jacobian is [[2x,1],[y,x]], a 2×2 matrix because there are two outputs and two inputs. The multivariable chain rule composes these local linear approximations by matrix multiplication; reversing their order is a common shape and meaning error.
For a scalar-valued function, the Hessian is the matrix of second partial derivatives. When second derivatives are continuous, mixed partials agree and the Hessian is symmetric. At a stationary point, positive curvature in every direction identifies a strict local minimum; mixed positive and negative curvature identifies a saddle. Positive semidefinite curvature alone may be inconclusive, and a local minimum need not be global unless additional conditions such as convexity hold. Newton's method uses curvature to scale an update, but an indefinite Hessian or ill-conditioned matrix can make that step unsafe.
Try this above
Compare the Jacobian entries as you move the input, then inspect how the Hessian changes the local curvature estimate.
In a one-dimensional problem, the Jacobian reduces to the ordinary derivative and the Hessian to the second derivative. In several dimensions, the Hessian stores how each gradient component changes with each input. For f=x²+3y², the diagonal entries 2 and 6 indicate the quadratic bowl is steeper along y. Off-diagonal terms describe interaction in curvature. The Hessian is local: it describes curvature near one point and can change elsewhere. For a nonconvex function, checking curvature at one point does not establish global behaviour.
The Hessian can guide a local quadratic approximation, but forming it explicitly costs memory proportional to the square of the number of parameters. For a neural network with millions of parameters, that is often impractical. First-order methods use gradients; second-order methods may use Hessian-vector products or approximations instead. A small Hessian example teaches curvature, but implementation should account for shape, symmetry, conditioning, and computational scale.