Practice / Linear algebra

Quadratic forms and positive definite matrices

Ten problems on quadratic forms and positive definite matrices: writing a form as xᵀAx with a symmetric matrix, classifying definite, semidefinite and indefinite matrices by their eigenvalues, the leading principal minors of a 3×3 matrix, completing the square as LDLᵀ, a Cholesky factor by hand, the range of a parameter that keeps a matrix positive definite, the largest and smallest values on the unit circle, the axes of an ellipse, why AᵀA is positive semidefinite and when it is definite, and the Hessian of a ridge regression loss, with worked solutions and the mistakes of the unhalved cross term, a positive diagonal taken as proof, leading minors for a semidefinite test, the long axis along the largest eigenvalue and the extremes read off the diagonal.

Before you start

A quadratic form is a sum of squares and cross products, such as 3x2+4xy+2y23x^2 + 4xy + 2y^2, and every one of them can be written as x⊤Axx^\top Ax with a symmetric matrix AA. The question that matters is its sign: a form that is positive for every nonzero xx is positive definite, and that single property is what makes a critical point a minimum, a loss convex with a unique minimizer, a covariance matrix valid and a Cholesky factor exist. These ten problems build the matrix of a form, test definiteness three ways (eigenvalues, leading principal minors and completing the square), factor a matrix by Cholesky, find the extremes of a form on the unit circle and the axes of an ellipse, and end with why ridge regression always has exactly one solution.

  • A quadratic form is q(x)=x⊤Ax=∑i,jAijxixjq(x) = x^\top Ax = \sum_{i,j} A_{ij}x_ix_j with AA symmetric. The coefficient of xi2x_i^2 is AiiA_{ii}, and the coefficient of xixjx_ix_j for i≠ji \ne j is 2Aij2A_{ij}, so the off-diagonal entries are half the cross coefficients.
  • AA is positive definite (PD) if x⊤Ax>0x^\top Ax > 0 for every x≠0x \ne 0, positive semidefinite (PSD) if x⊤Ax≥0x^\top Ax \ge 0 for every xx, negative (semi)definite if −A-A is, and indefinite if x⊤Axx^\top Ax takes both signs.
  • Eigenvalue test. A symmetric AA is QΛQ⊤Q\Lambda Q^\top with QQ orthogonal, so with y=Q⊤xy = Q^\top x, x⊤Ax=∑iλiyi2x^\top Ax = \sum_i\lambda_iy_i^2. AA is PD exactly when every λi>0\lambda_i > 0, PSD when every λi≥0\lambda_i \ge 0, and indefinite when there are eigenvalues of both signs.
  • Sylvester's criterion. AA is PD exactly when its leading principal minors (the determinants of the top-left 1×11\times1, 2×22\times2, …, n×nn\times n blocks) are all positive. For semidefiniteness the leading minors are not enough: every principal minor must be ≥0\ge 0.
  • Cholesky. AA is PD exactly when A=LL⊤A = LL^\top with LL lower-triangular and its diagonal positive. Equivalently A=LDL⊤A = LDL^\top with LL unit lower-triangular and the pivots of elimination on the diagonal of DD, all positive.
  • Rayleigh quotient. For symmetric AA, the largest and smallest values of x⊤Axx^\top Ax over unit vectors xx are λmax⁡\lambda_{\max} and λmin⁡\lambda_{\min}, reached at their eigenvectors. For PD AA, the set x⊤Ax=cx^\top Ax = c is an ellipse (ellipsoid) with axes along the eigenvectors and semi-axis lengths c/λi\sqrt{c/\lambda_i}.
  • For any matrix MM, v⊤M⊤Mv=∥Mv∥2v^\top M^\top Mv = \|Mv\|^2.

Builds on: Eigenvalues and eigenvectors by hand, Gaussian elimination, inverses and determinants by hand

