Unit 9, lesson 44

The Spectral Theorem for Symmetric Matrices

The real spectral theorem for symmetric matrices, why eigenvectors for distinct eigenvalues are orthogonal, and how to build an orthonormal eigenbasis and an orthogonal diagonalization, also for repeated eigenvalues.

  • Video 44
  • The Spectral Theorem and Quadratic Forms

The symmetric matrix with 22 on the diagonal and 11 off the diagonal stretches every vector on the line y=xy = x by a factor of 33 and leaves every vector on the perpendicular line y=−xy = -x where it is. So the matrix can be described by switching to coordinates along those two perpendicular lines, stretching each coordinate, and switching back, with no slanted grid anywhere. A general matrix need not allow this, because its eigenvectors can be slanted or too few to form a basis. This lesson states the theorem that guarantees a basis of perpendicular eigenvectors for every real symmetric matrix, proves the part about distinct eigenvalues, and builds the factorization A=QDQ⊤A = QDQ^{\top} by hand. Tuples such as (1,1)(1, 1) stand for column vectors.

Key terms

Symmetric matrix

Definition A real n×nn \times n matrix AA is symmetric if A⊤=AA^{\top} = A, that is, aij=ajia_{ij} = a_{ji} for all ii and jj. Only a square matrix can be symmetric, and the diagonal entries can be any real numbers. The property used again and again is that a symmetric matrix can move from one side of a dot product to the other. For all x\mathbf{x} and y\mathbf{y} in Rn\mathbb{R}^n,

(Ax)⋅y=x⊤A⊤y=x⊤Ay=x⋅(Ay).\begin{aligned} (A\mathbf{x}) \cdot \mathbf{y} &= \mathbf{x}^{\top}A^{\top}\mathbf{y} \\[0.4em] &= \mathbf{x}^{\top}A\mathbf{y} = \mathbf{x} \cdot (A\mathbf{y}). \end{aligned}

For every real m×nm \times n matrix CC, the n×nn \times n matrix C⊤CC^{\top}C is symmetric, since (C⊤C)⊤=C⊤C(C^{\top}C)^{\top} = C^{\top}C.

In plain words Reflect the matrix across its main diagonal and nothing changes. Symmetry is a condition on pairs of entries. It says nothing about signs, so a symmetric matrix can have negative or zero entries.

Example The matrices

S=[2112],[4−10−10505−3]\begin{gathered} S = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}, \\[0.4em] \begin{bmatrix} 4 & -1 & 0 \\ -1 & 0 & 5 \\ 0 & 5 & -3 \end{bmatrix} \end{gathered}

are symmetric. The matrix

B=[1102]B = \begin{bmatrix} 1 & 1 \\ 0 & 2 \end{bmatrix}

is not, because b12=1b_{12} = 1 while b21=0b_{21} = 0. For SS, moving the matrix across the dot product gives the same number, since (Se1)⋅e2=(2,1)⋅(0,1)=1(S\mathbf{e}_1) \cdot \mathbf{e}_2 = (2, 1) \cdot (0, 1) = 1 and e1⋅(Se2)=(1,0)⋅(1,2)=1\mathbf{e}_1 \cdot (S\mathbf{e}_2) = (1, 0) \cdot (1, 2) = 1.

Real spectral theorem

Definition Let AA be a real symmetric n×nn \times n matrix. Then every root of the characteristic polynomial χA(t)=det⁡(tI−A)\chi_A(t) = \det(tI - A) is real, and Rn\mathbb{R}^n has an orthonormal basis made of eigenvectors of AA. Equivalently, there are a real orthogonal matrix QQ, meaning Q⊤Q=IQ^{\top}Q = I, and a real diagonal matrix DD with

A=QDQ⊤.A = QDQ^{\top}.

The columns of QQ are the orthonormal eigenvectors, and the diagonal entries of DD are their eigenvalues in the same order. The hypotheses are real entries, a square symmetric matrix and finite dimension. The first claim, that the eigenvalues are real, has a short proof. Suppose Av=λvA\mathbf{v} = \lambda\mathbf{v} with λ\lambda complex and v\mathbf{v} a nonzero vector in Cn\mathbb{C}^n. Multiplying on the left by v∗=v‾⊤\mathbf{v}^{*} = \overline{\mathbf{v}}^{\top} gives

