Interactive Linear Algebra Tool

SVD Calculator & Simulator

Explore the Singular Value Decomposition of a matrix. Calculate its singular values and factor matrices, reconstruct the original matrix, estimate its rank, and solve linear systems using the pseudoinverse.

Rectangular matrices U, Σ and Vᵀ Singular values Matrix rank Pseudoinverse

Singular Value Decomposition Calculator

Enter a real matrix A. The calculator computes its thin SVD.

Free calculator

Matrix A

When selected, enter a vector b with one value for each row of A.

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.

\[ \boxed{A=U\Sigma V^T} \]

For an \(m\times n\) matrix A, the thin SVD has the following dimensions:

MatrixDimensionsMeaning
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.

\[ U^TU=I_k \]

2. Matrix Σ: singular values

Sigma is a diagonal matrix. Its diagonal entries are the singular values of A, conventionally written in descending order:

\[ \sigma_1\geq\sigma_2\geq\cdots\geq\sigma_k\geq0 \]

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.

\[ V^TV=I_k \quad\text{and}\quad VV^T=I_n \]

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.

Step 1 — Start with the input matrix.

Set \(B=A\) and initialize \(V=I_n\).

Step 2 — Orthogonalize column pairs.

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.

\[ \begin{aligned} \alpha &= b_p^Tb_p\\ \beta &= b_q^Tb_q\\ \gamma &= b_p^Tb_q \end{aligned} \] The rotation is selected so that the transformed columns are more nearly orthogonal.
Step 3 — Calculate singular values.

Once the columns are sufficiently orthogonal, their Euclidean lengths give the singular values:

\[ \sigma_j=\|b_j\|_2 \]
Step 4 — Sort the singular values.

Arrange the singular values in descending order and rearrange the corresponding columns of B and V in the same order.

Step 5 — Construct U, Σ and Vᵀ.

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.

Numerical algorithms use tolerances because floating-point arithmetic cannot represent every real number exactly. Very small singular values may be treated as zero when estimating numerical rank.

Worked Example: A 2 × 2 Matrix

Consider the matrix:

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

This matrix is already diagonal, with positive diagonal entries. One valid SVD is:

\[ U=\begin{bmatrix}1&0\\0&1\end{bmatrix}, \qquad \Sigma=\begin{bmatrix}3&0\\0&2\end{bmatrix}, \qquad V^T=\begin{bmatrix}1&0\\0&1\end{bmatrix} \]

Multiplying the three factors gives:

\[ U\Sigma V^T= \begin{bmatrix}3&0\\0&2\end{bmatrix}=A \]

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.

\[ \operatorname{rank}(A)= \#\{i:\sigma_i\text{ is nonzero}\} \]

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:

\[ \kappa_2(A)=\frac{\sigma_{\max}}{\sigma_{\min}} \]

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.

\[ A^+=V\Sigma^+U^T \] \[ \Sigma^+_{ii}= \begin{cases} 1/\sigma_i,&\sigma_i\text{ is retained}\\ 0,&\text{otherwise} \end{cases} \]

For a system \(Ax=b\), the pseudoinverse gives the minimum-norm least-squares solution:

\[ x=A^+b \]

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 →