Problems

  1. ·

    Write q(x,y)=3x2+4xy+2y2q(x, y) = 3x^2 + 4xy + 2y^2 as x⊤Axx^\top Ax with AA symmetric, and check it at (1,−1)(1, -1). Then write the matrix of x2+2y2+3z2+2xy−4yzx^2 + 2y^2 + 3z^2 + 2xy - 4yz.

  2. ·

    Classify each matrix as positive definite, positive semidefinite or indefinite from its eigenvalues: A=(2112)A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}, B=(1221)B = \begin{pmatrix} 1 & 2 \\ 2 & 1 \end{pmatrix}, C=(1224)C = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}.

  3. ··

    Use the leading principal minors to show that A=(2−10−12−10−12)A = \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix} is positive definite, and confirm with its eigenvalues.

  4. ··

    Complete the square in q(x,y)=3x2+4xy+2y2q(x, y) = 3x^2 + 4xy + 2y^2, and write the result as A=LDL⊤A = LDL^\top.

  5. ··

    Find the Cholesky factor LL of A=(42−22102−226)A = \begin{pmatrix} 4 & 2 & -2 \\ 2 & 10 & 2 \\ -2 & 2 & 6 \end{pmatrix}, and use it to get det⁡A\det A.

  6. ··

    For which real kk is A=(21012k0k2)A = \begin{pmatrix} 2 & 1 & 0 \\ 1 & 2 & k \\ 0 & k & 2 \end{pmatrix} positive definite?

  7. ··

    Find the largest and smallest values of q(x,y)=5x2+4xy+2y2q(x, y) = 5x^2 + 4xy + 2y^2 on the unit circle x2+y2=1x^2 + y^2 = 1, and where they occur.

  8. ··

    Find the axes, the semi-axis lengths and the area of the ellipse 5x2−4xy+5y2=215x^2 - 4xy + 5y^2 = 21.

  9. ···

    Show that M⊤MM^\top M is positive semidefinite for any matrix MM, and positive definite exactly when the columns of MM are independent. Test M1=(111213)M_1 = \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix} and M2=(121212)M_2 = \begin{pmatrix} 1 & 2 \\ 1 & 2 \\ 1 & 2 \end{pmatrix}.

  10. ···

    Ridge regression minimizes L(w)=∥Xw−y∥2+λ∥w∥2L(w) = \|Xw - y\|^2 + \lambda\|w\|^2. Find the gradient and Hessian of LL. With X=M2X = M_2 from Problem 9, y=(1,2,3)y = (1, 2, 3) and λ=12\lambda = \tfrac12, show that the Hessian is positive definite and find the unique minimizer.

Worked solutions

Problem 1

Write q(x,y)=3x2+4xy+2y2q(x, y) = 3x^2 + 4xy + 2y^2 as x⊤Axx^\top Ax with AA symmetric, and check it at (1,−1)(1, -1). Then write the matrix of x2+2y2+3z2+2xy−4yzx^2 + 2y^2 + 3z^2 + 2xy - 4yz.

  1. A11=3A_{11} = 3 and A22=2A_{22} = 2The squares go on the diagonal.
  2. 2A12=42A_{12} = 4, so A12=A21=2A_{12} = A_{21} = 2The cross term 4xy4xy is A12xy+A21yxA_{12}xy + A_{21}yx, split evenly between the two off-diagonal entries.
  3. A=(3222)A = \begin{pmatrix} 3 & 2 \\ 2 & 2 \end{pmatrix}Symmetric, as a form's matrix should be.
  4. At (1,−1)(1, -1): q=3−4+2=1q = 3 - 4 + 2 = 1, and x⊤Ax=(1,−1)(10)=1x^\top Ax = (1, -1)\begin{pmatrix} 1 \\ 0 \end{pmatrix} = 1Ax=(3−2,2−2)=(1,0)Ax = (3 - 2, 2 - 2) = (1, 0). Using 44 off the diagonal instead gives −3-3 (Mistake 1).
  5. A=(3222)A = \begin{pmatrix} 3 & 2 \\ 2 & 2 \end{pmatrix}; (11012−20−23)\begin{pmatrix} 1 & 1 & 0 \\ 1 & 2 & -2 \\ 0 & -2 & 3 \end{pmatrix}In the second form, 2xy2xy gives A12=1A_{12} = 1, −4yz-4yz gives A23=−2A_{23} = -2, and there is no xzxz term, so A13=0A_{13} = 0.

