MAT1041 · Week 14 · - Symmetric Matrices and Orthogonal Diagonalization

Symmetric matrices and orthogonal diagonalization

You learn orthogonal matrices (Pᵀ = P⁻¹), the special properties of symmetric matrices (real eigenvalues, orthogonal eigenspaces, always diagonalizable), how to diagonalize a symmetric matrix with an orthogonal P so that PᵀAP = D, and how to use Gram-Schmidt for a repeated eigenvalue.

symmetric matrixorthogonal matrixorthonormal setorthogonal vectorsnormalizeorthogonally diagonalizablespectral theoremGram-Schmidt processquadratic formprincipal axes

The last topic of the semester shows how “well-behaved” symmetric matrices are. A general matrix may not be diagonalizable, may have no real eigenvalues, and its eigenvectors may sit at skew angles to each other. None of this happens with a symmetric matrix: the eigenvalues are real, eigenvectors of distinct eigenvalues are perpendicular, and the matrix is always diagonalizable. Moreover, PP can be chosen so that its columns are mutually perpendicular unit vectors; then you don’t even need to compute P−1P^{-1}, because P−1=PTP^{-1} = P^T. This result is called the spectral theorem and is used everywhere from statistics (PCA) to physics.

Golden rules:

  1. An orthogonal matrix: the columns have unit length and are pairwise perpendicular. Its inverse is its transpose.
  2. In a symmetric matrix, eigenvectors of distinct eigenvalues are automatically perpendicular.
  3. Apply Gram-Schmidt in the eigenspace of a repeated eigenvalue.
  4. At the end normalize every vector. This is the step that gets forgotten.

Orthogonal vectors and orthogonal matrices

From week 6: if u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0, then u\mathbf{u} and v\mathbf{v} are orthogonal. A set made of pairwise perpendicular vectors is an orthogonal set, and if all have unit length it is an orthonormal set. An orthogonal set containing no zero vector is always linearly independent.

A square matrix QQ is an orthogonal matrix if it satisfies QTQ=IQ^TQ = I. Since the (i,j)(i, j) entry of QTQQ^TQ is the dot product of column ii with column jj:

QTQ=I  ⟺  the columns are orthonormal  ⟺  Q−1=QT.Q^TQ = I \iff \text{the columns are orthonormal} \iff Q^{-1} = Q^T.

ExampleOrthogonal?
[cos⁡θ−sin⁡θsin⁡θcos⁡θ]\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} (rotation)yes, det⁡=1\det = 1
[100−1]\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} (reflection)yes, det⁡=−1\det = -1
[3/5−4/54/53/5]\begin{bmatrix} 3/5 & -4/5 \\ 4/5 & 3/5 \end{bmatrix}yes (Q5)
[111−1]\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}no: the columns are perpendicular but have length 2\sqrt2

The last row is a classic trap: perpendicular columns are not enough, they must also be unit length. 12[111−1]\frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} is orthogonal.

Orthogonal matrices preserve length and angle: ∥Qx∥=∥x∥\|Q\mathbf{x}\| = \|\mathbf{x}\|, because ∥Qx∥2=xTQTQx=xTx\|Q\mathbf{x}\|^2 = \mathbf{x}^TQ^TQ\mathbf{x} = \mathbf{x}^T\mathbf{x}. Geometrically, only rotations and reflections.

Three properties of symmetric matrices

If AA is real and symmetric (AT=AA^T = A):

  1. All its eigenvalues are real.
  2. Eigenvectors belonging to distinct eigenvalues are perpendicular. Proof: Au=λuA\mathbf{u} = \lambda\mathbf{u}, Av=μvA\mathbf{v} = \mu\mathbf{v}, λ≠μ\lambda \neq \mu. λ(u⋅v)=(Au)Tv=uTATv=uTAv=μ(u⋅v)\lambda(\mathbf{u} \cdot \mathbf{v}) = (A\mathbf{u})^T\mathbf{v} = \mathbf{u}^TA^T\mathbf{v} = \mathbf{u}^TA\mathbf{v} = \mu(\mathbf{u} \cdot \mathbf{v}). (λ−μ)(u⋅v)=0(\lambda - \mu)(\mathbf{u} \cdot \mathbf{v}) = 0, so u⋅v=0\mathbf{u} \cdot \mathbf{v} = 0. (AT=AA^T = A is used exactly here.)
  3. For every eigenvalue, geometric multiplicity = algebraic multiplicity. Consequence: it is always diagonalizable.

