Singular Value Decomposition (SVD) Calculator
Factorize a real matrix into its singular value decomposition A = UΣVT, where U and V are orthogonal matrices and Σ contains the singular values. SVD is widely used in dimensionality reduction, least-squares problems, numerical analysis, and data compression.
A
Learn About Singular Value Decomposition (SVD)
The Singular Value Decomposition (SVD) is the most general and informative matrix factorization in numerical linear algebra. Unlike eigenvalue decomposition, which applies only to square matrices, SVD exists for every real matrix $\mathbf{A} \in \mathbb{R}^{m \times n}$:
where:
- $\mathbf{U} \in \mathbb{R}^{m \times m}$ is an orthogonal matrix ($\mathbf{U}^T\mathbf{U} = \mathbf{I}_m$) whose columns $\mathbf{u}_i$ are the left singular vectors.
- $\mathbf{\Sigma} \in \mathbb{R}^{m \times n}$ is a rectangular diagonal matrix whose non-negative diagonal elements $\sigma_1 \ge \sigma_2 \ge \dots \ge \sigma_{\min(m, n)} \ge 0$ are the singular values.
- $\mathbf{V} \in \mathbb{R}^{n \times n}$ is an orthogonal matrix ($\mathbf{V}^T\mathbf{V} = \mathbf{I}_n$) whose columns $\mathbf{v}_i$ are the right singular vectors.
Geometric Meaning: The Sphere-to-Ellipsoid Transformation
Geometrically, any linear transformation $\mathbf{x} \mapsto \mathbf{A}\mathbf{x}$ maps the unit sphere $\{\mathbf{x} \in \mathbb{R}^n : \|\mathbf{x}\|_2 = 1\}$ into a hyper-ellipsoid in $\mathbb{R}^{m}$:
- The right singular vectors $\mathbf{v}_1, \dots, \mathbf{v}_n$ form an orthonormal basis for the domain $\mathbb{R}^n$, specifying which directions in the sphere map to the principal axes of the ellipsoid.
- The singular values $\sigma_1, \dots, \sigma_r$ represent the lengths of the semi-axes of the resulting hyper-ellipsoid.
- The left singular vectors $\mathbf{u}_1, \dots, \mathbf{u}_m$ form an orthonormal basis for the codomain $\mathbb{R}^m$, aligning with the directions of the principal axes.
Connection to Gram Matrices $\mathbf{A}^T\mathbf{A}$ and $\mathbf{A}\mathbf{A}^T$
The components of the SVD are derived directly from the symmetric positive semi-definite Gram matrices:
- The right singular vectors $\mathbf{v}_i$ are orthonormal eigenvectors of $\mathbf{A}^T\mathbf{A}$.
- The left singular vectors $\mathbf{u}_i$ are orthonormal eigenvectors of $\mathbf{A}\mathbf{A}^T$, related by $\mathbf{u}_i = \frac{1}{\sigma_i}\mathbf{A}\mathbf{v}_i$ for $\sigma_i > 0$.
- The singular values are the non-negative square roots of the eigenvalues: $\sigma_i = \sqrt{\lambda_i(\mathbf{A}^T\mathbf{A})}$.
Outer Product Expansion and Low-Rank Approximation
In dyadic (sum of rank-one matrices) form:
where $r = \operatorname{rank}(\mathbf{A})$. By the Eckart-Young-Mirsky Theorem, truncating this sum to $k < r$ terms yields the optimal rank-$k$ approximation $\mathbf{A}_k = \sum_{i=1}^k \sigma_i \mathbf{u}_i \mathbf{v}_i^T$, minimizing approximation error in both the Frobenius norm and spectral 2-norm.
Worked Numerical Example
Compute the SVD of the symmetric $2 \times 2$ matrix:
- Form the Gram Matrix $\mathbf{A}^T\mathbf{A}$:
- Find Eigenvalues and Singular Values:
Solve $\det(\mathbf{A}^T\mathbf{A} - \lambda \mathbf{I}) = (10 - \lambda)^2 - 36 = 0$:
The singular values are:
- Find Normalized Right Singular Vectors $\mathbf{V}$:
- For $\lambda_1 = 16$: $(\mathbf{A}^T\mathbf{A} - 16\mathbf{I})\mathbf{v} = \begin{bmatrix} -6 & 6 \\ 6 & -6 \end{bmatrix}\mathbf{v} = \mathbf{0} \implies \mathbf{v}_1 = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\ 1 \end{bmatrix}$.
- For $\lambda_2 = 4$: $(\mathbf{A}^T\mathbf{A} - 4\mathbf{I})\mathbf{v} = \begin{bmatrix} 6 & 6 \\ 6 & 6 \end{bmatrix}\mathbf{v} = \mathbf{0} \implies \mathbf{v}_2 = \frac{1}{\sqrt{2}}\begin{bmatrix} -1 \\ 1 \end{bmatrix}$.
- Compute Left Singular Vectors $\mathbf{U}$:
- Verify Factorization $\mathbf{U}\mathbf{\Sigma}\mathbf{V}^T = \mathbf{A}$:
How does SVD differ from eigenvalue decomposition?
Eigenvalue decomposition $\mathbf{A} = \mathbf{P}\mathbf{D}\mathbf{P}^{-1}$ applies only to square matrices that possess a complete set of linearly independent eigenvectors, and $\mathbf{P}$ is generally not orthogonal. SVD applies to any matrix—square or rectangular, full-rank or singular—and always uses orthogonal matrices $\mathbf{U}$ and $\mathbf{V}$, ensuring numerical stability.
Why are singular values always non-negative real numbers?
Because $\mathbf{A}^T\mathbf{A}$ is a symmetric positive semi-definite matrix, its eigenvalues are guaranteed to be real and non-negative: $\lambda_i \ge 0$. The singular values are defined as $\sigma_i = \sqrt{\lambda_i}$, which ensures they are non-negative real numbers regardless of whether $\mathbf{A}$ contains negative or complex entries.
How does SVD compute the Moore-Penrose pseudoinverse?
Using the SVD $\mathbf{A} = \mathbf{U}\mathbf{\Sigma}\mathbf{V}^T$, the pseudoinverse is computed by inverting the non-zero singular values: $\mathbf{A}^+ = \mathbf{V}\mathbf{\Sigma}^+\mathbf{U}^T$. In $\mathbf{\Sigma}^+$, each non-zero singular value $\sigma_i$ is replaced by $\frac{1}{\sigma_i}$ and the matrix is transposed.
What is the relationship between SVD and Principal Component Analysis (PCA)?
PCA is mathematically equivalent to the SVD of a mean-centered data matrix $\mathbf{X} \in \mathbb{R}^{m \times n}$. The right singular vectors $\mathbf{V}$ are the principal component loading directions (eigenvectors of sample covariance matrix $\frac{1}{m-1}\mathbf{X}^T\mathbf{X}$), and the singular values determine the variance explained by each principal component: $\operatorname{Var}_i = \frac{\sigma_i^2}{m-1}$.
- Independent 19th-Century Discoverers: Italian geometer Eugenio Beltrami (1873) and French mathematician Camille Jordan (1874) independently discovered SVD for square bilinear forms. British mathematician James Joseph Sylvester (1889) rediscovered it, and American mathematical psychologists Carl Eckart and Gale Young (1936) extended the formulation to rectangular matrices.
- The Condition Number: The numerical sensitivity of any linear system $\mathbf{A}\mathbf{x} = \mathbf{b}$ to roundoff error is governed by its matrix condition number $\kappa(\mathbf{A}) = \frac{\sigma_{\max}}{\sigma_{\min}}$. When $\sigma_{\min} = 0$, the matrix is singular and the condition number is infinite.