Problem 2

Classify each matrix as positive definite, positive semidefinite or indefinite from its eigenvalues: A=(2112)A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}, B=(1221)B = \begin{pmatrix} 1 & 2 \\ 2 & 1 \end{pmatrix}, C=(1224)C = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}.

  1. AA: λ2−4λ+3=0\lambda^2 - 4\lambda + 3 = 0, so λ=1,3\lambda = 1, 3Trace 44, determinant 33.
  2. BB: λ2−2λ−3=0\lambda^2 - 2\lambda - 3 = 0, so λ=3,−1\lambda = 3, -1Trace 22, determinant −3-3. A negative determinant of a 2×22\times2 always means one eigenvalue of each sign.
  3. CC: λ2−5λ=0\lambda^2 - 5\lambda = 0, so λ=0,5\lambda = 0, 5Determinant 00: the rows are proportional.
  4. qB(1,−1)=1−4+1=−2q_B(1, -1) = 1 - 4 + 1 = -2 and qC(2,−1)=4−8+4=0q_C(2, -1) = 4 - 8 + 4 = 0A witness for each: (1,−1)(1, -1) is BB's eigenvector for −1-1, and (2,−1)(2, -1) spans CC's null space.
  5. AA is positive definite, BB is indefinite, CC is positive semidefinite (not definite)BB has positive diagonal entries and is still not PD (Mistake 2).

Problem 3

Use the leading principal minors to show that A=(2−10−12−10−12)A = \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix} is positive definite, and confirm with its eigenvalues.

  1. Δ1=2\Delta_1 = 2The top-left entry.
  2. Δ2=2⋅2−(−1)(−1)=3\Delta_2 = 2\cdot2 - (-1)(-1) = 3The top-left 2×22\times2 block.
  3. Δ3=2(4−1)−(−1)(−2−0)+0=6−2=4\Delta_3 = 2(4 - 1) - (-1)(-2 - 0) + 0 = 6 - 2 = 4Expand along the first row.
  4. All three are positive, so AA is PD by Sylvester's criterionThis is the second-difference matrix behind a discretized −u′′-u''.
  5. Δ1,Δ2,Δ3=2,3,4\Delta_1, \Delta_2, \Delta_3 = 2, 3, 4; the eigenvalues are 2−2≈0.5862 - \sqrt2 \approx 0.586, 22 and 2+2≈3.4142 + \sqrt2 \approx 3.414, all positiveTheir product is 4=det⁡A4 = \det A and their sum is 6=tr⁡A6 = \operatorname{tr}A.

Problem 4

Complete the square in q(x,y)=3x2+4xy+2y2q(x, y) = 3x^2 + 4xy + 2y^2, and write the result as A=LDL⊤A = LDL^\top.

  1. 3x2+4xy=3(x2+43xy)=3(x+23y)2−43y23x^2 + 4xy = 3\big(x^2 + \tfrac43xy\big) = 3\big(x + \tfrac23y\big)^2 - \tfrac43y^2Factor out the x2x^2 coefficient, then half of 43\tfrac43 is 23\tfrac23, and 3⋅49=433\cdot\tfrac49 = \tfrac43.
  2. q=3(x+23y)2+23y2q = 3\big(x + \tfrac23y\big)^2 + \tfrac23y^22−43=232 - \tfrac43 = \tfrac23.
  3. Both coefficients are positive, so q>0q > 0 unless y=0y = 0 and x+23y=0x + \tfrac23y = 0, that is unless x=y=0x = y = 0A sum of positive multiples of squares of independent combinations.
  4. L=(10231)L = \begin{pmatrix} 1 & 0 \\ \tfrac23 & 1 \end{pmatrix}, D=diag⁡(3,23)D = \operatorname{diag}\big(3, \tfrac23\big)The rows of L⊤L^\top are the combinations being squared; the entries of DD are the pivots of elimination on AA.
  5. q=3(x+23y)2+23y2q = 3\big(x + \tfrac23y\big)^2 + \tfrac23y^2, A=LDL⊤A = LDL^\top with L=(10231)L = \begin{pmatrix} 1 & 0 \\ \tfrac23 & 1 \end{pmatrix}, D=diag⁡(3,23)D = \operatorname{diag}(3, \tfrac23): positive definiteCheck: det⁡A=3⋅23=2=6−4\det A = 3\cdot\tfrac23 = 2 = 6 - 4.