Spectral theorem. Let AA be an n×nn \times n real matrix. The following two statements are equivalent:

  • AA is symmetric.
  • There exist an orthogonal PP and a diagonal DD with PTAP=DP^TAP = D (orthogonal diagonalization).

So the answer to “is it orthogonally diagonalizable?” is at a glance: is the matrix symmetric?

The recipe for orthogonal diagonalization

  1. Solve the characteristic equation.
  2. Find a basis of the eigenspace for each eigenvalue.
  3. If an eigenspace has dimension 2 or more, apply Gram-Schmidt to its basis to make it orthogonal. (Single-dimensional eigenspaces, and orthogonality between different eigenspaces, come for free.)
  4. Normalize every vector: v/∥v∥\mathbf{v}/\|\mathbf{v}\|.
  5. The columns of PP are these orthonormal vectors, with the eigenvalues in DD in the same order. A=PDPTA = PDP^T.

Gram-Schmidt (two vectors). If {v1,v2}\{\mathbf{v}_1, \mathbf{v}_2\} is independent,

u1=v1,u2=v2−v2⋅u1u1⋅u1u1.\mathbf{u}_1 = \mathbf{v}_1, \qquad \mathbf{u}_2 = \mathbf{v}_2 - \frac{\mathbf{v}_2 \cdot \mathbf{u}_1}{\mathbf{u}_1 \cdot \mathbf{u}_1}\mathbf{u}_1.

u2\mathbf{u}_2 removes from v2\mathbf{v}_2 the component along u1\mathbf{u}_1; what remains is the perpendicular part. With three vectors, both the u1\mathbf{u}_1 and u2\mathbf{u}_2 components are removed from u3\mathbf{u}_3.

Example 1 (2×2). A=[3113]A = \begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix}. Trace 6, det 8: λ2−6λ+8=(λ−4)(λ−2)\lambda^2 - 6\lambda + 8 = (\lambda - 4)(\lambda - 2).

λ=4:(1,1),λ=2:(1,−1),P=12[111−1],D=[4002].\lambda = 4: (1, 1), \qquad \lambda = 2: (1, -1), \qquad P = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \quad D = \begin{bmatrix} 4 & 0 \\ 0 & 2 \end{bmatrix}.

The eigenvectors came out perpendicular by themselves; the only job was to normalize.

