Ten problems on positive-definite matrices: classifying 2×2 matrices by eigenvalues and by a test vector, the eigenvalue characterisation and what it says about determinants and inverses, Sylvester's criterion by completing the square, Gram matrices and ridge, a 3×3 Cholesky factorisation by hand with a solve, the gradient, Hessian and minimiser of a quadratic, Hessian PSD if and only if convex, the symmetric square root and the ellipsoid of a quadratic form, the step-size condition and convergence rate of gradient descent on a quadratic, and why a quadratic form sees only the symmetric part, with worked solutions and the mistakes that read definiteness off a determinant, trust the eigenvalues of a non-symmetric matrix, sample with the transposed Cholesky factor, assume the normal equations have a unique solution, or pick the step size from the smallest eigenvalue.
Before you start
A positive-definite matrix is one whose quadratic form is a bowl: x⊤Ax>0 in every direction. Every covariance matrix, every Gram matrix X⊤X with independent columns, every Hessian at a strict minimum and every kernel matrix is one, and the properties that make them useful, a Cholesky factor, an inverse that is also positive definite, a square root, a condition number that sets the step size of gradient descent, all come from that one inequality. These ten problems classify small matrices by hand, prove the eigenvalue test and Sylvester's criterion, factor a 3×3 matrix by Cholesky and solve a system with it, minimise a quadratic by completing the square, show that a convex function is exactly one with a PSD Hessian, compute a symmetric square root, derive the step size and rate of gradient descent on a quadratic, and end with the fact that a quadratic form never sees the antisymmetric part of its matrix. The five mistakes at the end are the ones that survive a glance: a positive determinant read as positive definite, positive eigenvalues of a non-symmetric matrix, the Cholesky factor used transposed, normal equations assumed solvable, and a step size chosen from the wrong eigenvalue.
A is a real symmetric n×n matrix unless a problem says otherwise, I is the identity, and vectors are columns. A is positive definite (PD, written )A≻0) if x⊤Ax>0 for every ,x=0, positive semidefinite (PSD, )A⪰0) if x⊤Ax≥0 for every ,x, and indefinite if x⊤Ax takes both signs.
A symmetric A has an orthonormal eigenbasis: A=QΛQ⊤ with ,Q⊤Q=I,,Λ=diag(λ1,…,λn), and Aqi=λiqi for the columns qi of Q (the eigenvalues page). Equivalently .A=∑iλiqiqi⊤.λmax and λmin are the largest and smallest eigenvalues and κ=λmax/λmin is the condition number of a PD matrix.
A Cholesky factorisation of a PD matrix is A=LL⊤ with L lower-triangular and .Ljj>0. Computed column by column: Ljj=Ajj−∑k<jLjk2 and, for ,i>j,.Lij=(Aij−∑k<jLikLjk)/Ljj.
For X∈RN×d the Gram matrix is ;X⊤X;.∥v∥2=v⊤v. The singular values of X are σi (the least-squares page).
Gradients are columns: for scalar ,f(x),∇f∈Rn and the Hessian ∇2f is the n×n matrix of second partials, so for symmetric ,A,∇(x⊤Ax)=2Ax and ∇(b⊤x)=b (the matrix-calculus page). A twice-differentiable f is convex when f(λx+(1−λ)y)≤λf(x)+(1−λ)f(y) for all x,y and λ∈[0,1] (the Jensen page).
Gradient descent with step η is ;xk+1=xk−η∇f(xk);ek=xk−x∗ is the error after k steps.
Classify ,A=[2112],B=[1221] and C=[1224] as positive definite, positive semidefinite or indefinite using their eigenvalues. For ,B, exhibit a vector v with ;v⊤Bv<0; for ,C, a nonzero vector with .v⊤Cv=0.
··
For symmetric ,A=∑iλiqiqi⊤, show that x⊤Ax=∑iλi(qi⊤x)2 and hence that A is PD if and only if every .λi>0. Deduce that a PD matrix has detA>0 and ,trA>0, is invertible, and that A−1 is PD.
··
By completing the square in ,x⊤Ax=ax2+2bxy+cy2, show that the symmetric A=[abbc] is PD if and only if a>0 and .ac−b2>0. For which t is [2tt2] positive definite?
··
For ,X∈RN×d, show that X⊤X is PSD, that it is PD if and only if the columns of X are linearly independent, and that X⊤X+λI is PD for every λ>0 with eigenvalues ,σi2+λ, where the σi are the singular values of X (zero for ).i>rankX).
··
Compute the Cholesky factor L of ,A=422253236, verify ,LL⊤=A, and use it to solve Ax=b for b=(8,10,11)⊤ by two triangular solves. What is ?detA?
··
Let f(x)=21x⊤Ax−b⊤x+c with A symmetric and PD. Compute ∇f and ,∇2f, show that f(x)=21(x−x∗)⊤A(x−x∗)+f(x∗) with x∗=A−1b and ,f(x∗)=c−21b⊤A−1b, and conclude that x∗ is the unique minimiser. Evaluate for ,A=[2112],,b=(1,2)⊤,.c=0. What happens if A has a negative eigenvalue?
···
Let f be twice differentiable on Rn and, for fixed x and ,v, let .g(t)=f(x+tv). Show that ,g′′(t)=v⊤∇2f(x+tv)v, and use it to prove that f is convex if and only if ∇2f(x)⪰0 for every .x. Conclude that 21x⊤Ax is convex exactly when .A⪰0.
··
For PD A=QΛQ⊤ define .A1/2=QΛ1/2Q⊤. Show that A1/2 is symmetric PD with ,(A1/2)2=A, and that .A−1/2AA−1/2=I. Compute A1/2 for ,A=[2112], and describe the ellipse .{x:x⊤Ax=1}.
···
For f(x)=21x⊤Ax−b⊤x with ,A≻0, show that gradient descent satisfies ,ek+1=(I−ηA)ek, that it converges from every start if and only if ,0<η<2/λmax, and that the error component along qi shrinks by the factor ∣1−ηλi∣ per step. Find the η that minimises the worst factor and the resulting rate in terms of .κ. Evaluate for .A=diag(1,10).
··
For any square matrix ,M, not necessarily symmetric, show that x⊤Mx=x⊤Sx with .S=21(M+M⊤). Show that M=[1041] has both eigenvalues equal to 1 and yet v⊤Mv<0 for some .v. Why does the eigenvalue test of Problem 2 not apply?
Answers
A≻0 (eigenvalues );3,1);B indefinite (eigenvalues ,3,−1,v=(1,−1)⊤ gives );−2);C⪰0 but not PD (eigenvalues ,5,0,v=(2,−1)⊤ gives )0)
;x⊤Ax=∑iλi(qi⊤x)2;A≻0⟺ all ;λi>0; then ,detA>0,,trA>0,A is invertible and A−1≻0
[abbc]≻0⟺a>0 and ;ac−b2>0;[2tt2]≻0⟺∣t∣<2
X⊤X⪰0 always; ;X⊤X≻0⟺rankX=d;X⊤X+λI≻0 for ,λ>0, with eigenvalues σi2+λ
,L=211021002,;LL⊤=A;;x=(1,1,1)⊤;detA=64
,∇f=Ax−b,;∇2f=A;f(x)=21(x−x∗)⊤A(x−x∗)+f(x∗) with x∗=A−1b and ,f(x∗)=c−21b⊤A−1b, the unique minimiser; for the example ,x∗=(0,1)⊤,;f(x∗)=−1; with a negative eigenvalue f is unbounded below
;g′′(t)=v⊤∇2f(x+tv)v;f convex ⟺∇2f(x)⪰0 for all ;x;21x⊤Ax convex ⟺A⪰0
A1/2=QΛ1/2Q⊤≻0 with (A1/2)2=A and ;A−1/2AA−1/2=I; for the example ;A1/2=21[3+13−13−13+1];x⊤Ax=1 is an ellipse with semi-axes 1/3 along (1,1)⊤/2 and 1 along (1,−1)⊤/2
;ek+1=(I−ηA)ek; convergence from every start ;⟺0<η<2/λmax; the qi component scales by ;∣1−ηλi∣;η∗=λmin+λmax2 with rate ;κ+1κ−1; for :diag(1,10):,η∗=2/11, rate 9/11
;x⊤Mx=x⊤21(M+M⊤)x;M=[1041] has eigenvalues 1,1 but ;(1,−1)M(1,−1)⊤=−2; the eigenvalue test needs a symmetric matrix
Worked solutions
Problem 1
Classify ,A=[2112],B=[1221] and C=[1224] as positive definite, positive semidefinite or indefinite using their eigenvalues. For ,B, exhibit a vector v with ;v⊤Bv<0; for ,C, a nonzero vector with .v⊤Cv=0.
:A:det(A−λI)=(2−λ)2−1=0 gives ,λ=3,1, both positive: PD.The eigenvalues page's Problem 1; Problem 2 below shows why positive eigenvalues mean PD.
:B:(1−λ)2−4=0 gives ,1−λ=±2,:λ=3,−1: indefinite.One eigenvalue of each sign.
:v=(1,−1)⊤:.v⊤Bv=1−2−2+1=−2<0.v is the eigenvector for ,λ=−1, since ;B(1,−1)⊤=(1−2,2−1)⊤=−(1,−1)⊤; its quadratic form is .λ∥v∥2=−2.
:C:(1−λ)(4−λ)−4=λ2−5λ=0 gives :λ=5,0: PSD but not PD.A zero eigenvalue means x⊤Cx=0 for a nonzero ,x, so the form is never negative but is not always positive.
:v=(2,−1)⊤:,Cv=(2−2,4−4)⊤=0, so .v⊤Cv=0.The null vector of ;C;C has rank one, .C=(1,2)⊤(1,2).
A≻0 (eigenvalues );3,1);B indefinite (eigenvalues ,3,−1,v=(1,−1)⊤ gives );−2);C⪰0 but not PD (eigenvalues ,5,0,v=(2,−1)⊤ gives )0)All three have positive diagonal entries and positive trace, and B even has all entries positive, so none of those tests decides anything; B's determinant is −3 and C's is ,0, which rule them out, but a positive determinant would not have ruled them in (Mistake 1). A is the covariance matrix of the Gaussian page's Problem 1, and C is what a covariance looks like when one coordinate is twice the other.
Problem 2
For symmetric ,A=∑iλiqiqi⊤, show that x⊤Ax=∑iλi(qi⊤x)2 and hence that A is PD if and only if every .λi>0. Deduce that a PD matrix has detA>0 and ,trA>0, is invertible, and that A−1 is PD.
.x⊤Ax=x⊤(∑iλiqiqi⊤)x=∑iλi(x⊤qi)(qi⊤x)=∑iλi(qi⊤x)2.Distribute x⊤ and x over the sum; x⊤qi=qi⊤x is a scalar.
If every λi>0 and ,x=0, then some ,qi⊤x=0, so .x⊤Ax>0.The qi are an orthonormal basis, so ;x=∑i(qi⊤x)qi; if every coefficient were zero, x would be zero. All terms are ≥0 and at least one is .>0.
If A is PD, then λi=qi⊤Aqi>0 for every .i.Take x=qi in the definition: .qi⊤Aqi=qi⊤(λiqi)=λi∥qi∥2=λi.
detA=∏iλi>0 and ;trA=∑iλi>0; no eigenvalue is zero, so A is invertible.The eigenvalues page's Problem 5, extended to n×n by det(QΛQ⊤)=detΛ and ;tr(QΛQ⊤)=tr(ΛQ⊤Q)=trΛ; a matrix is singular exactly when 0 is an eigenvalue.
,A−1=QΛ−1Q⊤=∑iλi1qiqi⊤, with every ,1/λi>0, so A−1 is PD by step 2.(QΛQ⊤)(QΛ−1Q⊤)=QΛΛ−1Q⊤=I because ;Q⊤Q=I; the inverse has the same eigenvectors and reciprocal eigenvalues.
;x⊤Ax=∑iλi(qi⊤x)2;A≻0⟺ all ;λi>0; then ,detA>0,,trA>0,A is invertible and A−1≻0In the eigenbasis the quadratic form is a weighted sum of squares, and definiteness is the sign pattern of the weights: all >0 is PD, all ≥0 is PSD, mixed is indefinite. The converses of step 4 fail: det>0 and tr>0 together do not give PD in three dimensions (),diag(4,−1,−1)), and in two dimensions they do only because two eigenvalues with positive product and positive sum are both positive, which is Problem 3's criterion. Step 5 is why the precision matrix Σ−1 of a Gaussian is PD whenever the covariance is.
Problem 3
By completing the square in ,x⊤Ax=ax2+2bxy+cy2, show that the symmetric A=[abbc] is PD if and only if a>0 and .ac−b2>0. For which t is [2tt2] positive definite?
For :a=0:.ax2+2bxy+cy2=a(x+aby)2+(c−ab2)y2=a(x+aby)2+aac−b2y2.Expand a(x+aby)2=ax2+2bxy+ab2y2 and subtract the extra .ab2y2.
If a>0 and :ac−b2>0: both coefficients are positive, so the form is ,≥0, and it is 0 only when y=0 and then .x+aby=x=0.A positive combination of two squares vanishes only when both squares vanish.
If A is PD: x=(1,0)⊤ gives ,a>0, and x=(−ab,1)⊤ gives ,aac−b2>0, so .ac−b2>0.Two test vectors, chosen to kill one square each in step 1; a>0 lets the inequality be multiplied through.
:[2tt2]:a=2>0 and ac−b2=4−t2>0 exactly when .∣t∣<2.Step 2 with ,a=c=2,.b=t.
[abbc]≻0⟺a>0 and ;ac−b2>0;[2tt2]≻0⟺∣t∣<2This is Sylvester's criterion: all leading principal minors positive, the 1×1 minor a and the 2×2 minor .detA. Completing the square is the 2×2 Cholesky factorisation in disguise, ,L=[ab/a0(ac−b2)/a], and the criterion fails exactly where a square root in Problem 5's algorithm would go negative. At t=±2 the matrix is PSD with the null vector ,(1,∓1)⊤, and for ∣t∣>2 it is indefinite despite its positive diagonal and positive trace. For a covariance [σ12ρσ1σ2ρσ1σ2σ22] the condition is .ρ2<1.
Problem 4
For ,X∈RN×d, show that X⊤X is PSD, that it is PD if and only if the columns of X are linearly independent, and that X⊤X+λI is PD for every λ>0 with eigenvalues ,σi2+λ, where the σi are the singular values of X (zero for ).i>rankX).
.v⊤X⊤Xv=(Xv)⊤(Xv)=∥Xv∥2≥0.Group the product as ;(Xv)⊤(Xv); a squared norm is nonnegative.
.v⊤X⊤Xv=0⟺Xv=0.A norm is zero only for the zero vector.
X⊤X≻0⟺Xv=0 for every v=0⟺ the columns of X are linearly independent.Xv=∑jvjxj with xj the columns, and Xv=0 for some v=0 is exactly a linear dependence among them. That needs ;N≥d; with N<d some nonzero v always has .Xv=0.
v⊤(X⊤X+λI)v=∥Xv∥2+λ∥v∥2>0 for .v=0.Step 1 plus ;λ∥v∥2>0; the second term is positive even when the first is zero.
With :X=UΣV⊤:,X⊤X=VΣ⊤ΣV⊤, so its eigenvalues are σi2 with eigenvectors the right singular vectors ,vi, and .(X⊤X+λI)vi=(σi2+λ)vi.U⊤U=I and Σ⊤Σ is diagonal with entries σi2 (the least-squares page); adding λI adds λ to every eigenvalue without moving the eigenvectors.
X⊤X⪰0 always; ;X⊤X≻0⟺rankX=d;X⊤X+λI≻0 for ,λ>0, with eigenvalues σi2+λEvery Gram matrix, covariance matrix (N−11X⊤HX on the variance page) and kernel matrix is PSD for the reason in step 1, and PD only when nothing is collinear. The normal equations X⊤Xw=X⊤y have a unique solution exactly in the PD case (Mistake 4); ridge regression's X⊤X+λI is always invertible, with condition number ,(σmax2+λ)/(σmin2+λ), which λ pulls towards ,1, and that is what makes ridge both solvable and well-conditioned. The bias–variance page prices the shrinkage this costs.
Problem 5
Compute the Cholesky factor L of ,A=422253236, verify ,LL⊤=A, and use it to solve Ax=b for b=(8,10,11)⊤ by two triangular solves. What is ?detA?
Column 1: ,L11=A11=2,,L21=A21/L11=1,.L31=A31/L11=1.The algorithm with no earlier columns to subtract.
Column 2: ,L22=A22−L212=5−1=2,.L32=(A32−L31L21)/L22=(3−1)/2=1.Subtract the contribution of column 1 before taking the root and dividing.
Column 3: .L33=A33−L312−L322=6−1−1=2.Both earlier columns contribute to the (3,3) entry.
L=211021002 and .LL⊤=42221+41+221+21+1+4=A.Entry (i,j) of LL⊤ is the dot product of rows i and j of .L.
Forward solve :Ly=b:,y1=8/2=4,,y2=(10−1⋅4)/2=3,.y3=(11−1⋅4−1⋅3)/2=2.Row by row from the top; each row has one new unknown.
Back solve :L⊤x=y:,x3=2/2=1,,x2=(3−1⋅1)/2=1,.x1=(4−1⋅1−1⋅1)/2=1.L⊤ is upper-triangular, so solve from the bottom; .Ax=LL⊤x=Ly=b.
.detA=detLdetL⊤=(detL)2=(2⋅2⋅2)2=64.The determinant of a triangular matrix is the product of its diagonal, and .detL⊤=detL.
,L=211021002,;LL⊤=A;;x=(1,1,1)⊤;detA=64Check: .A(1,1,1)⊤=(8,10,11)⊤. The three square roots were of ,4,4 and ,4, all positive, which is the proof that A is PD: Cholesky succeeds exactly when every pivot Ajj−∑k<jLjk2 is positive, and it is how software tests definiteness, at a third of the cost of an eigendecomposition. The Gaussian page uses L to sample, x=μ+Lε (and not ,L⊤ε, Mistake 3), and logdetΣ=2∑jlogLjj is how its normaliser is computed without forming the determinant.
Problem 6
Let f(x)=21x⊤Ax−b⊤x+c with A symmetric and PD. Compute ∇f and ,∇2f, show that f(x)=21(x−x∗)⊤A(x−x∗)+f(x∗) with x∗=A−1b and ,f(x∗)=c−21b⊤A−1b, and conclude that x∗ is the unique minimiser. Evaluate for ,A=[2112],,b=(1,2)⊤,.c=0. What happens if A has a negative eigenvalue?
∇f=Ax−b and .∇2f=A.∇(21x⊤Ax)=Ax for symmetric A and ∇(b⊤x)=b (the matrix-calculus page); the Hessian is the Jacobian of .Ax−b.
.21(x−x∗)⊤A(x−x∗)=21x⊤Ax−x⊤Ax∗+21x∗⊤Ax∗.Expand; the two cross terms are equal because A is symmetric.
With :Ax∗=b:x⊤Ax∗=b⊤x and ,x∗⊤Ax∗=b⊤A−1b, so .21(x−x∗)⊤A(x−x∗)=21x⊤Ax−b⊤x+21b⊤A−1b=f(x)−c+21b⊤A−1b.Substitute Ax∗=b and ;x∗=A−1b; compare with the definition of .f.
f(x)=21(x−x∗)⊤A(x−x∗)+f(x∗) with ;f(x∗)=c−21b⊤A−1b; the first term is >0 for x=x∗ and 0 at .x∗.Rearrange step 3; A≻0 applied to the vector .x−x∗.
,A−1=31[2−1−12],,x∗=31(2−2,−1+4)⊤=(0,1)⊤,.f(x∗)=−21b⊤x∗=−21(0+2)=−1.The 2×2 inverse with ;detA=3;.b⊤A−1b=b⊤x∗. Check: f(0,1)=21⋅2−2=−1 and .∇f(0,1)=(1,2)⊤−(1,2)⊤=0.
If Av=λv with :λ<0:f(tv)=21λt2∥v∥2−tb⊤v+c→−∞ as .t→∞.Along an eigenvector the quadratic term is ,21λt2∥v∥2, and a negative quadratic beats a linear term for large .t.
,∇f=Ax−b,;∇2f=A;f(x)=21(x−x∗)⊤A(x−x∗)+f(x∗) with x∗=A−1b and ,f(x∗)=c−21b⊤A−1b, the unique minimiser; for the example ,x∗=(0,1)⊤,;f(x∗)=−1; with a negative eigenvalue f is unbounded belowCompleting the square in n dimensions: the bowl is centred at x∗ and shaped by .A. Setting ∇f=0 finds the same ,x∗, but only step 4 says it is a minimum rather than a saddle, and only PD makes it unique: a PSD A with Av=0 leaves f constant along v (a valley of minimisers if ,b⊥v, no minimiser at all otherwise), which is Mistake 4 in the least-squares setting. Newton's method is exactly this calculation applied to the quadratic model of a general ,f, which the Newton page takes up.
Problem 7
Let f be twice differentiable on Rn and, for fixed x and ,v, let .g(t)=f(x+tv). Show that ,g′′(t)=v⊤∇2f(x+tv)v, and use it to prove that f is convex if and only if ∇2f(x)⪰0 for every .x. Conclude that 21x⊤Ax is convex exactly when .A⪰0.
.g′(t)=∇f(x+tv)⊤v.Chain rule: the derivative of f along the curve ,x+tv, whose velocity is v (the Jacobians page).
.g′′(t)=v⊤∇2f(x+tv)v.Differentiate ∑i∂if(x+tv)vi again: each ∂if contributes ,∑j∂ijfvj, giving .∑ijvi∂ijfvj.
If ∇2f⪰0 everywhere, then g′′≥0 for every ,x,v, so each g is convex: f(λy+(1−λ)z)=g(λ) with ,x=z,,v=y−z, and .g(λ)=g(λ⋅1+(1−λ)⋅0)≤λg(1)+(1−λ)g(0)=λf(y)+(1−λ)f(z).The Jensen page's Problem 2: a one-variable function with nonnegative second derivative is convex; the segment from z to y is the line z+t(y−z) for .t∈[0,1].
Conversely, if f is convex then every g is convex, so ,g′′(0)≥0, that is v⊤∇2f(x)v≥0 for every .v.Restricting a convex function to a line keeps the chord inequality, and a convex twice-differentiable function of one variable has :g′′≥0: if g′′(0)<0 then g(h)+g(−h)−2g(0)=g′′(0)h2+o(h2)<0 for small ,h, contradicting the midpoint chord inequality.
f(x)=21x⊤Ax has ∇2f=A at every ,x, so f is convex exactly when .A⪰0.Problem 6, step 1; the Hessian is constant.
;g′′(t)=v⊤∇2f(x+tv)v;f convex ⟺∇2f(x)⪰0 for all ;x;21x⊤Ax convex ⟺A⪰0Convexity in n dimensions is convexity along every line, and the second derivative along a line is the Hessian's quadratic form in that direction, so PSD everywhere is the whole story. It has to be everywhere (the Jensen page's Mistake 5) and PSD is enough: PD gives strict convexity, but the converse fails (x4 is strictly convex with ).f′′(0)=0). This is the test that certifies least squares (Hessian ,2X⊤X, Problem 4), ridge, logistic regression (Hessian N1X⊤DX on the Hessians page) and cross-entropy with softmax (the Jensen page's Problem 7) as convex, and it is what a neural network with a hidden layer fails.
Problem 8
For PD A=QΛQ⊤ define .A1/2=QΛ1/2Q⊤. Show that A1/2 is symmetric PD with ,(A1/2)2=A, and that .A−1/2AA−1/2=I. Compute A1/2 for ,A=[2112], and describe the ellipse .{x:x⊤Ax=1}.
,(A1/2)⊤=QΛ1/2Q⊤=A1/2, and its eigenvalues λi are positive, so .A1/2≻0.Λ1/2 is diagonal, hence symmetric; Problem 2's test.
.(A1/2)2=QΛ1/2Q⊤QΛ1/2Q⊤=QΛQ⊤=A.Q⊤Q=I in the middle and .Λ1/2Λ1/2=Λ.
A−1/2=QΛ−1/2Q⊤ and .A−1/2AA−1/2=QΛ−1/2ΛΛ−1/2Q⊤=QQ⊤=I.The same cancellation; Λ−1/2ΛΛ−1/2=I entrywise, and QQ⊤=I for a square orthogonal matrix.
For the example, ,Q=21[111−1],,Λ=diag(3,1), so .A1/2=3q1q1⊤+1⋅q2q2⊤=23[1111]+21[1−1−11]=21[3+13−13−13+1].The eigenvalues page's Problem 8 for Q and ;Λ;A1/2=∑iλiqiqi⊤ with q1=(1,1)⊤/2 and .q2=(1,−1)⊤/2.
Check: (A1/2)2 has diagonal 41((3+1)2+(3−1)2)=41(8)=2 and off-diagonal .41⋅2(3+1)(3−1)=41⋅4=1.(3±1)2=4±23 and .(3+1)(3−1)=2.
With :y=Q⊤x:,x⊤Ax=y⊤Λy=3y12+y22=1, an ellipse with semi-axis 1/3 along q1 and 1 along .q2.Problem 2's sum of squares in the eigenbasis; λiyi2=1 on the axis gives .yi=1/λi.
A1/2=QΛ1/2Q⊤≻0 with (A1/2)2=A and ;A−1/2AA−1/2=I; for the example ;A1/2=21[3+13−13−13+1];x⊤Ax=1 is an ellipse with semi-axes 1/3 along (1,1)⊤/2 and 1 along (1,−1)⊤/2A PD matrix has two useful square roots: the symmetric A1/2 here and the triangular Cholesky L of Problem 5, with .A=A1/2A1/2=LL⊤. Either one turns N(0,I) into N(0,A) by multiplication, and either inverse whitens, which is the variance page's W=Λ−1/2Q⊤ up to a rotation. The ellipse is the unit ball of the norm ∥x∥A=x⊤Ax and the level set of the Gaussian with precision :A: long axes where the eigenvalue is small, and Problem 9 shows that the ratio of its axes, ,κ, is what slows gradient descent.
Problem 9
For f(x)=21x⊤Ax−b⊤x with ,A≻0, show that gradient descent satisfies ,ek+1=(I−ηA)ek, that it converges from every start if and only if ,0<η<2/λmax, and that the error component along qi shrinks by the factor ∣1−ηλi∣ per step. Find the η that minimises the worst factor and the resulting rate in terms of .κ. Evaluate for .A=diag(1,10).
,xk+1−x∗=xk−η(Axk−b)−x∗=(xk−x∗)−ηA(xk−x∗), so .ek+1=(I−ηA)ek.∇f=Ax−b (Problem 6) and ,b=Ax∗, so .Axk−b=A(xk−x∗).
With :ek=∑ici(k)qi:,ci(k+1)=(1−ηλi)ci(k), so .ci(k)=(1−ηλi)kci(0).;(I−ηA)qi=qi−ηλiqi; the eigenvectors decouple the iteration into n scalar recurrences.
ek→0 for every e0⟺∣1−ηλi∣<1 for every i⟺0<ηλi<2 for every i.⟺0<η<2/λmax.A geometric sequence tends to zero exactly when its ratio has modulus below ;1; the binding constraint is the largest eigenvalue, since ηλi<2 for all i is ,ηλmax<2, and η>0 is needed for .λmin.
The worst factor is .ρ(η)=maxi∣1−ηλi∣=max(1−ηλmin,ηλmax−1).For 0<η<2/λmax the values 1−ηλi lie between 1−ηλmax and ,1−ηλmin, and the largest modulus is at one of the two ends.
ρ is minimised where the two branches are equal: ,1−ηλmin=ηλmax−1, so η∗=λmin+λmax2 and .ρ(η∗)=1−λmin+λmax2λmin=λmax+λminλmax−λmin=κ+1κ−1.One branch decreases in η and the other increases, so the maximum of the two is smallest where they cross; divide numerator and denominator by .λmin.
:A=diag(1,10):,κ=10,,η∗=2/11, rate ;9/11≈0.818; with η=1/λmax=0.1 the factors are 0.9 and ,0, rate ;0.9; with η=0.3>2/10 the stiff component grows by ∣1−3∣=2 per step.Step 5 with ,λmin=1,;λmax=10; the other two step sizes from step 4.
;ek+1=(I−ηA)ek; convergence from every start ;⟺0<η<2/λmax; the qi component scales by ;∣1−ηλi∣;η∗=λmin+λmax2 with rate ;κ+1κ−1; for :diag(1,10):,η∗=2/11, rate 9/11The step size is set by the stiffest direction and the speed by the flattest: at η∗ the error shrinks by (κ−1)/(κ+1)≈1−2/κ per step, so reaching accuracy ϵ takes about 2κlog(1/ϵ) steps, linear in the condition number. For a general smooth f the same analysis applies to the Hessian at the minimum, which is why conditioning is the quantity that normalisation, preconditioning and Adam's per-coordinate scaling attack, and why Newton's method, which multiplies by A−1 and makes every λi effectively ,1, converges in one step on a quadratic. Mistake 5 chooses η from the wrong eigenvalue.
Problem 10
For any square matrix ,M, not necessarily symmetric, show that x⊤Mx=x⊤Sx with .S=21(M+M⊤). Show that M=[1041] has both eigenvalues equal to 1 and yet v⊤Mv<0 for some .v. Why does the eigenvalue test of Problem 2 not apply?
.x⊤Mx=(x⊤Mx)⊤=x⊤M⊤x.A 1×1 matrix equals its transpose, and .(x⊤Mx)⊤=x⊤M⊤x.
.x⊤Mx=21(x⊤Mx+x⊤M⊤x)=x⊤21(M+M⊤)x=x⊤Sx.Average the two equal expressions and factor out x⊤ and .x.
M is upper-triangular with diagonal ,(1,1), so its eigenvalues are .1,1.The eigenvalues of a triangular matrix are its diagonal entries (the eigenvalues page's Problem 4).
,S=21([1041]+[1401])=[1221], Problem 1's ,B, indefinite with eigenvalues .3,−1.Add M to its transpose and halve.
:v=(1,−1)⊤:.v⊤Mv=1⋅1+4⋅1⋅(−1)+0+1⋅1=−2.Expand x⊤Mx=M11x12+M12x1x2+M21x2x1+M22x22 with ;x=(1,−1)⊤; it agrees with v⊤Sv=−2 from Problem 1.
;x⊤Mx=x⊤21(M+M⊤)x;M=[1041] has eigenvalues 1,1 but ;(1,−1)M(1,−1)⊤=−2; the eigenvalue test needs a symmetric matrixA quadratic form sees only the symmetric part of its matrix; the antisymmetric part 21(M−M⊤) contributes x⊤Kx=0 because .x⊤Kx=−x⊤K⊤x=−x⊤Kx. Problem 2 used M=QΛQ⊤ with orthonormal ,Q, which non-symmetric matrices do not have: M here has a single eigenvector direction (it is a shear) and no orthogonal eigenbasis, so its eigenvalues say nothing about its quadratic form (Mistake 2). This is also why the matrix-calculus page's ∇(x⊤Mx)=(M+M⊤)x has the symmetrised matrix in it, and why the Hessians page symmetrises A before reading off definiteness.
Where this goes wrong
1. Reading positive definite off a positive determinant
Sylvester's criterion is remembered as “the determinant is positive”, which is the last of its conditions and not the first.
[abbc]≻0⟺a>0 and ac−b2>0Right so far: Problem 3.
“The determinant is what decides it: positive determinant, positive definite.”The shortcut that causes the mistake: Problem 3's proof needed the leading entry a>0 first, and the determinant only afterwards.
A=[−100−1] has ,detA=1>0, so A≻0x⊤Ax=−∥x∥2<0 for every :x=0: negative definite. The determinant is the product of the eigenvalues, and two negative eigenvalues multiply to a positive number; diag(4,−1,−1) does the same in three dimensions with a positive trace too. The criterion needs every leading principal minor positive, a and then ,ac−b2, which for diag(−1,−1) fails at the first. The cheapest decisive test is Problem 5's: attempt the Cholesky factorisation and watch for a non-positive pivot, which here fails at .−1.
2. Trusting the eigenvalues of a non-symmetric matrix
Positive eigenvalues mean positive definite, and the matrix at hand is not checked for symmetry before the test is applied.
A=QΛQ⊤≻0⟺ every λi>0Right so far: Problem 2, for symmetric .A.
“Eigenvalues are eigenvalues; compute them and look at the signs.”The habit that causes the mistake: Problem 2's proof wrote ,x⊤Ax=∑iλi(qi⊤x)2, which needs an orthonormal eigenbasis, and only symmetric matrices are guaranteed one.
M=[1041] has eigenvalues ,1,1>0, so x⊤Mx>0 for all x=0(1,−1)M(1,−1)⊤=−2 (Problem 10). The quadratic form of M is the quadratic form of ,21(M+M⊤)=[1221], whose eigenvalues are 3 and ,−1, so the form is indefinite. The right procedure for a non-symmetric matrix is to symmetrise first and then test; a Jacobian ∂f/∂x of a non-gradient vector field is the usual place this comes up, and the Hessians page's 21(A+A⊤) is the same step taken for the Hessian of .21x⊤Ax.
3. Sampling with the transposed Cholesky factor
A=LL⊤ and A=L⊤L look alike, and whichever factor is to hand gets multiplied onto the noise.
A=LL⊤ with ,L=211021002, and x=μ+Lε has covariance LL⊤=A for ε∼N(0,I)Right so far: Problem 5 and the Gaussian page's Problem 7.
“L and L⊤ are the same factor, just written the other way.”The habit that causes the mistake: the covariance of Mε is ,MM⊤, and the order of the two factors is not optional.
x=μ+L⊤ε has covariance AIts covariance is :L⊤(L⊤)⊤=L⊤L=632352224=A: the first coordinate now has variance 6 instead of .4.L⊤L and LL⊤ share eigenvalues and determinant (64 in both cases), so a check on those would not catch it; a check on Var(x1) would. The same slip in the other direction happens in the whitening step, L−1(x−μ) against ,L−⊤(x−μ), and in software it is the difference between a library returning the lower factor and one returning the upper. Problem 8's symmetric root A1/2 has no such ambiguity, which is one reason to prefer it when cost is not the issue.
4. Assuming the normal equations have a unique solution
X⊤X is positive semidefinite and usually positive definite, and the usual case becomes the only case.
X⊤X⪰0 for every ,X, with v⊤X⊤Xv=∥Xv∥2Right so far: Problem 4, step 1.
“A Gram matrix is positive definite, so (X⊤X)−1 exists and .w=(X⊤X)−1X⊤y.”The habit that causes the mistake: Problem 4 made PD conditional on linearly independent columns, and nothing has been said about the columns.
w∗=(X⊤X)−1X⊤y is the unique least-squares solution for any XIf two features are collinear, or there are more features than examples (),d>N), some v=0 has ,Xv=0,X⊤X has a zero eigenvalue and is singular, and every w∗+tv fits equally well: a whole line (or more) of minimisers, as in Problem 6's PSD case. Problem 1's C=[1224] is X⊤X for the single row ,X=(1,2), and its null vector (2,−1)⊤ is the direction along which the fit cannot tell the features apart. Ridge adds λI and restores a unique solution (Problem 4), and the least-squares page's pseudoinverse picks the minimiser of smallest norm; both are choices, not consequences of the normal equations.
5. Choosing the gradient-descent step from the smallest eigenvalue
The slow direction is the one with the small eigenvalue, and the step is enlarged to speed it up.
The component of the error along qi scales by 1−ηλi per stepRight so far: Problem 9, step 2.
“The slowest direction is ,λmin, so pick η to make 1−ηλmin small.”The habit that causes the mistake: Problem 9's convergence condition is on ;λmax; the step that is right for the flattest direction is far too long for the stiffest.
For ,A=diag(1,10), take ,η=1=1/λmin, which kills the slow component in one stepThe stiff component scales by :1−10=−9: after k steps it is (−9)k times its start, so the iteration diverges, oscillating across the valley in ever larger swings. Any η≥2/λmax=0.2 does this. The admissible range is ,0<η<0.2, the best choice is η∗=2/11 (Problem 9), and the slow direction then shrinks by only 9/11 per step: with a single step size the slow direction cannot be sped up without breaking the fast one, and that gap, ,κ, is what momentum (the optimisers page) and preconditioning exist to close.