v∗Av=λ v∗v.\mathbf{v}^{*}A\mathbf{v} = \lambda\, \mathbf{v}^{*}\mathbf{v}.

Because AA is real and symmetric, A∗=AA^{*} = A, so the number v∗Av\mathbf{v}^{*}A\mathbf{v} equals its own conjugate (v∗Av)∗=v∗A∗v(\mathbf{v}^{*}A\mathbf{v})^{*} = \mathbf{v}^{*}A^{*}\mathbf{v} and is real. Also v∗v=∣v1∣2+⋯+∣vn∣2>0\mathbf{v}^{*}\mathbf{v} = \lvert v_1 \rvert^2 + \cdots + \lvert v_n \rvert^2 > 0, and dividing shows that λ\lambda is real. The second claim, that there are always enough orthonormal eigenvectors for a basis, needs a longer argument by induction on nn, which this lesson does not give. Neither the examples below nor the orthogonality result for distinct eigenvalues proves it. Linear Algebra II proves it in The Spectral Theorem for Normal Operators.

In plain words A real symmetric matrix always has a full set of perpendicular axes, and along each axis it simply multiplies vectors by a real factor. The factors can be positive, negative or zero.

Example For the matrix SS above,

χS(t)=(t−2)2−1=(t−3)(t−1),\begin{aligned} \chi_S(t) &= (t - 2)^2 - 1 \\[0.4em] &= (t - 3)(t - 1), \end{aligned}

so the eigenvalues 33 and 11 are real. Since S(1,1)=(3,3)S(1, 1) = (3, 3) and S(1,−1)=(1,−1)S(1, -1) = (1, -1), the vectors (1,1)(1, 1) and (1,−1)(1, -1) are eigenvectors, and they are perpendicular. The hypothesis matters. The quarter turn with columns (0,1)(0, 1) and (−1,0)(-1, 0) is not symmetric, and its characteristic polynomial t2+1t^2 + 1 has no real roots at all. The symmetric matrix diag⁡(4,−1)\operatorname{diag}(4, -1) is already orthogonally diagonalized with Q=IQ = I, and one of its axes is reversed rather than stretched, so symmetry does not make eigenvalues positive.

Orthogonality of eigenvectors for distinct eigenvalues

Definition Let AA be a real symmetric n×nn \times n matrix, and let u\mathbf{u} and v\mathbf{v} in Rn\mathbb{R}^n be eigenvectors with Au=λuA\mathbf{u} = \lambda\mathbf{u} and Av=μvA\mathbf{v} = \mu\mathbf{v}, where λ≠μ\lambda \ne \mu. Then u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0. The proof uses symmetry in the middle step,

λ(u⋅v)=(Au)⋅v=u⋅(Av)=μ(u⋅v).\begin{aligned} \lambda(\mathbf{u} \cdot \mathbf{v}) &= (A\mathbf{u}) \cdot \mathbf{v} \\[0.4em] &= \mathbf{u} \cdot (A\mathbf{v}) \\[0.4em] &= \mu(\mathbf{u} \cdot \mathbf{v}). \end{aligned}

So (λ−μ)(u⋅v)=0(\lambda - \mu)(\mathbf{u} \cdot \mathbf{v}) = 0, and since λ−μ≠0\lambda - \mu \ne 0, the dot product is 00. As a result, every vector of the eigenspace Eλ=Null⁡(A−λI)E_{\lambda} = \operatorname{Null}(A - \lambda I) is orthogonal to every vector of EμE_{\mu}. If λ=μ\lambda = \mu, the factor λ−μ\lambda - \mu is 00 and the computation gives no information about u⋅v\mathbf{u} \cdot \mathbf{v}. Indeed two eigenvectors for one eigenvalue need not be orthogonal, as the repeated eigenvalue example below shows.

In plain words Symmetry lets the matrix act on either vector in the dot product. Acting on one side multiplies the dot product by λ\lambda and acting on the other multiplies it by μ\mu, and multiplying a number by two different factors gives the same result only when that number is zero.

Example The symmetric matrix

A=[110121011]A = \begin{bmatrix} 1 & 1 & 0 \\ 1 & 2 & 1 \\ 0 & 1 & 1 \end{bmatrix}