Example 2 (3×3, repeated eigenvalue). A=[211121112]A = \begin{bmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{bmatrix}.

The characteristic polynomial is λ3−6λ2+9λ−4=(λ−1)2(λ−4)\lambda^3 - 6\lambda^2 + 9\lambda - 4 = (\lambda - 1)^2(\lambda - 4). Check: trace 6=1+1+46 = 1 + 1 + 4.

  • λ=4\lambda = 4: the rows of A−4IA - 4I are (−2,1,1),(1,−2,1),(1,1,−2)(-2, 1, 1), (1, -2, 1), (1, 1, -2); the solution is x=y=zx = y = z: (1,1,1)(1, 1, 1).
  • λ=1\lambda = 1: all rows of A−IA - I are (1,1,1)(1, 1, 1): a single equation x+y+z=0x + y + z = 0. A basis is v1=(−1,1,0)\mathbf{v}_1 = (-1, 1, 0), v2=(−1,0,1)\mathbf{v}_2 = (-1, 0, 1). These are not perpendicular (v1⋅v2=1\mathbf{v}_1 \cdot \mathbf{v}_2 = 1).

Gram-Schmidt (within the eigenspace):

u1 = (-1, 1, 0)
v2·u1 = 1 + 0 + 0 = 1,   u1·u1 = 2
u2 = (-1, 0, 1) - (1/2)(-1, 1, 0) = (-1/2, -1/2, 1)   → multiply by 2: (-1, -1, 2)
check: u1·u2 = 1 - 1 + 0 = 0;  A u2 = (-2-1+2, -1-2+2, -1-1+4) = (-1, -1, 2) = 1·u2

(1,1,1)(1, 1, 1) is already perpendicular to both (a different eigenvalue). Normalize: the lengths are 2\sqrt2, 6\sqrt6, 3\sqrt3.

P=[−12−161312−161302613],D=[100010004].P = \begin{bmatrix} -\frac{1}{\sqrt2} & -\frac{1}{\sqrt6} & \frac{1}{\sqrt3} \\ \frac{1}{\sqrt2} & -\frac{1}{\sqrt6} & \frac{1}{\sqrt3} \\ 0 & \frac{2}{\sqrt6} & \frac{1}{\sqrt3} \end{bmatrix}, \qquad D = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 4 \end{bmatrix}.

PITFALL · skipping Gram-Schmidt for a repeated eigenvalue. Two eigenvectors from the same eigenspace need not be perpendicular. In Example 2, (−1,1,0)(-1, 1, 0) and (−1,0,1)(-1, 0, 1) are both correct eigenvectors, but the angle between them is 60∘60^\circ. If you normalize them directly and put them in PP, you get PTP≠IP^TP \neq I.

TIP · check. To check PTP=IP^TP = I, look at the dot product of each pair of columns (it must be 0) and the length of each column (it must be 1). Much shorter than multiplying out PTAPP^TAP completely.

Application: quadratic forms

The expression Q(x,y)=ax2+bxy+cy2Q(x, y) = ax^2 + bxy + cy^2 is a quadratic form and is written with a symmetric matrix:

Q(x)=xTAx,A=[ab/2b/2c].Q(\mathbf{x}) = \mathbf{x}^TA\mathbf{x}, \qquad A = \begin{bmatrix} a & b/2 \\ b/2 & c \end{bmatrix}.

If A=PDPTA = PDP^T, then with the change of variable x=Py\mathbf{x} = P\mathbf{y}, Q=λ1y12+λ2y22Q = \lambda_1y_1^2 + \lambda_2y_2^2: no cross term. The columns of PP are the principal axes. In Q11, 3x2+4xy+3y2=5x′2+y′23x^2 + 4xy + 3y^2 = 5x'^2 + y'^2; the directions (1,1)(1, 1) and (−1,1)(-1, 1) are the axes of the ellipse. The signs of the eigenvalues tell whether the form is always positive (positive definite).

Semester summary: the diagonalization hierarchy

Type of matrixDiagonalizable?PP
General square matrixsometimes (if there are nn independent eigenvectors)invertible
nn distinct eigenvaluesalwaysinvertible
Symmetricalwaysorthogonal (P−1=PTP^{-1} = P^T)

Common mistakes

WrongRight
Counting a matrix with perpendicular columns as orthogonalThe columns must also be unit length
Forgetting to normalizeDivide each column by its own length
Using the eigenvectors of a repeated eigenvalue as they areGram-Schmidt first
Doing Gram-Schmidt between different eigenspacesNot needed, they are already perpendicular
Writing A=PDP−1A = PDP^{-1} and computing P−1P^{-1}P−1=PTP^{-1} = P^T
Writing the xyxy coefficient of a quadratic form as is in the off-diagonalHalf of it: b/2b/2
Trying to orthogonally diagonalize a non-symmetric matrixOnly symmetric ones
det⁡Q\det Q is always 1±1\pm1

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Which of the matrices A=[1221]A = \begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix} and Q=12[11−11]Q = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ -1 & 1 \end{bmatrix} is orthogonal?

Show answer
Only QQ

Orthogonal: QTQ=IQ^TQ = I, that is, the columns have unit length and are perpendicular to each other.QQ: the columns are 12(1,−1)\frac{1}{\sqrt2}(1, -1) and 12(1,1)\frac{1}{\sqrt2}(1, 1), dot product 12(1−1)=0\frac12(1 - 1) = 0, lengths 1.AA: ATA=[5445]≠IA^TA = \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} \neq I. Being symmetric is not being orthogonal.

Question 2easy

Find the eigenvalues of the symmetric matrix A=[5222]A = \begin{bmatrix} 5 & 2 \\ 2 & 2 \end{bmatrix}.

Show answer
66 and 11

Trace 7, det 10−4=610 - 4 = 6: λ2−7λ+6=(λ−6)(λ−1)\lambda^2 - 7\lambda + 6 = (\lambda - 6)(\lambda - 1).
Since it is symmetric, it was known in advance that they would be real.

Question 3medium

Orthogonally diagonalize A=[5222]A = \begin{bmatrix} 5 & 2 \\ 2 & 2 \end{bmatrix}: find an orthogonal PP and diagonal DD with PTAP=DP^TAP = D.

