You've learned about eigen-decomposition in the previous chapter, typically applied to square matrices to find directions (eigenvectors) that remain unchanged (up to scaling) under the transformation represented by the matrix. Recall that for a matrix A, the eigenvalue equation is Ax=λx. If A is symmetric, its eigen-decomposition takes the form A=VΛVT, where V contains the orthogonal eigenvectors and Λ is a diagonal matrix of eigenvalues.
Singular Value Decomposition (SVD), A=UΣVT, provides a related but more general way to decompose any matrix A, whether square or rectangular. The connection between SVD and eigen-decomposition becomes clear when we consider the matrices ATA and AAT. These matrices are always square and symmetric (or more precisely, positive semi-definite), which means their eigen-decomposition is well-behaved.
Let's see how the components of SVD (U, Σ, V) relate to the eigen-decomposition of these specific matrices.
Consider the matrix ATA. Let's substitute the SVD of A into this expression: A=UΣVT AT=(UΣVT)T=VΣTUT
Now, multiply AT by A: ATA=(VΣTUT)(UΣVT)
Since U is an orthogonal matrix, UTU=I (the identity matrix). The expression simplifies: ATA=VΣT(UTU)ΣVT ATA=V(ΣTΣ)VT
Look closely at this result: ATA=V(ΣTΣ)VT. This is exactly the form of an eigen-decomposition for the symmetric matrix ATA.
What are the diagonal entries of ΣTΣ? If Σ has the singular values σ1,σ2,...,σr on its diagonal (where r is the rank of A), then ΣTΣ is an n×n diagonal matrix with σ12,σ22,...,σr2 followed by zeros on its diagonal.
So, the right singular vectors of A (the columns of V) are the eigenvectors of ATA. The squared singular values of A (σi2) are the eigenvalues of ATA.
Now let's perform a similar analysis for the matrix AAT: AAT=(UΣVT)(VΣTUT)
Since V is also an orthogonal matrix, VTV=I. The expression simplifies: AAT=UΣ(VTV)ΣTUT AAT=U(ΣΣT)UT
Again, this result AAT=U(ΣΣT)UT is the eigen-decomposition for the symmetric matrix AAT.
The diagonal entries of ΣΣT are also the squared singular values σ12,σ22,...,σr2, followed by zeros (this time it's an m×m matrix).
So, the left singular vectors of A (the columns of U) are the eigenvectors of AAT. The squared singular values of A (σi2) are also the eigenvalues of AAT.
SVD Component (A=UΣVT) | Relationship to Eigen-decomposition |
---|---|
Singular Values (σi) | Square roots of non-zero eigenvalues of ATA (and AAT) |
Right Singular Vectors (V) | Eigenvectors of ATA |
Left Singular Vectors (U) | Eigenvectors of AAT |
This relationship is significant for several reasons:
Let's verify this relationship using Python's NumPy library. We'll create a sample matrix A, compute its SVD, and then compute the eigen-decompositions of ATA and AAT to see if the components match as expected.
import numpy as np
# Set print options for better readability
np.set_printoptions(suppress=True, precision=4)
# Create a sample non-square matrix A
A = np.array([[1, 2, 3],
[4, 5, 6]]) # A is 2x3
print("Matrix A:\n", A)
# 1. Compute SVD of A
# U will be 2x2, S will contain 2 singular values, Vh (V.T) will be 3x3
U, s, Vh = np.linalg.svd(A)
V = Vh.T # Transpose Vh to get V
Sigma_squared = s**2
print("\nSVD Results:")
print("U (Left Singular Vectors):\n", U)
print("Singular Values (s):", s)
print("Sigma^2 (Squared Singular Values):", Sigma_squared)
print("V (Right Singular Vectors):\n", V)
# 2. Compute Eigen-decomposition of A.T @ A (A^T A)
ATA = A.T @ A # ATA is 3x3
print("\nMatrix A^T A:\n", ATA)
# Use eigh for symmetric matrices (returns sorted eigenvalues/vectors)
eigenvalues_ATA, eigenvectors_ATA = np.linalg.eigh(ATA)
# Eigenvalues from eigh are sorted smallest to largest, reverse them
eigenvalues_ATA = eigenvalues_ATA[::-1]
eigenvectors_ATA = eigenvectors_ATA[:, ::-1]
print("\nEigen-decomposition of A^T A:")
print("Eigenvalues (should match Sigma^2):", eigenvalues_ATA)
print("Eigenvectors (should match columns of V):\n", eigenvectors_ATA)
# 3. Compute Eigen-decomposition of A @ A.T (A A^T)
AAT = A @ A.T # AAT is 2x2
print("\nMatrix A A^T:\n", AAT)
eigenvalues_AAT, eigenvectors_AAT = np.linalg.eigh(AAT)
# Reverse sort order for consistency
eigenvalues_AAT = eigenvalues_AAT[::-1]
eigenvectors_AAT = eigenvectors_AAT[:, ::-1]
print("\nEigen-decomposition of A A^T:")
print("Eigenvalues (should match Sigma^2):", eigenvalues_AAT)
print("Eigenvectors (should match columns of U):\n", eigenvectors_AAT)
# Verification Checks (allowing for small numerical differences)
print("\nVerification:")
# Check eigenvalues
print("Sigma^2 matches eigenvalues of A^T A (approx):", np.allclose(Sigma_squared, eigenvalues_ATA[:len(s)]))
print("Sigma^2 matches eigenvalues of A A^T (approx):", np.allclose(Sigma_squared, eigenvalues_AAT[:len(s)]))
# Check eigenvectors (Note: Eigenvectors are unique only up to sign)
# Check if columns of V match eigenvectors_ATA (or their negative)
print("Columns of V match eigenvectors of A^T A (approx):",
np.allclose(np.abs(V[:, :len(s)]), np.abs(eigenvectors_ATA[:, :len(s)])))
# Check if columns of U match eigenvectors_AAT (or their negative)
print("Columns of U match eigenvectors of A A^T (approx):",
np.allclose(np.abs(U), np.abs(eigenvectors_AAT)))
Running this code demonstrates the connection:
Remember that eigenvectors (and singular vectors) are unique only up to a sign (±1). So, when comparing vectors like V and the eigenvectors of ATA, you might find that some corresponding columns are negatives of each other. This is perfectly normal and np.allclose
comparing absolute values handles this.
This deep connection between SVD and eigen-decomposition solidifies SVD as a fundamental tool. It leverages the well-understood properties of symmetric matrix eigen-decomposition to provide a powerful decomposition for any matrix, with direct applications in understanding data structure, dimensionality reduction, and more.
© 2025 ApX Machine Learning