has χA(t)=t(t−1)(t−3)\chi_A(t) = t(t - 1)(t - 3), with eigenvectors (1,−1,1)(1, -1, 1), (1,0,−1)(1, 0, -1) and (1,2,1)(1, 2, 1) for the eigenvalues 00, 11 and 33. For instance A(1,2,1)=(3,6,3)A(1, 2, 1) = (3, 6, 3). The three pairwise dot products are 1+0−11 + 0 - 1, 1−2+11 - 2 + 1 and 1+0−11 + 0 - 1, all equal to 00, as the theorem predicts. Without symmetry this fails. The matrix BB above has eigenvectors (1,0)(1, 0) and (1,1)(1, 1) for the distinct eigenvalues 11 and 22, and their dot product is 11.

Orthonormal eigenbasis

Definition Let AA be a real n×nn \times n matrix. An orthonormal eigenbasis of AA is a basis B=(q1,…,qn)\mathcal{B} = (\mathbf{q}_1, \dots, \mathbf{q}_n) of Rn\mathbb{R}^n in which every vector is a unit eigenvector, Aqi=λiqiA\mathbf{q}_i = \lambda_i\mathbf{q}_i with ∥qi∥=1\lVert \mathbf{q}_i \rVert = 1, and different vectors are orthogonal, qi⋅qj=0\mathbf{q}_i \cdot \mathbf{q}_j = 0 for i≠ji \ne j. The matrix Q=[q1 ⋯ qn]Q = [\mathbf{q}_1 \ \cdots \ \mathbf{q}_n] then satisfies Q⊤Q=IQ^{\top}Q = I, so it is orthogonal and Q−1=Q⊤Q^{-1} = Q^{\top}. The coordinates of a vector in this basis are dot products,

[x]B=Q⊤x=[q1⋅x⋮qn⋅x],[\mathbf{x}]_{\mathcal{B}} = Q^{\top}\mathbf{x} = \begin{bmatrix} \mathbf{q}_1 \cdot \mathbf{x} \\ \vdots \\ \mathbf{q}_n \cdot \mathbf{x} \end{bmatrix},

so no linear system has to be solved. The coordinate change keeps lengths, since ∥Qz∥2=z⊤Q⊤Qz=∥z∥2\lVert Q\mathbf{z} \rVert^2 = \mathbf{z}^{\top}Q^{\top}Q\mathbf{z} = \lVert \mathbf{z} \rVert^2. To get unit vectors from perpendicular eigenvectors, divide each by its length. A nonzero multiple of an eigenvector is still an eigenvector for the same eigenvalue.

In plain words An orthonormal eigenbasis is a set of perpendicular unit axes along which the matrix only stretches. Coordinates along such axes are read off with dot products, and lengths and angles are the same in the new coordinates as in the old ones.

Example For SS, the eigenvectors (1,1)(1, 1) and (1,−1)(1, -1) both have length 2\sqrt{2}, and dividing gives

q1=12[11],q2=12[1−1],\begin{aligned} \mathbf{q}_1 &= \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 1 \end{bmatrix}, \\[0.4em] \mathbf{q}_2 &= \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1 \end{bmatrix}, \end{aligned}

with eigenvalues 33 and 11. For x=(3,1)\mathbf{x} = (3, 1) the coordinates are q1⋅x=4/2=22\mathbf{q}_1 \cdot \mathbf{x} = 4/\sqrt{2} = 2\sqrt{2} and q2⋅x=2/2=2\mathbf{q}_2 \cdot \mathbf{x} = 2/\sqrt{2} = \sqrt{2}, and indeed 22 q1+2 q2=(2,2)+(1,−1)=(3,1)2\sqrt{2}\,\mathbf{q}_1 + \sqrt{2}\,\mathbf{q}_2 = (2, 2) + (1, -1) = (3, 1). Applying SS multiplies these coordinates by 33 and 11, so

Sx=3⋅22 q1+2 q2=[75],S\mathbf{x} = 3 \cdot 2\sqrt{2}\,\mathbf{q}_1 + \sqrt{2}\,\mathbf{q}_2 = \begin{bmatrix} 7 \\ 5 \end{bmatrix},

which matches the direct product (2⋅3+1,3+2⋅1)=(7,5)(2 \cdot 3 + 1, 3 + 2 \cdot 1) = (7, 5).

Orthogonal diagonalization