Show answer
P=15[211−2], D=[6001]P = \frac{1}{\sqrt5}\begin{bmatrix} 2 & 1 \\ 1 & -2 \end{bmatrix},\ D = \begin{bmatrix} 6 & 0 \\ 0 & 1 \end{bmatrix}

λ=6\lambda = 6: A−6I=[−122−4]A - 6I = \begin{bmatrix} -1 & 2 \\ 2 & -4 \end{bmatrix}, x=2yx = 2y: (2,1)(2, 1).λ=1\lambda = 1: A−I=[4221]A - I = \begin{bmatrix} 4 & 2 \\ 2 & 1 \end{bmatrix}, 2x+y=02x + y = 0: (1,−2)(1, -2).
The two are perpendicular: 2−2=02 - 2 = 0. Both have length 5\sqrt5; normalize and use them as columns.

Question 4easy

Find kk such that (1,k,2)(1, k, 2) and (3,1,−1)(3, 1, -1) are orthogonal.

Show answer
k=−1k = -1

Perpendicular   ⟺  \iff dot product 0: 3+k−2=03 + k - 2 = 0, k=−1k = -1.

Question 5medium

Find the inverse of Q=[3/5−4/54/53/5]Q = \begin{bmatrix} 3/5 & -4/5 \\ 4/5 & 3/5 \end{bmatrix}.

Show answer
[3/54/5−4/53/5]\begin{bmatrix} 3/5 & 4/5 \\ -4/5 & 3/5 \end{bmatrix}

The columns are (3/5,4/5)(3/5, 4/5) and (−4/5,3/5)(-4/5, 3/5): lengths 9+1625=1\frac{9 + 16}{25} = 1, dot product −1225+1225=0-\frac{12}{25} + \frac{12}{25} = 0. QQ is orthogonal.
The inverse of an orthogonal matrix is its transpose: Q−1=QTQ^{-1} = Q^T. No calculation.

Question 6medium

True or false: Every real symmetric matrix is diagonalizable.

Show answer
True

Spectral theorem: the eigenvalues of a real symmetric matrix are real, and for every eigenvalue the geometric multiplicity equals the algebraic multiplicity. In fact it is diagonalizable with an orthogonal PP.
The non-symmetric [2102]\begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix} was not diagonalizable; with a symmetric matrix this can't happen.

Question 7hard

AA is a 3×33 \times 3 symmetric matrix. (1,2,−1)(1, 2, -1) is an eigenvector for λ=3\lambda = 3 and (2,a,4)(2, a, 4) is an eigenvector for λ=−1\lambda = -1. Find aa.

Show answer
a=1a = 1

In a symmetric matrix, eigenvectors of distinct eigenvalues are perpendicular.(1,2,−1)⋅(2,a,4)=2+2a−4=0⇒a=1(1, 2, -1) \cdot (2, a, 4) = 2 + 2a - 4 = 0 \Rightarrow a = 1.

Question 8hard

Orthogonally diagonalize A=[102030201]A = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 3 & 0 \\ 2 & 0 & 1 \end{bmatrix}.

Show answer
P=[1/201/20101/20−1/2], D=diag⁡(3,3,−1)P = \begin{bmatrix} 1/\sqrt2 & 0 & 1/\sqrt2 \\ 0 & 1 & 0 \\ 1/\sqrt2 & 0 & -1/\sqrt2 \end{bmatrix},\ D = \operatorname{diag}(3, 3, -1)

The eigenvalues are 3,3,−13, 3, -1 ((λ−3)2(λ+1)(\lambda - 3)^2(\lambda + 1)).λ=3\lambda = 3: A−3I=[−20200020−2]A - 3I = \begin{bmatrix} -2 & 0 & 2 \\ 0 & 0 & 0 \\ 2 & 0 & -2 \end{bmatrix}, x=zx = z, yy free: (1,0,1)(1, 0, 1) and (0,1,0)(0, 1, 0). These are already perpendicular, no Gram-Schmidt needed.λ=−1\lambda = -1: A+I=[202040202]A + I = \begin{bmatrix} 2 & 0 & 2 \\ 0 & 4 & 0 \\ 2 & 0 & 2 \end{bmatrix}, y=0y = 0, x=−zx = -z: (1,0,−1)(1, 0, -1).
Normalize: (1,0,1)/2(1, 0, 1)/\sqrt2, (0,1,0)(0, 1, 0), (1,0,−1)/2(1, 0, -1)/\sqrt2.

