Quadratic function of multiple variables

From Calculus

Definition

Consider variables x1,x2,,xn. A quadratic function of the variables x1,x2,,xn is a function of the form:

(i=1nj=1naijxixj)+(i=1nbixi)+c

In vector form, if we denote by x the column vector with coordinates x1,x2,,xn, then we can write the function as:

xTAx+bTx+c

where A is a n×n matrix with entries aij and b is the column vector with entries bi.

Note that the matrix A is non-unique: if A+AT=F+FT then we could replace A by F. Therefore, we could choose to replace A by the matrix (A+AT)/2 and have the advantage of working with a symmetric matrix.

Key data

For the discussion here, assume that A has been made a symmetric matrix.

Item Value Consistency with the case n=1, where f(x)=ax2+bx+c, A=(a) (a 1×1 matrix), b=(b) (a 1-dimensional vector)
default domain the whole of Rn the whole of R
range If the matrix A is not positive semidefinite or negative semidefinite, the range is all of R.
If the matrix A is positive definite or (A is positive semidefinite and b is in its image), the range is [m,) where m is the minimum value. If the matrix A is negative definite or (A is negative semidefinite and b is in its image), the range is (,m] where m is the maximum value.
The case of "not positive semidefinite or negative semidefinite" does not arise for n=1. Moreover, all the semidefinite cases must be definite, so we only have to consider the positive definite case and the negative definite case.
The positive definite case corresponds to a>0
The negative definite case corresponds to a<0
local minimum value and points of attainment If the matrix A is positive definite, then c14bTA1b, attained at 12A1b
If A is positive semidefinite but not positive definite, it depends on whether b is in the image of A. If yes, replace A1b with the solution v to Av=b, so we get a local minimum of c14bTv attained at 12v
If A is not positive semidefinite or if b is not in the image of A, no local minimum value
The positive definite case corresponds to a>0: Here, the local minimum value of cb24a is attained at b2a (consistent with the matrix formulation)
The negative definite case corresponds to a<0, and there is no minimum in this case.
local maximum value and points of attainment If the matrix A is negative definite, then c14bTA1b, attained at 12A1b
If A is negative semidefinite but not negative definite, it depends on whether b is in the image of A. If yes, replace A1b with the solution v to Av=b, so we get a local minimum of c14bTv attained at 12v
If A is not negative semidefinite or if b is not in the image of A, no local minimum value
The negative definite case corresponds to a<0: Here, the local maximum value of cb24a is attained at b2a (consistent with the matrix formulation)
The positive definite case corresponds to a>0, and there is no maximum in this case.
gradient vector function (analogous to the derivative) x2Ax+b the derivative is x2ax+b (consistent with the matrix formulation)
Hessian matrix (analogous to the second derivative) x2A (constant matrix-valued function) the second derivative is the constant function x2a (consistent with the matrix formulation)

Differentiation

Partial derivatives and gradient vector

Case of general matrix

The partial derivative with respect to the variable xi, and therefore also the ith coordinate of the gradient vector, is given by:

fxi=(j=1n(aij+aji)xj)+bi

In terms of the matrix and vector notation, the gradient vector, expressed as a column vector, is:

(f)(x)=(A+AT)x+b

Case of symmetric matrix

In the case that A is a symmetric matrix, the above expressions simplify as follows.

Since aij=aji for all i,j, the expression for the partial derivative becomes:

fxi=(j=1n2aijxj)+bi

The expression for the gradient vector becomes:

(f)(x)=2Ax+b

Case n=1

A sanity check for the above expressions is that in the case n=1, where A=(a),b=b, we get the same answers as for the quadratic function f(x)=ax2+bx+c.

This is indeed the case. The only partial derivative here is the ordinary derivative, and this also is the gradient vector, and has expression:

f(x)=2ax+b

This agrees with both the expression for f/xi and the expression for (f)(x).

Second-order partial derivatives and Hessian matrix

Case of general matrix=

Recall that we had obtained (we replace the dummy variable j by k to facilitate differentiation with respect to j in the next step):

fxi=(k=1n(aik+aki)xk)+bi

Differentiating both sides with respect to xj (note that j may be equal to i or different from i) we find that the only term with a nonzero derivative is the term where k=j. In this case, the derivative is the coefficient of xj. Therefore, we obtain:

2fxjxi=aij+aji

Thus, the Hessian matrix of the quadratic function is given as:

H(f)(x)=A+AT

Note that this is independent of the choice of x. This fact is true only because of the nature of the function: for more general functional forms, the Hessian matrix varies with the choice of input vector.

We can also see this in matrix form directly. The gradient function is:

(f)(x)=(A+AT)x+b

This is a linear transformation, and the Jacobian matrix of this linear transformation computes the Hessian that we want. We can use the well-known fact that the Jacobian matrix of a linear transformation coincides with the matrix describing the linear part of the transformation, and therefore the Hessian is:

H(f)(x)=A+AT

Case of symmetric matrix

We can either plug into the formulas for the general case or perform similar calculations to get the formulas in the case that A is a symmetric matrix:

2fxjxi=2aij

H(f)(x)=2A

Case n=1

A sanity check for the above expressions is that in the case n=1, where A=(a),b=b, we get the same answers as for the quadratic function f(x)=ax2+bx+c.

This is indeed the case. The only second-order partial derivative is f(x)=2a. This agrees both with the formula for the second-order partial derivative and with the formula for the Hessian matrix.

Higher derivatives

All higher order partial derivatives (pure or mixed) are zero. This can be seen directly from the fact that the second-order partial derivatives are all constants, so differentiating them further (with respect to any variable) gives zero.

Therefore, the higher derivative tensors (the higher-order analogues of the gradient vector and Hessian matrix) are also identically zero.

Cases

For the discussion of cases, assume that A is a symmetric matrix. If A is not symmetric, replace it by the symmetric matrix (A+AT)/2.

Positive definite case

First, we consider the case where A is a symmetric positive definite matrix. In other words, we can write A in the form:

A=MTM

where M is a n×n invertible matrix.

We can "complete the square" for this function:

f(x)=(Mx+12(MT)1b)T(Mx+12(MT)1b)+(c14bTA1b)

In other words:

f(x)=Mx+12(MT)1b2+(c14bTA1b)

This is minimized when the expression whose norm we are measuring is zero, so that it is minimized when we have:

Mx+12(MT)1b=0

Simplifying, we obtain that we minimum occurs at:

x=12A1b

Moreover, the value of the minimum is:

c14bTA1b