Definition A real n×nn \times n matrix AA is orthogonally diagonalizable if

A=QDQ⊤A = QDQ^{\top}

for a real orthogonal matrix QQ and a real diagonal matrix DD, or equivalently Q⊤AQ=DQ^{\top}AQ = D. The columns of QQ then form an orthonormal eigenbasis, and the diagonal entries of DD are the matching eigenvalues in the same order. With columns q1,…,qn\mathbf{q}_1, \dots, \mathbf{q}_n and diagonal entries λ1,…,λn\lambda_1, \dots, \lambda_n, the product expands into the spectral decomposition

A=λ1q1q1⊤+⋯+λnqnqn⊤.A = \lambda_1 \mathbf{q}_1\mathbf{q}_1^{\top} + \cdots + \lambda_n \mathbf{q}_n\mathbf{q}_n^{\top}.

A real matrix is orthogonally diagonalizable exactly when it is symmetric. The spectral theorem gives one direction. For the other, (QDQ⊤)⊤=QD⊤Q⊤=QDQ⊤(QDQ^{\top})^{\top} = QD^{\top}Q^{\top} = QDQ^{\top}, so every matrix of this form is symmetric. To orthogonally diagonalize a symmetric matrix, find its eigenvalues, find an orthonormal basis of each eigenspace, and place the basis vectors in QQ and their eigenvalues in DD in the same order.

In plain words The factor Q⊤Q^{\top} reads off coordinates along perpendicular unit axes, DD stretches each coordinate by its eigenvalue, and QQ turns the result back into standard coordinates. Each term λiqiqi⊤\lambda_i\mathbf{q}_i\mathbf{q}_i^{\top} projects onto one axis and scales by that axis’s eigenvalue.

Example For SS, with q1\mathbf{q}_1 and q2\mathbf{q}_2 as above,

Q=12[111−1],D=[3001].\begin{gathered} Q = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \\[0.4em] D = \begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}. \end{gathered}

The columns are orthonormal, so Q⊤Q=IQ^{\top}Q = I. To check S=QDQ⊤S = QDQ^{\top}, compute the two terms of the spectral decomposition,

3q1q1⊤=32[1111],q2q2⊤=12[1−1−11].\begin{aligned} 3\mathbf{q}_1\mathbf{q}_1^{\top} &= \frac{3}{2}\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}, \\[0.4em] \mathbf{q}_2\mathbf{q}_2^{\top} &= \frac{1}{2}\begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}. \end{aligned}

Their sum has diagonal entries 32+12=2\frac{3}{2} + \frac{1}{2} = 2 and off-diagonal entries 32−12=1\frac{3}{2} - \frac{1}{2} = 1, which is SS. Other choices work too, such as −q2-\mathbf{q}_2 in place of q2\mathbf{q}_2, or the two columns swapped together with the two eigenvalues. The matrix BB above is diagonalizable, since its eigenvalues 11 and 22 are distinct, but it is not symmetric, so no choice of eigenvectors diagonalizes it orthogonally.

Orthonormal basis of a repeated eigenspace

Definition Let λ\lambda be an eigenvalue of a real symmetric matrix AA whose eigenspace Eλ=Null⁡(A−λI)E_{\lambda} = \operatorname{Null}(A - \lambda I) has dimension m≥2m \ge 2. Every nonzero vector of EλE_{\lambda} is an eigenvector for λ\lambda, and every linear combination of vectors in EλE_{\lambda} stays in EλE_{\lambda}. So Gram-Schmidt applied to any basis of EλE_{\lambda} produces an orthonormal basis of EλE_{\lambda} made of eigenvectors. This step is needed in general, because two basis vectors of one eigenspace need not be orthogonal. For a symmetric matrix, mm equals the algebraic multiplicity of λ\lambda, a consequence of the spectral theorem. Putting together orthonormal bases of all the eigenspaces gives an orthonormal eigenbasis of Rn\mathbb{R}^n. The combined list is orthonormal because different eigenspaces are already orthogonal to each other, and it has nn vectors because, by the spectral theorem, the dimensions of the eigenspaces add up to nn. The result is not unique, since any orthonormal basis of each eigenspace works.

In plain words Inside a repeated eigenspace every direction is an eigenvector direction, so you are free to pick perpendicular ones. The eigenvectors that row reduction gives you are usually not perpendicular, and Gram-Schmidt fixes that without leaving the eigenspace.