Problem 5

Find the Cholesky factor LL of A=(42−22102−226)A = \begin{pmatrix} 4 & 2 & -2 \\ 2 & 10 & 2 \\ -2 & 2 & 6 \end{pmatrix}, and use it to get det⁡A\det A.

  1. l11=4=2l_{11} = \sqrt4 = 2, l21=22=1l_{21} = \tfrac22 = 1, l31=−22=−1l_{31} = \tfrac{-2}{2} = -1The first column of AA is l11l_{11} times the first column of LL.
  2. l22=10−l212=9=3l_{22} = \sqrt{10 - l_{21}^2} = \sqrt9 = 3Subtract what the first column already supplies, then take the root.
  3. l32=2−l31l21l22=2−(−1)(1)3=1l_{32} = \dfrac{2 - l_{31}l_{21}}{l_{22}} = \dfrac{2 - (-1)(1)}{3} = 1From A32=l31l21+l32l22A_{32} = l_{31}l_{21} + l_{32}l_{22}.
  4. l33=6−l312−l322=6−1−1=2l_{33} = \sqrt{6 - l_{31}^2 - l_{32}^2} = \sqrt{6 - 1 - 1} = 2Every square root was of a positive number, which is the proof that AA is PD.
  5. L=(200130−112)L = \begin{pmatrix} 2 & 0 & 0 \\ 1 & 3 & 0 \\ -1 & 1 & 2 \end{pmatrix}, det⁡A=(2⋅3⋅2)2=144\det A = (2\cdot3\cdot2)^2 = 144det⁡A=det⁡L det⁡L⊤\det A = \det L\,\det L^\top. Sampling N(0,A)\mathcal{N}(0, A) is LεL\varepsilon with ε∼N(0,I)\varepsilon \sim \mathcal{N}(0, I).

Problem 6

For which real kk is A=(21012k0k2)A = \begin{pmatrix} 2 & 1 & 0 \\ 1 & 2 & k \\ 0 & k & 2 \end{pmatrix} positive definite?

  1. Δ1=2>0\Delta_1 = 2 > 0 and Δ2=4−1=3>0\Delta_2 = 4 - 1 = 3 > 0These do not involve kk.
  2. Δ3=2(4−k2)−1(2−0)+0=6−2k2\Delta_3 = 2(4 - k^2) - 1(2 - 0) + 0 = 6 - 2k^2Expand along the first row.
  3. 6−2k2>0  ⟺  k2<36 - 2k^2 > 0 \iff k^2 < 3Sylvester's criterion needs all three minors positive.
  4. At k=3k = \sqrt3 the determinant is 00 and the smallest eigenvalue is 00: PSD but not PDThe boundary of the range.
  5. −3<k<3-\sqrt3 < k < \sqrt3Check k=2k = 2: (1,−2,2)(1, -2, 2) gives x⊤Ax=2−4+8+8−16=−2<0x^\top Ax = 2 - 4 + 8 + 8 - 16 = -2 < 0.

Problem 7

Find the largest and smallest values of q(x,y)=5x2+4xy+2y2q(x, y) = 5x^2 + 4xy + 2y^2 on the unit circle x2+y2=1x^2 + y^2 = 1, and where they occur.

  1. A=(5222)A = \begin{pmatrix} 5 & 2 \\ 2 & 2 \end{pmatrix}Half of 44 off the diagonal.
  2. λ2−7λ+6=0\lambda^2 - 7\lambda + 6 = 0, so λ=6,1\lambda = 6, 1Trace 77, determinant 10−4=610 - 4 = 6.
  3. λ=6\lambda = 6: (A−6I)v=0(A - 6I)v = 0 with rows (−1,2)(-1, 2), so v=15(2,1)v = \tfrac{1}{\sqrt5}(2, 1)Check: q=15(20+8+2)=6q = \tfrac15(20 + 8 + 2) = 6.
  4. λ=1\lambda = 1: rows (4,2)(4, 2), so v=15(1,−2)v = \tfrac{1}{\sqrt5}(1, -2)Check: q=15(5−8+8)=1q = \tfrac15(5 - 8 + 8) = 1.
  5. Maximum 66 at ±15(2,1)\pm\tfrac{1}{\sqrt5}(2, 1); minimum 11 at ±15(1,−2)\pm\tfrac{1}{\sqrt5}(1, -2)Every other unit vector gives a value in between, for example q(1,0)=5q(1, 0) = 5. The smallest diagonal entry, 22, is not the minimum (Mistake 5).

