In one variable the sign of f′′(x0) tells whether a stationary point is a maximum or a minimum. In several variables the second derivatives are n2 in number and must be organized in a matrix; their "sign" becomes the sign of a quadratic form.
Higher-order derivatives and Schwarz's theorem
Consider a function f:D⊆Rn→R. If the first partial derivatives ∂xi∂f are in turn differentiable, we obtain the second-order partial derivativesderivatives of the partial derivatives, defined by:
∂xj∂xi∂2f=∂xj∂(∂xi∂f)
When i=j they are called mixed derivatives. A function is said to be of class C2a function whose second partial derivatives are continuous on an open set D.
Schwarz's theorem. Let f:D⊆Rn→R be a function of class C2 in a neighbourhood of x0∈D. Then the mixed derivatives are equal at x0:
∂xi∂xj∂2f(x0)=∂xj∂xi∂2f(x0)
This theorem guarantees that, for sufficiently regular functions, the order of differentiation does not affect the result. In fact it suffices that the two mixed derivatives exist near x0 and are continuous at x0. Without continuity it can fail: the classic counterexample is f(x,y)=x2+y2xy(x2−y2), f(0,0)=0, for which fxy(0,0)=−1 and fyx(0,0)=1.
Example.f(x,y)=sin(x2y)+4x3y2.
fx=2xycos(x2y)+12x2y2, fy=x2cos(x2y)+8x3y.
fxy=∂y∂fx=2xcos(x2y)−2xy⋅x2sin(x2y)+24x2y=2xcos(x2y)−2x3ysin(x2y)+24x2y (product 2xy⋅cos(x2y) differentiated in y: the derivative of cos(x2y) with respect to y is −x2sin(x2y)).
fyx=∂x∂fy=2xcos(x2y)−x2⋅2xysin(x2y)+24x2y: equal to fxy, as Schwarz predicts.
The Hessian matrix is the main tool for analysing the local curvature of a function.
Definition. Given f∈C2(D), the Hessian matrix Hf(x0) is the n×n square matrix defined by:
Hf(x0)=fx1x1⋮fxnx1…⋱…fx1xn⋮fxnxn
By Schwarz's theorem, the Hessian matrix is symmetric (Hf=HfT).
Example: let f(x,y)=ex2+y.
Compute the gradient: ∇f=(2xex2+y,ex2+y).
Differentiate with respect to x and y to obtain the entries of Hf:
fxx=2ex2+y+4x2ex2+y, fxy=2xex2+y, fyy=ex2+y.
Hf(x,y)=ex2+y(2+4x22x2x1)
Taylor formula. Let f∈C2 in a neighbourhood of x0. For h sufficiently small,
f(x0+h)=f(x0)+∇f(x0)⋅h+21hTHf(x0)h+o(∥h∥2)
where hTHfh is the quadratic formthe sum of the terms a_ij h_i h_j: a homogeneous polynomial of degree two in the components of h associated with the Hessian.
In two variables, with h=(h,k) and the derivatives evaluated at (x0,y0):
f(x0+h,y0+k)=f+fxh+fyk+21(fxxh2+2fxyhk+fyyk2)+o(h2+k2)
The 2 in front of fxy comes from the two equal terms fxyhk and fyxkh in the product hTHh.
Example.f(x,y)=ex2+y at (0,0): f=1, ∇f=(0,1), Hf(0,0)=(2001) (from the formula above with x=y=0). Hence
ex2+y=1+y+21(2x2+y2)+o(x2+y2)=1+y+x2+2y2+o(x2+y2)
Check: with u=x2+y, eu=1+u+2u2+⋯=1+x2+y+2y2+… (the terms x4, x2y are of order higher than two).
Definite, semidefinite and indefinite symmetric matrices
At a critical point (∇f(x0)=0) the Taylor formula becomes f(x0+h)−f(x0)=21hTHf(x0)h+o(∥h∥2): the sign of f(x0+h)−f(x0) near x0 is that of the quadratic form q(h)=hTAh with A=Hf(x0). For this reason we need to classify symmetric matrices.
Definition. A symmetric n×n matrix A is:
positive definite if hTAh>0 for every h=0;
negative definite if hTAh<0 for every h=0;
positive (negative) semidefinite if hTAh≥0 (≤0) for every h, and vanishes for some h=0;
indefinite if there exist h1,h2 with h1TAh1>0 and h2TAh2<0.
Example.A=(2003) is positive definite (hTAh=2h12+3h22>0); B=(100−1) is indefinite (hTBh=h12−h22 changes sign).
Eigenvalue criterion. A symmetric matrix has n real eigenvalues λ1,…,λn (see Linear Algebra). It is positive definite if they are all >0, negative definite if all <0, semidefinite if they are all ≥0 (or all ≤0) and at least one is zero, indefinite if there are some of opposite sign.
Leading principal minors criterion (Sylvester). Let Ak be the submatrices formed by the first k rows and k columns:
Positive definite:detAk>0 for every k=1,…,n.
Negative definite: the signs alternate starting from negative: detA1<0,detA2>0,detA3<0,… (i.e. (−1)kdetAk>0).
The criterion works only for definite matrices: if some minor is zero it does not say anything precise.
The 2×2 case. For A=(abbc), the eigenvalues have product detA=ac−b2 and sum a+c. Therefore:
detA>0: eigenvalues of the same sign; if a>0 positive definite, if a<0 negative definite (a and c have the same sign, because ac>b2≥0).
detA<0: eigenvalues of opposite sign, indefinite.
detA=0: one eigenvalue is zero, semidefinite (or null).
Examples.(2113): det=5>0 and a=2>0, positive definite. (1221): det=−3<0, indefinite (indeed q(1,−1)=1−4+1=−2<0 and q(1,0)=1>0). (−444−4): det=0, negative semidefinite (q(h,k)=−4(h−k)2≤0).
Forgetting the factor 1/2: in the Taylor formula the quadratic term must always be multiplied by 1/2.
Applying Schwarz without its hypotheses: for piecewise-defined functions the mixed derivatives at the junction point must be computed from the definition and can be different.
Confusion in the signs of the minors criterion: for negative definite the first minor (detA1=a11) must be negative, the second positive; "all negative" is wrong.
Forgetting the 2 of the mixed term when writing Taylor in two variables: it is 2fxyhk.
Versione ripasso
Schwarz's theorem. If f∈C2 in a neighbourhood of x0, the mixed derivatives coincide: fxixj(x0)=fxjxi(x0). It suffices that the mixed ones exist near x0 and are continuous at x0. Without this hypothesis it can fail: for f=x2+y2xy(x2−y2) we have fxy(0,0)=−1 and fyx(0,0)=1.
Hessian.Hf(x0)=(fxixj(x0))ij is symmetric by Schwarz. Example: f=ex2+y has Hf(x,y)=ex2+y(2+4x22x2x1).
Second-order Taylor (f∈C2).f(x0+h)=f(x0)+∇f(x0)⋅h+21hTHf(x0)h+o(∥h∥2)
In two variables: f(x0+h,y0+k)=f+fxh+fyk+21(fxxh2+2fxyhk+fyyk2)+o(h2+k2). The 2 in front of fxy comes from the two equal terms hk and kh.
Example: f=ex2+y at (0,0), with H=(2001), gives ex2+y=1+y+x2+2y2+o(x2+y2). Check: with u=x2+y, eu=1+u+2u2+….
Quadratic forms. A symmetric matrix A is:
positive definite if hTAh>0 for h=0; negative definite if <0;
positive (negative) semidefinite if ≥0 (≤0) everywhere and vanishes for some h=0;
indefinite if it takes values of both signs.
Examples: diag(2,3) is positive definite; diag(1,−1) is indefinite.
Criteria.
Eigenvalues: positive definite if all >0, negative definite if all <0, indefinite if of mixed sign, semidefinite if one is zero and the others have the same sign.
Leading principal minors (Sylvester): positive definite if detAk>0 for every k; negative definite if detA1<0, detA2>0, detA3<0, ... The criterion decides only for definite matrices.