Lecture 50 · Week 13· 19:11
Quadratic forms
Positive definiteness, principal axes.
Saved in this browser only. No account needed.
TranscriptThe full text of the lecture. Click any sentence to play the video from there.
Today: squares and cross terms
Welcome back. Last time we proved the spectral theorem: every real symmetric matrix is Q D Q transpose, with Q orthogonal and D diagonal. Today we use it to understand expressions such as eleven x one squared, plus six x one x two, plus three x two squared. Expressions like this appear all over mathematics. The squared length of a vector in the plane, x one squared plus x two squared, is one of them. The weighted inner product of lecture forty five, taken of a vector with itself, two v one squared plus three v two squared, is another. Each of them adds up squares and products of the coordinates, with no linear terms and no constant. We ask two questions. Is such an expression positive at every nonzero vector? And what does the curve where it is constant look like?
For the squared length, both answers are easy: yes, and the curves are circles. The difficulty is the cross term, six x one x two, which mixes the two coordinates. The spectral theorem will remove it. Here is the plan. First, quadratic forms and their symmetric matrices. Then the principal axes theorem, which removes the cross terms, and the level curves in the plane. Then positive definite forms, which you can also explore on the website. Finally, two tests that avoid eigenvalues.
Quadratic forms and symmetric matrices
Let A be a real symmetric n by n matrix. Its quadratic form is the function q A, from R n to R, that sends x to x transpose A x. Written out, it is the double sum, over j and k, of a j k, times x j, times x k. Every term has degree two in the coordinates. For a two by two matrix with the rows a, b, and b, c, the product gives four terms: a x one squared, plus b x one x two, plus b x two x one, plus c x two squared.
The two middle terms are equal, so they pack into one. The cross term has the coefficient two b, because b appears twice in the matrix. In general, a quadratic form on R n is any function given by such a polynomial: a sum of terms c j k, x j, x k, with j at most k. And here is the key fact. Every quadratic form is q A for exactly one real symmetric matrix A. To find A, put the coefficient of x j squared on the diagonal, in position j j. Then split the coefficient of each cross term x j x k in half, between the positions j k and k j.
In our example, the diagonal holds eleven and three, and the cross coefficient six splits into three and three. So A has the first row eleven, three, and the second row three, three. Why only one matrix? Its entries can be read off from the values of the form. At e j, the form equals a j j. At e j plus e k, with j different from k, it equals a j j, plus a j k, plus a k j, plus a k k. And a k j equals a j k, because A is symmetric, so this is a j j, plus two a j k, plus a k k. So the form decides every entry of A. And why symmetric matrices? Any square matrix B gives a quadratic form, x transpose B x. But B and its transpose give the same form, and so does their average, which is symmetric. Many matrices give the same form, and exactly one of them is symmetric: the one the spectral theorem applies to.
The principal axes theorem
Now the key idea: a change of variables. Put x equal to P y, with P an invertible matrix. Then x transpose A x becomes y transpose, P transpose A P, y. So in the new variables, the form has the matrix P transpose A P, which is again symmetric. We want this new matrix to be diagonal, because the form of a diagonal matrix has no cross terms. If Q is orthogonal, then Q transpose is the inverse of Q. And the spectral theorem gives exactly such a Q, one that makes Q transpose A Q diagonal. Here is the principal axes theorem. Let A be a real symmetric n by n matrix, and write A as Q D Q transpose, as in the spectral theorem. The columns q one up to q n of Q are orthonormal eigenvectors of A, and D is diagonal, with the eigenvalues lambda one up to lambda n.
Put y equal to Q transpose x. Then the form becomes lambda one y one squared, plus and so on, up to lambda n y n squared. There are no cross terms. The proof takes one line. x equals Q y, because Q Q transpose is the identity. So the form is y transpose, Q transpose A Q, y. And Q transpose A Q is D, so we get y transpose D y, the sum of lambda j, y j squared. What are the new variables? Entry j of Q transpose x is q j dot x, the coordinate of x along q j. So y is the coordinate vector of x in the orthonormal basis of eigenvectors. The lines spanned by q one up to q n are called the principal axes of the form.
Back to our example. The characteristic polynomial of A is t squared, minus fourteen t, plus twenty four, which factors as t minus two, times t minus twelve. So the eigenvalues are twelve and two. For twelve, A minus twelve I has the rows (minus one, three), and (three, minus nine). Its null space is the eigenspace E twelve, spanned by the vector (three, one), an eigenvector for twelve. For two, A minus two I has the rows (nine, three), and (three, one). Its null space is the eigenspace E two, spanned by the vector (minus one, three), an eigenvector for two.
The two eigenvectors are orthogonal, as the spectral theorem promises, and both have length root ten. Dividing them by root ten gives q one and q two. So eleven x one squared, plus six x one x two, plus three x two squared, equals twelve y one squared, plus two y two squared, where y one is q one dot x, and y two is q two dot x. Let's check one value. At x equal to e one, the left side is eleven. And y one is three over root ten, while y two is minus one over root ten. So the right side is twelve times nine tenths, plus two times one tenth, which is a hundred and ten tenths, that is, eleven.
Before we draw this form, here is a way to picture any quadratic form in the plane. A point x of the plane is a choice of the two variables, x one and x two, and the form gives it one number. At e one, we just found the value eleven. Now collect all the points where the form takes one fixed value c. Together they make up a curve, called a level curve of the form, just as a contour line on a map joins the points of equal height. For our form, the values two, six and twelve give three curves, one inside the next, and a larger value gives a larger curve. Every point of the plane lies on exactly one level curve, the one for its own value. The point e one lies on the curve for eleven.
At c equal to zero, the curve shrinks to the origin alone. And a negative value gives no points at all, because twelve y one squared, plus two y two squared, is never negative. Now take the curve where the form equals twelve. It is a tilted ellipse. Turn the plane so that q one and q two lie along the axes. There, its equation is twelve y one squared plus two y two squared equals twelve. It meets the first axis at plus and minus one, and the second at plus and minus root six.
Level curves in the plane
The same argument works for every real symmetric two by two matrix, with eigenvalues lambda one and lambda two, where lambda one is the larger. Take the curve where q A equals a positive number c. In the principal axes, its equation is lambda one y one squared, plus lambda two y two squared, equals c. If both eigenvalues are positive, the curve is an ellipse. Its semi-axis along q one is the root of c over lambda one, and along q two it is the root of c over lambda two. The larger eigenvalue gives the shorter axis, because the form grows fastest in that direction. If the eigenvalues have opposite signs, the curve is a hyperbola. If one is positive and the other is zero, it is a pair of parallel lines. And if neither is positive, the curve is empty.
The change of variables only turns or reflects the plane, because Q is orthogonal, so it keeps lengths and angles. The curve in x therefore has exactly the same shape as the curve in y. That explains the name: the principal axes are the axes of symmetry of the curve. A second example: four x one squared, plus twelve x one x two, minus x two squared. Its matrix has the rows (four, six), and (six, minus one). Its characteristic polynomial is t minus eight, times t plus five, so its eigenvalues are eight and minus five. The eigenvectors are the vector (three, two), for eight, and the vector (minus two, three), for minus five. Divided by root thirteen, they give q one and q two. So the form is eight y one squared, minus five y two squared.
The curve where it equals eight is a hyperbola. It crosses the q one axis at plus and minus one, and never meets the q two axis. Its asymptotes are the two lines where eight y one squared equals five y two squared. Now draw many level curves of both examples at once. In the first form, twelve y one squared plus two y two squared, both coefficients are positive. The values two, eight and eighteen give nested ellipses around the origin, like the contour lines of a valley. In the second form, eight y one squared minus five y two squared, the coefficient of y two squared is negative. That one sign changes the picture.
Along q one the form still rises, so the positive values two, eight and eighteen give hyperbolas that cross the q one axis. Along q two it now falls, so the negative values give the dashed hyperbolas that cross the q two axis. Together they look like the contours of a mountain pass, which rises in one direction and falls in the other.
Positive definite forms
This leads to the central definition. A real symmetric matrix A, and its form, are called positive definite if x transpose A x is positive for every nonzero x, and positive semidefinite if it is at least zero for every x. Negative definite and negative semidefinite are defined in the same way, with the inequalities reversed. And A is indefinite if its form takes both positive and negative values. Theorem: A is positive definite exactly when all its eigenvalues are positive, and positive semidefinite exactly when they are all at least zero. For the negative cases, reverse the signs. And A is indefinite exactly when it has a positive and a negative eigenvalue.
Here is the proof of the first part. By the principal axes theorem, the form is the sum of lambda j, y j squared, with y equal to Q transpose x. Since Q transpose is invertible, y is nonzero exactly when x is nonzero. So if every lambda j is positive, the form is positive at every nonzero x. Conversely, at x equal to q j, the vector y is e j, and the form equals lambda j. So if the form is positive definite, every lambda j is positive. The other parts are proved in the same way. So our first example, with eigenvalues twelve and two, is positive definite, and its level curves are ellipses. The second, with eigenvalues eight and minus five, is indefinite, and its level curves are hyperbolas.
Be careful: positive coefficients are not enough. Two x one squared, plus six x one x two, plus two x two squared, has only positive coefficients. But at the vector (one, minus one), it equals two, minus six, plus two, which is minus two. Its eigenvalues are five and minus one, so it is indefinite. The principal axes also bound every form. Theorem: for every x, q A of x lies between lambda min times the length of x squared, and lambda max times the length of x squared. Here lambda min and lambda max are the smallest and the largest eigenvalue of A. For the proof, write the form as the sum of lambda j, y j squared. It is at least lambda min times the sum of the y j squared, and at most lambda max times the same sum. That sum is the length of y, squared, which equals the length of x, squared, because the orthogonal matrix Q transpose keeps lengths.
So on the unit circle, our first form takes values between two and twelve. The ellipse where it equals twelve touches the circle at plus and minus q one, and the ellipse where it equals two touches it at plus and minus q two. Watch a unit vector go around. The value is largest at plus and minus q one, and smallest at plus and minus q two. So the largest eigenvalue is the maximum of the form on unit vectors, a fact we will use for the singular value decomposition. One more connection. In lecture forty five, we met inner products on R n, such as two u one v one, plus three u two v two. In general, u transpose A v is an inner product exactly when A is symmetric and positive definite.
Try it yourself
You can explore quadratic forms yourself, on this lecture's page at Open Semester dot com. You choose the matrix A with three sliders, and the page draws its level curves, its principal axes and its eigenvalues. Here is our first example. The unit vector goes around the circle, and the value of the form moves between two and twelve, the two eigenvalues. Now make the entry b larger. The ellipses grow longer and turn, and the smaller eigenvalue falls towards zero. Once b squared is larger than a times c, the smaller eigenvalue is negative, and the ellipses break open into hyperbolas.
The example with only positive coefficients behaves the same way. Its level curves are hyperbolas, and the unit vector finds negative values around the direction of the vector (one, minus one). Try a semidefinite matrix too, whose level curves are parallel lines, and a negative definite one, which never takes a positive value. Then try your own entries.
Two tests, and a summary
Eigenvalues can be hard to compute, so here are two tests that avoid them. The first comes from least squares. For every real m by n matrix B, the matrix B transpose B is positive semidefinite, and it is positive definite exactly when the columns of B are linearly independent. The proof is short. B transpose B is symmetric, because its transpose is B transpose B again. And x transpose B transpose B x regroups as B x dot B x, which is the length of B x, squared. That is never negative. It is zero exactly when B x is the zero vector. For a nonzero x, that happens only when the columns of B are linearly dependent. Conversely, as the book shows, every positive semidefinite matrix is B transpose B for some B.
The second test uses determinants. For each k from one to n, let delta k be the determinant of the top left k by k block of A. These numbers are called the leading principal minors of A. Sylvester's criterion: a real symmetric matrix A is positive definite exactly when all its leading principal minors are positive. One direction deserves a careful look, so take it slowly. Suppose A is positive definite, and take a nonzero vector x prime in R k. Put zeros after its entries, to get a vector x in R n. Then the form of the top left block at x prime equals the form of A at x, which is positive. So the block is positive definite too.
So all eigenvalues of the block, call it S, are positive. By the spectral theorem, S is Q D Q transpose, with its own Q and D. Its determinant is the determinant of Q, times that of D, times that of Q transpose. The first and the last together give the determinant of Q Q transpose, which is one. So delta k is the determinant of D, the product of the eigenvalues, which is positive. The converse is proved by induction on n, with the dimension formula. The proof is in the book. For a two by two matrix with the rows a, b, and b, c, the criterion reads: a is positive, and a c minus b squared is positive. In our first example, eleven is positive, and thirty three minus nine is twenty four, so the form is positive definite, as we found.
A three by three example: the first row (three, one, one), the second row (one, two, zero), and the third row (one, zero, one). Delta one is three. Delta two is three times two, minus one times one, which is five. Delta three is the whole determinant. Expanding along the last row, it is one times minus two, plus one times five, which is three. All three minors are positive, so this matrix is positive definite, and we never needed its eigenvalues. A warning: for semidefinite matrices, the criterion does not simply carry over to minors that are at least zero. The book has an example.
Let's sum up. A quadratic form is x transpose A x, for exactly one symmetric matrix A. The principal axes theorem turns it into the sum of lambda j, y j squared, in the coordinates along orthonormal eigenvectors. In the plane, its level curves are ellipses or hyperbolas, with the eigenvectors as their axes. The signs of the eigenvalues decide whether the form is positive definite, and B transpose B and Sylvester's criterion give two more tests. Before the next lecture, read section eleven point two of the course book, try the problems on sheet thirteen about quadratic forms, and do the lecture check on this lecture's page at Open Semester dot com. Next time, the singular value decomposition carries these ideas to every matrix, even a rectangular one.
In this lecture
Materials
Try it
Quadratic forms in the plane
Set the entries of the symmetric matrix A with rows a, b and b, c, or pick an example. The form is qA(x) = ax12 + 2bx1x2 + cx22. The green curves are its level curves, solid where the value is positive and dashed where it is negative; when λ1 is positive, the brighter one is qA = λ1, which touches the unit circle at ±q1. The gold unit vector goes around the circle, and its value always stays between the two eigenvalues.
Check yourself
3 questions, from warm-up to stretch
Work each one out on paper, type your answer and press Check. Stuck? Open a hint; the worked solution is there when you need it.
- Question 1 of 3 Warm-up
Write the quadratic form as with a symmetric matrix , and say which kind of form it is.
Hint 1 of 2
For a symmetric matrix, (Proposition 11.2.3): the cross term is shared by the two off-diagonal entries.
Hint 2 of 2
So and are the coefficients of the squares, and . For the kind, try the vectors and : and .
Worked solution
- The coefficients of the squares are the diagonal entries: and .
- The cross term is , so and : .
- and , so the form takes both signs: it is indefinite. In line with Theorem 11.2.10, , so the eigenvalues have opposite signs.
- Question 2 of 3 Core
Let . Find its eigenvalues , the smallest value of on the unit circle , and the kind of form.
Hint 1 of 2
The characteristic polynomial of a matrix is . For the smallest value, use Theorem 11.2.12 with .
Hint 2 of 2
and , so solve . On the unit circle, , and both bounds are reached at the principal axes.
Worked solution
- and , so : and .
- By Theorem 11.2.12, on the unit circle. The value is reached at the unit eigenvector for : gives , so , and .
- Both eigenvalues are positive, so is positive definite (Theorem 11.2.10). Sylvester's criterion agrees: and .
- Question 3 of 3 Stretch
Let . For , find the leading principal minors and . Then find the number such that is positive definite exactly when .
Hint 1 of 2
is the determinant of the top left block. By Sylvester's criterion (Theorem 11.2.15), is positive definite exactly when , and are all positive.
Hint 2 of 2
Only depends on . Expand along the last row: .
Worked solution
- and , whatever is.
- Expanding along the last row : . At this is .
- By Sylvester's criterion, is positive definite exactly when , that is . At the determinant is , so has the eigenvalue and is not positive definite.
How did it go?