Problem 8

Find the axes, the semi-axis lengths and the area of the ellipse 5x2−4xy+5y2=215x^2 - 4xy + 5y^2 = 21.

  1. A=(5−2−25)A = \begin{pmatrix} 5 & -2 \\ -2 & 5 \end{pmatrix} has λ=3\lambda = 3 for (1,1)/2(1, 1)/\sqrt2 and λ=7\lambda = 7 for (1,−1)/2(1, -1)/\sqrt2A(1,1)=(3,3)A(1, 1) = (3, 3) and A(1,−1)=(7,−7)A(1, -1) = (7, -7).
  2. In the rotated coordinates y=Q⊤xy = Q^\top x the ellipse is 3y12+7y22=213y_1^2 + 7y_2^2 = 21The cross term disappears along the eigenvectors.
  3. Semi-axes 21/3=7≈2.646\sqrt{21/3} = \sqrt7 \approx 2.646 along (1,1)(1, 1) and 21/7=3≈1.732\sqrt{21/7} = \sqrt3 \approx 1.732 along (1,−1)(1, -1)Divide by the eigenvalue: the smaller eigenvalue gives the longer axis.
  4. Check the end of the long axis, 7⋅12(1,1)\sqrt7\cdot\tfrac{1}{\sqrt2}(1, 1), where x=y=3.5x = y = \sqrt{3.5}: (5−4+5)⋅3.5=21(5 - 4 + 5)\cdot3.5 = 21It lies on the ellipse.
  5. Major semi-axis 7\sqrt7 along (1,1)(1, 1), minor semi-axis 3\sqrt3 along (1,−1)(1, -1); area π73=π21≈14.40\pi\sqrt7\sqrt3 = \pi\sqrt{21} \approx 14.40Putting the long axis along the eigenvector of 77 gives a point where the form is 4949 (Mistake 4).

Problem 9

Show that M⊤MM^\top M is positive semidefinite for any matrix MM, and positive definite exactly when the columns of MM are independent. Test M1=(111213)M_1 = \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{pmatrix} and M2=(121212)M_2 = \begin{pmatrix} 1 & 2 \\ 1 & 2 \\ 1 & 2 \end{pmatrix}.

  1. v⊤M⊤Mv=(Mv)⊤(Mv)=∥Mv∥2≥0v^\top M^\top Mv = (Mv)^\top(Mv) = \|Mv\|^2 \ge 0A squared length is never negative, so M⊤MM^\top M is PSD.
  2. ∥Mv∥2=0  ⟺  Mv=0\|Mv\|^2 = 0 \iff Mv = 0, and MvMv is the combination of the columns with coefficients vvSo v⊤M⊤Mv>0v^\top M^\top Mv > 0 for every v≠0v \ne 0 exactly when no nonzero combination of the columns is 00.
  3. M1⊤M1=(36614)M_1^\top M_1 = \begin{pmatrix} 3 & 6 \\ 6 & 14 \end{pmatrix}, with minors 33 and 42−36=642 - 36 = 6Both positive: PD, as the columns (1,1,1)(1, 1, 1) and (1,2,3)(1, 2, 3) are independent.
  4. M2⊤M2=(36612)M_2^\top M_2 = \begin{pmatrix} 3 & 6 \\ 6 & 12 \end{pmatrix}, with determinant 00 and eigenvalues 00 and 1515The second column is twice the first, and v=(2,−1)v = (2, -1) gives M2v=0M_2v = 0.
  5. M⊤MM^\top M is always PSD; M1⊤M1M_1^\top M_1 is PD, M2⊤M2M_2^\top M_2 is only PSD, with v⊤M2⊤M2v=0v^\top M_2^\top M_2v = 0 at v=(2,−1)v = (2, -1)This is why the normal equations have a unique solution exactly when the features are not collinear.