Question 9medium

What are the possible values of det⁡Q\det Q for an orthogonal matrix QQ?

Show answer
11 or −1-1

QTQ=I⇒det⁡QTdet⁡Q=1⇒(det⁡Q)2=1Q^TQ = I \Rightarrow \det Q^T\det Q = 1 \Rightarrow (\det Q)^2 = 1.
Rotations give +1+1 (the matrix in Q5), reflections −1-1 (diag⁡(1,−1)\operatorname{diag}(1, -1)).

Question 10hard

Apply the Gram-Schmidt process to {(1,1,0),(1,0,1)}\{(1, 1, 0), (1, 0, 1)\} to get an orthogonal basis of their span.

Show answer
{(1,1,0), (1,−1,2)}\{(1, 1, 0),\ (1, -1, 2)\}

u1=(1,1,0)\mathbf{u}_1 = (1, 1, 0). u2=(1,0,1)−(1,0,1)⋅u1u1⋅u1u1=(1,0,1)−12(1,1,0)=(12,−12,1)\mathbf{u}_2 = (1, 0, 1) - \frac{(1, 0, 1) \cdot \mathbf{u}_1}{\mathbf{u}_1 \cdot \mathbf{u}_1}\mathbf{u}_1 = (1, 0, 1) - \frac12(1, 1, 0) = \left(\tfrac12, -\tfrac12, 1\right).
Multiply by 2 (orthogonality is not affected): (1,−1,2)(1, -1, 2). Check: 1−1+0=01 - 1 + 0 = 0.

Question 11hard

Write the quadratic form Q(x,y)=3x2+4xy+3y2Q(x, y) = 3x^2 + 4xy + 3y^2 as xTAx\mathbf{x}^TA\mathbf{x} with AA symmetric, and find the eigenvalues of AA.

Show answer
A=[3223]A = \begin{bmatrix} 3 & 2 \\ 2 & 3 \end{bmatrix}; eigenvalues 55 and 11

Diagonal: the coefficients of x2x^2 and y2y^2. The coefficient of xyxy is 4, split half and half between the two off-diagonal entries: 2 and 2.
Eigenvalues: trace 6, det 5, λ2−6λ+5\lambda^2 - 6\lambda + 5: 55 (direction (1,1)(1, 1)) and 11 (direction (−1,1)(-1, 1)).
In the new axes Q=5x′2+y′2Q = 5x'^2 + y'^2: the cross term disappears.

Verification: The eigenvalues and eigenspaces were found in node with BigInt fractions from the roots of the characteristic polynomial and the exact null space; to avoid normalizations containing square roots, orthogonality SᵀS = diag(‖vᵢ‖²) and diagonalization SᵀAS = diag(‖vᵢ‖²λᵢ) were checked exactly with the unscaled column matrix S; the Gram-Schmidt steps and dot products were computed with exact fractions (verify/MAT1041/14.mjs).

Review card

Symmetric: A^T = A. ORTHOGONAL MATRIX: Q^T Q = I ⇔ Q⁻¹ = Q^T ⇔ the columns are ORTHONORMAL (unit + perpendicular). det Q = ±1. Preserves length and angle: ||Qx|| = ||x||. SYMMETRIC MATRIX (spectral theorem): (1) eigenvalues are REAL (2) eigenvectors of distinct eigenvalues are PERPENDICULAR (3) it is ALWAYS diagonalizable, and with an ORTHOGONAL P: P^T A P = D. The converse is also true: an orthogonally diagonalizable matrix is symmetric. RECIPE: eigenvalues → a basis of each E_λ → (for repeated λ) Gram-Schmidt → NORMALIZE → the columns of P. Gram-Schmidt: u1 = v1; u2 = v2 - (v2·u1)/(u1·u1) u1. Scaling is allowed. Vectors in different eigenspaces are already perpendicular; GS only WITHIN the same eigenspace. Normalize: v/||v||. DON'T FORGET: a P that is not normalized is not orthogonal. A = PDP^T (P^T instead of P⁻¹). Quadratic form ax² + bxy + cy² → A = [a b/2; b/2 c]; eigenvectors = principal axes.