Singular Value Decomposition Calculator
Enter a real matrix A. The calculator computes its thin SVD.
Matrix A
Decomposition Results
The thin singular value decomposition is \(A=U\Sigma V^T\).
Matrix U
Left singular vectors; orthonormal columns.
Matrix Σ (Sigma)
Diagonal matrix of singular values.
Matrix Vᵀ
Transpose of the right singular-vector matrix.
Reconstruction: UΣVᵀ
This product should reproduce the original matrix A, up to numerical rounding.
Orthogonality checks
Calculation details
What Is Singular Value Decomposition?
Singular Value Decomposition, usually abbreviated as SVD, is a factorization that expresses a real matrix as the product of three matrices. It is one of the most useful decompositions in numerical linear algebra because it applies to square and rectangular matrices, including matrices that are singular or rank-deficient.
For an \(m\times n\) matrix A, the thin SVD has the following dimensions:
| Matrix | Dimensions | Meaning |
|---|---|---|
| A | \(m\times n\) | Original matrix |
| U | \(m\times k\) | Left singular vectors |
| Σ | \(k\times k\) | Diagonal singular-value matrix |
| Vᵀ | \(k\times n\) | Transpose of right singular vectors |
Here, \(k=\min(m,n)\).
1. Matrix U: left singular vectors
The columns of U are left singular vectors. They are orthonormal, which means that each column has unit length and different columns are perpendicular to one another.
2. Matrix Σ: singular values
Sigma is a diagonal matrix. Its diagonal entries are the singular values of A, conventionally written in descending order:
The singular values measure how strongly the matrix stretches space in particular directions. A zero singular value indicates a lost dimension in the transformation.
3. Matrix V: right singular vectors
The columns of V are right singular vectors. They are also orthonormal. The calculator displays \(V^T\), the transpose of V.
The second identity above describes the full square V matrix. In a thin SVD, V has dimensions \(n\times k\), so its columns are orthonormal and \(V^TV=I_k\).
How the SVD Is Calculated
This simulator uses a one-sided Jacobi method. It repeatedly applies orthogonal rotations to pairs of columns of A until those columns are approximately mutually orthogonal.
Set \(B=A\) and initialize \(V=I_n\).
For a pair of columns p and q, calculate their squared lengths and inner product. Apply a Jacobi rotation to reduce their inner product toward zero. Apply the same rotation to V.
Once the columns are sufficiently orthogonal, their Euclidean lengths give the singular values:
\[ \sigma_j=\|b_j\|_2 \]Arrange the singular values in descending order and rearrange the corresponding columns of B and V in the same order.
For each nonzero singular value, normalize its corresponding column of B to obtain a column of U. Form Sigma from the singular values and transpose V.
Worked Example: A 2 × 2 Matrix
Consider the matrix:
This matrix is already diagonal, with positive diagonal entries. One valid SVD is:
Multiplying the three factors gives:
The singular values are 3 and 2. The matrix stretches vectors by a factor of 3 in one coordinate direction and by a factor of 2 in the other.
Matrix Rank, Condition Number and Pseudoinverse
Numerical rank
The rank of a matrix is the number of linearly independent rows or columns. It is also the number of nonzero singular values in the exact mathematical decomposition.
In numerical computation, a tolerance is used to decide whether a small singular value should be considered zero.
Condition number
For a matrix with full rank, the 2-norm condition number is the ratio of its largest singular value to its smallest singular value:
A large condition number indicates that a problem may be sensitive to small changes in its input. A rank-deficient matrix has an infinite condition number under this definition.
Moore-Penrose pseudoinverse
The pseudoinverse extends the idea of a matrix inverse to rectangular and singular matrices. It can be constructed from the SVD by transposing the singular-vector factors and replacing nonzero singular values with their reciprocals.
For a system \(Ax=b\), the pseudoinverse gives the minimum-norm least-squares solution:
This is useful when a system has no exact solution, has multiple solutions, or has a rectangular coefficient matrix.
Applications of Singular Value Decomposition
1. Dimensionality reduction
SVD is central to Principal Component Analysis (PCA). Large singular values often capture the most important directions in a dataset, making it possible to represent data using fewer dimensions.
2. Image compression
An image can be represented as a matrix. Keeping only the largest singular values and their corresponding singular vectors can produce a lower-rank approximation that uses less storage.
3. Least-squares problems
The pseudoinverse derived from SVD can find least-squares solutions to overdetermined systems and minimum-norm solutions to underdetermined systems.
4. Noise reduction
Small singular components may represent noise in some applications. Truncating selected components can produce a smoother, lower-rank approximation of the original data.
5. Recommender systems
User-item rating matrices can be approximated with lower-rank factors. These factors can reveal latent patterns and help estimate missing preferences.
Frequently Asked Questions
What does SVD stand for?
SVD stands for Singular Value Decomposition. It is a matrix factorization that expresses a matrix as \(U\Sigma V^T\).
Can SVD be used for rectangular matrices?
Yes. Unlike some matrix factorizations, SVD works for rectangular matrices as well as square matrices. This makes it useful for data analysis, image processing and least-squares problems.
Are singular values always positive?
Singular values are always nonnegative. They can be zero when the matrix is rank-deficient.
What is the difference between eigenvalues and singular values?
Eigenvalues are defined for square matrices and may be negative or complex. Singular values are nonnegative real numbers and are defined for every real or complex rectangular matrix.
Is U always a square matrix?
The full SVD uses a square orthogonal U matrix. The thin SVD displayed by this calculator uses only the first \(k=\min(m,n)\) columns, so U has dimensions \(m\times k\).
Why might two SVD calculators show different U and V matrices?
Singular vectors are not always unique. In particular, the signs of corresponding columns of U and V can both be reversed without changing the product \(U\Sigma V^T\). Different valid algorithms may therefore display different factor matrices while reconstructing the same original matrix.
What is a truncated SVD?
A truncated SVD keeps only a selected number of the largest singular values and their corresponding singular vectors. It provides a lower-rank approximation of the original matrix.
Related Matrix Calculators
Continue exploring matrix operations and numerical linear algebra.
Matrix Multiplication Simulator → Eigenvalue & Eigenvector Simulator → Gaussian Elimination Simulator → LU Decomposition Simulator → Matrix Iteration Simulator →