Problem 10

Ridge regression minimizes L(w)=∥Xw−y∥2+λ∥w∥2L(w) = \|Xw - y\|^2 + \lambda\|w\|^2. Find the gradient and Hessian of LL. With X=M2X = M_2 from Problem 9, y=(1,2,3)y = (1, 2, 3) and λ=12\lambda = \tfrac12, show that the Hessian is positive definite and find the unique minimizer.

  1. ∇L=2X⊤(Xw−y)+2λw\nabla L = 2X^\top(Xw - y) + 2\lambda w and ∇2L=2(X⊤X+λI)\nabla^2L = 2(X^\top X + \lambda I)L=w⊤(X⊤X+λI)w−2y⊤Xw+y⊤yL = w^\top(X^\top X + \lambda I)w - 2y^\top Xw + y^\top y, a quadratic form plus a linear term.
  2. v⊤(X⊤X+λI)v=∥Xv∥2+λ∥v∥2>0v^\top(X^\top X + \lambda I)v = \|Xv\|^2 + \lambda\|v\|^2 > 0 for v≠0v \ne 0Whatever XX is, when λ>0\lambda > 0. So LL is strictly convex with one minimizer.
  3. X⊤X+12I=(3.56612.5)X^\top X + \tfrac12I = \begin{pmatrix} 3.5 & 6 \\ 6 & 12.5 \end{pmatrix}, with eigenvalues 0.50.5 and 15.515.5, and X⊤y=(6,12)X^\top y = (6, 12)The eigenvalues of X⊤XX^\top X, 00 and 1515, each move up by λ\lambda.
  4. det⁡=43.75−36=7.75\det = 43.75 - 36 = 7.75, so w1=12.5⋅6−6⋅127.75=1231w_1 = \dfrac{12.5\cdot6 - 6\cdot12}{7.75} = \dfrac{12}{31} and w2=3.5⋅12−6⋅67.75=2431w_2 = \dfrac{3.5\cdot12 - 6\cdot6}{7.75} = \dfrac{24}{31}Cramer's rule on (X⊤X+λI)w=X⊤y(X^\top X + \lambda I)w = X^\top y.
  5. ∇2L=2(X⊤X+λI)\nabla^2L = 2(X^\top X + \lambda I), PD with eigenvalues 11 and 3131; w∗=(1231,2431)w^* = \big(\tfrac{12}{31}, \tfrac{24}{31}\big)Without λ\lambda the Hessian is singular and every ww with w1+2w2=2w_1 + 2w_2 = 2 is a minimizer. Ridge picks one along (1,2)(1, 2), with w1+2w2=6031≈1.935w_1 + 2w_2 = \tfrac{60}{31} \approx 1.935, shrunk slightly below 22.

Where this goes wrong

1. The cross coefficient left unhalved

The coefficient of xyxy is copied straight into the matrix.

  1. q=3x2+4xy+2y2q = 3x^2 + 4xy + 2y^2, with 33 and 22 on the diagonalRight so far: Problem 1.
  2. “The xyxy coefficient goes off the diagonal: A=(3442)A = \begin{pmatrix} 3 & 4 \\ 4 & 2 \end{pmatrix}.”Both off-diagonal entries multiply xyxy, so together they give 8xy8xy.
  3. The form is indefinite, since det⁡A=6−16=−10<0\det A = 6 - 16 = -10 < 0That matrix is the form 3x2+8xy+2y23x^2 + 8xy + 2y^2. At (1,−1)(1, -1) it gives −3-3, while q(1,−1)=1q(1, -1) = 1. With A12=2A_{12} = 2 the determinant is 2>02 > 0 and qq is positive definite (Problem 4).

2. A positive diagonal taken as proof