Example The symmetric matrix

A=[211121112]A = \begin{bmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{bmatrix}

has χA(t)=(t−1)2(t−4)\chi_A(t) = (t - 1)^2(t - 4). The eigenspace E4E_4 is spanned by (1,1,1)(1, 1, 1). Every entry of A−IA - I equals 11, so E1E_1 is the plane x+y+z=0x + y + z = 0, with basis b1=(1,−1,0)\mathbf{b}_1 = (1, -1, 0) and b2=(1,0,−1)\mathbf{b}_2 = (1, 0, -1). Both are eigenvectors for 11, but b1⋅b2=1\mathbf{b}_1 \cdot \mathbf{b}_2 = 1. Gram-Schmidt keeps b1\mathbf{b}_1 and replaces b2\mathbf{b}_2 by

b2−b2⋅b1b1⋅b1 b1=[1/21/2−1],\mathbf{b}_2 - \frac{\mathbf{b}_2 \cdot \mathbf{b}_1}{\mathbf{b}_1 \cdot \mathbf{b}_1}\,\mathbf{b}_1 = \begin{bmatrix} 1/2 \\ 1/2 \\ -1 \end{bmatrix},

whose entries still add to 00, so it is still an eigenvector for 11. Normalizing b1\mathbf{b}_1, twice this vector and (1,1,1)(1, 1, 1) gives the orthonormal eigenbasis

q1=12[1−10],q2=16[11−2],q3=13[111],\begin{aligned} \mathbf{q}_1 &= \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ -1 \\ 0 \end{bmatrix}, \\[0.4em] \mathbf{q}_2 &= \frac{1}{\sqrt{6}}\begin{bmatrix} 1 \\ 1 \\ -2 \end{bmatrix}, \\[0.4em] \mathbf{q}_3 &= \frac{1}{\sqrt{3}}\begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}, \end{aligned}

and A=QDQ⊤A = QDQ^{\top} with Q=[q1 q2 q3]Q = [\mathbf{q}_1 \ \mathbf{q}_2 \ \mathbf{q}_3] and D=diag⁡(1,1,4)D = \operatorname{diag}(1, 1, 4). As a check, q1⋅q3\mathbf{q}_1 \cdot \mathbf{q}_3 and q2⋅q3\mathbf{q}_2 \cdot \mathbf{q}_3 are 00 by the theorem on distinct eigenvalues, and q1⋅q2\mathbf{q}_1 \cdot \mathbf{q}_2 is 00 by construction. In the extreme case 2I2I, every nonzero vector is an eigenvector, so (1,0)(1, 0) and (1,1)(1, 1) are eigenvectors that are not orthogonal, and every orthonormal basis of R2\mathbb{R}^2 is an orthonormal eigenbasis.

Check yourself

  1. Orthogonally diagonalize the matrix AA with rows (6,2)(6, 2) and (2,3)(2, 3).
Show the answer

The matrix is symmetric, so an orthogonal diagonalization exists. Its characteristic polynomial is

χA(t)=(t−6)(t−3)−4=t2−9t+14=(t−7)(t−2).\begin{aligned} \chi_A(t) &= (t - 6)(t - 3) - 4 \\[0.4em] &= t^2 - 9t + 14 \\[0.4em] &= (t - 7)(t - 2). \end{aligned}

For λ=7\lambda = 7, the system (A−7I)x=0(A - 7I)\mathbf{x} = \mathbf{0} reduces to −x+2y=0-x + 2y = 0, giving the eigenvector (2,1)(2, 1). For λ=2\lambda = 2, it reduces to 4x+2y=04x + 2y = 0, giving (1,−2)(1, -2). Their dot product is 2−2=02 - 2 = 0, and both have length 5\sqrt{5}, so

Q=15[211−2],D=[7002].\begin{gathered} Q = \frac{1}{\sqrt{5}}\begin{bmatrix} 2 & 1 \\ 1 & -2 \end{bmatrix}, \\[0.4em] D = \begin{bmatrix} 7 & 0 \\ 0 & 2 \end{bmatrix}. \end{gathered}