A diagonal matrix with positive entries is positive definite, and the shortcut gets applied to every matrix.

  1. B=(1221)B = \begin{pmatrix} 1 & 2 \\ 2 & 1 \end{pmatrix} has B11=B22=1>0B_{11} = B_{22} = 1 > 0Right so far: Problem 2. A positive diagonal is necessary, since ei⊤Bei=Biie_i^\top Be_i = B_{ii}.
  2. “Every diagonal entry is positive, so every x⊤Bxx^\top Bx is positive.”The cross term 4xy4xy can outweigh the squares.
  3. BB is positive definiteqB(1,−1)=1−4+1=−2q_B(1, -1) = 1 - 4 + 1 = -2, and the eigenvalues are 33 and −1-1. A positive diagonal is not sufficient; a 2×22\times2 also needs det⁡>0\det > 0, and here det⁡B=−3\det B = -3.

3. Leading minors used to test semidefiniteness

Sylvester's criterion is remembered as “check the leading minors”, with >0> 0 relaxed to ≥0\ge 0.

  1. A=(000−1)A = \begin{pmatrix} 0 & 0 \\ 0 & -1 \end{pmatrix} has Δ1=0\Delta_1 = 0 and Δ2=0\Delta_2 = 0Right so far: both leading minors are ≥0\ge 0.
  2. “All leading minors are non-negative, so AA is PSD.”For semidefiniteness every principal minor must be checked, including the bottom-right entry −1-1.
  3. AA is positive semidefinite(0,1)⊤A(0,1)=−1<0(0, 1)^\top A(0, 1) = -1 < 0: AA is negative semidefinite. The 1×11\times1 principal minor A22=−1A_{22} = -1 is the one the leading minors skip.

4. The long axis along the largest eigenvalue

The biggest eigenvalue is thought of as the biggest direction, as it is for a covariance matrix.

  1. 5x2−4xy+5y2=215x^2 - 4xy + 5y^2 = 21 has eigenvalues 33 along (1,1)(1, 1) and 77 along (1,−1)(1, -1)Right so far: Problem 8.
  2. “The major semi-axis 7\sqrt7 points along the eigenvector of 77.”Along an eigenvector the form is λr2\lambda r^2, so a large λ\lambda reaches 2121 at a small rr.
  3. The ellipse reaches 7⋅12(1,−1)\sqrt7\cdot\tfrac{1}{\sqrt2}(1, -1)There x=−y=3.5x = -y = \sqrt{3.5} and the form is (5+4+5)⋅3.5=49(5 + 4 + 5)\cdot3.5 = 49, not 2121. The semi-axis along an eigenvector is c/λ\sqrt{c/\lambda}: 21/7=3\sqrt{21/7} = \sqrt3 along (1,−1)(1, -1) and 7\sqrt7 along (1,1)(1, 1). For a Gaussian the ellipse is x⊤Σ−1x=cx^\top\Sigma^{-1}x = c, whose eigenvalues are 1/λ1/\lambda, which is why the covariance's largest eigenvalue does give the long axis.

5. The extremes read off the diagonal

On the unit circle the values at (1,0)(1, 0) and (0,1)(0, 1) are the diagonal entries, and these are taken as the extremes.

  1. q=5x2+4xy+2y2q = 5x^2 + 4xy + 2y^2 has q(1,0)=5q(1, 0) = 5 and q(0,1)=2q(0, 1) = 2Right so far: Problem 7.
  2. “The coordinate axes give the largest and smallest values.”Only when the cross term is 00, so that the axes are the eigenvectors.
  3. On the unit circle, 2≤q≤52 \le q \le 5The eigenvalues are 66 and 11, at 15(2,1)\tfrac{1}{\sqrt5}(2, 1) and 15(1,−2)\tfrac{1}{\sqrt5}(1, -2). The diagonal entries always lie between λmin⁡\lambda_{\min} and λmax⁡\lambda_{\max}, so they never show the extremes unless the matrix is diagonal.

Print this set: quadratic-forms-and-positive-definite-matrices.pdf (problems, answers, and worked solutions on separate pages).

Read the guide: Quadratic forms and positive definite matrices: halve the cross term, test with eigenvalues or pivots, and read the axes off the eigenvectors