Check with the spectral decomposition. The sum 75(2,1)(2,1)⊤+25(1,−2)(1,−2)⊤\frac{7}{5}(2, 1)(2, 1)^{\top} + \frac{2}{5}(1, -2)(1, -2)^{\top} has diagonal entries 28+25=6\frac{28 + 2}{5} = 6 and 7+85=3\frac{7 + 8}{5} = 3 and off-diagonal entries 14−45=2\frac{14 - 4}{5} = 2, which is AA.

  1. The matrix CC with rows (1,2)(1, 2) and (3,2)(3, 2) has eigenvectors (2,3)(2, 3) for the eigenvalue 44 and (1,−1)(1, -1) for the eigenvalue −1-1. A student normalizes them, puts them in QQ and writes C=QDQ⊤C = QDQ^{\top} with D=diag⁡(4,−1)D = \operatorname{diag}(4, -1). What is wrong, and what is a correct diagonalization?
Show the answer

The matrix is not symmetric, since c12=2c_{12} = 2 and c21=3c_{21} = 3. The eigenvectors are not orthogonal, because (2,3)⋅(1,−1)=−1(2, 3) \cdot (1, -1) = -1, so the normalized columns have dot product −1/26-1/\sqrt{26} and Q⊤Q≠IQ^{\top}Q \ne I. That means Q⊤Q^{\top} is not Q−1Q^{-1}. Even more directly, QDQ⊤QDQ^{\top} is symmetric for every QQ and every diagonal DD, so it cannot equal CC. No other choice of eigenvectors helps either, since the two eigenvector lines meet at a fixed angle that is not a right angle. A correct diagonalization uses the inverse,

P=[213−1],P−1=15[113−2],C=P[400−1]P−1.\begin{aligned} P &= \begin{bmatrix} 2 & 1 \\ 3 & -1 \end{bmatrix}, \\[0.4em] P^{-1} &= \frac{1}{5}\begin{bmatrix} 1 & 1 \\ 3 & -2 \end{bmatrix}, \\[0.4em] C &= P \begin{bmatrix} 4 & 0 \\ 0 & -1 \end{bmatrix} P^{-1}. \end{aligned}
  1. The symmetric matrix MM below has the eigenvalue 33, repeated, and the eigenvalue 00. Find an orthonormal eigenbasis and an orthogonal diagonalization of
M=[21112−11−12].M = \begin{bmatrix} 2 & 1 & 1 \\ 1 & 2 & -1 \\ 1 & -1 & 2 \end{bmatrix}.
Show the answer

Every row of M−3IM - 3I is a multiple of (−1,1,1)(-1, 1, 1), so E3E_3 is the plane −x+y+z=0-x + y + z = 0, with basis (1,1,0)(1, 1, 0) and (1,0,1)(1, 0, 1). These have dot product 11, so apply Gram-Schmidt. Keep (1,1,0)(1, 1, 0) and replace the second vector by

[101]−12[110]=[1/2−1/21],\begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} - \frac{1}{2}\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1/2 \\ -1/2 \\ 1 \end{bmatrix},

or (1,−1,2)(1, -1, 2) after scaling. For the eigenvalue 00, the vector (1,−1,−1)(1, -1, -1) satisfies M(1,−1,−1)=0M(1, -1, -1) = \mathbf{0}, and it is orthogonal to the plane E3E_3, as the theorem on distinct eigenvalues requires. The orthonormal eigenbasis is

q1=12[110],q2=16[1−12],q3=13[1−1−1],\begin{aligned} \mathbf{q}_1 &= \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix}, \\[0.4em] \mathbf{q}_2 &= \frac{1}{\sqrt{6}}\begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix}, \\[0.4em] \mathbf{q}_3 &= \frac{1}{\sqrt{3}}\begin{bmatrix} 1 \\ -1 \\ -1 \end{bmatrix}, \end{aligned}

and M=QDQ⊤M = QDQ^{\top} with Q=[q1 q2 q3]Q = [\mathbf{q}_1 \ \mathbf{q}_2 \ \mathbf{q}_3] and D=diag⁡(3,3,0)D = \operatorname{diag}(3, 3, 0). As a check, Mq2=3q2M\mathbf{q}_2 = 3\mathbf{q}_2, since M(1,−1,2)=(3,−3,6)M(1, -1, 2) = (3, -3, 6). Any other orthonormal basis of the plane E3E_3 would do as well.

How this lesson connects

Where this leads in Linear Algebra II