SVD Calculator - Singular Value Decomposition
Enter your matrix row by row to decompose it as A = U * Sigma * V^T. The calculator returns the three factor matrices, the singular values, the matrix rank, and the condition number. Step-by-step working shows exactly how each stage is computed. Choose 2x2 or 3x3 mode, adjust decimal precision, and see a visual comparison of the singular values as a horizontal bar chart.
What is singular value decomposition?
Singular value decomposition (SVD) is one of the most fundamental factorizations in linear algebra. Any real m x n matrix A can be written as A = U * Sigma * V^T, where U is an m x m orthogonal matrix (columns are the left singular vectors), Sigma is an m x n diagonal matrix whose non-negative diagonal entries are the singular values, and V^T is the n x n transpose of an orthogonal matrix (rows are the right singular vectors). The singular values appear in Sigma in descending order, and they tell you how much the transformation A "stretches" space along each of the principal directions. This decomposition always exists for any real matrix, regardless of whether it is square or rectangular.
How to compute SVD step by step
The standard algorithm works in six stages. First, form the n x n matrix B = A^T * A, which is always symmetric and positive semi-definite. Second, find all eigenvalues and eigenvectors of B, using Jacobi iteration or the QR algorithm for numerical stability. Third, the singular values are the square roots of the eigenvalues of B, sorted from largest to smallest. Fourth, the columns of V are the corresponding unit eigenvectors. Fifth, compute each left singular vector as u_i = (1 / sigma_i) * A * v_i for each non-zero singular value. Sixth, extend U with orthonormal vectors if needed (when A has more rows than non-zero singular values). This calculator uses the Jacobi eigen-decomposition method, which is highly stable for symmetric matrices.
Singular values, rank, and the condition number
The number of non-zero singular values equals the rank of the matrix. A matrix is invertible if and only if all its singular values are non-zero. The condition number, defined as the ratio of the largest to the smallest singular value, measures numerical sensitivity: a condition number close to 1 means tiny changes in A cause tiny changes in the solution, while a large condition number signals that the problem is ill-posed. When the condition number exceeds the reciprocal of machine precision (roughly 10^15 for double-precision arithmetic), the matrix is effectively singular in practice.
Applications of SVD
SVD underpins a remarkable range of applications. In data science and machine learning, it drives principal component analysis (PCA), dimensionality reduction, and latent semantic indexing for text search. In signal processing, it is used for noise reduction by discarding small singular values. In image compression, storing only the k largest singular values and their vectors recovers the dominant structure of an image at a fraction of the storage cost. In statistics, the pseudo-inverse (Moore-Penrose inverse) A+ = V * Sigma+ * U^T, where Sigma+ replaces each non-zero diagonal with its reciprocal, is computed directly from the SVD and gives the minimum-norm least-squares solution to any linear system.
What the condition number tells you
| Condition number | Interpretation | Reliability |
|---|---|---|
| 1 | Perfectly conditioned (orthogonal matrix) | Excellent |
| 1 - 10 | Well-conditioned | Very good |
| 10 - 100 | Moderately conditioned | Good |
| 100 - 1,000 | Mildly ill-conditioned | Fair |
| 1,000 - 1,000,000 | Ill-conditioned | Poor |
| > 1,000,000 | Near-singular (rank-deficient numerically) | Unreliable |
The condition number kappa = sigma_max / sigma_min measures how numerically stable the matrix is for solving linear systems.
Frequently asked questions
What does A = U * Sigma * V^T mean?
It means your matrix A is decomposed into three matrices: U, a matrix of left singular vectors that form an orthonormal basis for the column space; Sigma, a diagonal matrix whose entries are the singular values (non-negative scalars); and V^T, the transpose of a matrix of right singular vectors forming an orthonormal basis for the row space. Multiplying these three together exactly reconstructs A.
Is the SVD unique?
Not entirely. The singular values in Sigma are unique and appear in descending order. However, the columns of U and V are not unique: you can flip the sign of any pair (column of U, row of V^T) without changing the product. When singular values are repeated, the corresponding singular vectors can be any orthonormal set within the associated eigenspace.
What does the condition number tell me?
The condition number is the ratio of the largest to the smallest singular value. It measures how sensitive the matrix equation Ax = b is to small perturbations. A condition number near 1 is ideal. If the condition number is kappa and you have about d significant digits of precision in your data, you can expect to lose about log10(kappa) digits of accuracy in the solution.
How is rank related to the singular values?
The rank of a matrix equals the number of its non-zero singular values. In exact arithmetic a singular value of zero means the matrix is rank-deficient, but in floating-point arithmetic any singular value much smaller than the largest one (typically sigma_i / sigma_1 < n * machine epsilon) is usually treated as effectively zero.
Can SVD be used for image compression?
Yes. Represent the image as a matrix of pixel values. Compute the SVD to get U, Sigma, and V^T. Keep only the k largest singular values and the corresponding k columns of U and k rows of V^T. The product of these reduced matrices is a rank-k approximation of the original image that captures the dominant structure at much lower storage cost. The error of this approximation equals sigma_{k+1}, the first discarded singular value.
What is the pseudo-inverse and how is it computed from the SVD?
The Moore-Penrose pseudo-inverse A+ gives the minimum-norm least-squares solution to Ax = b. You compute it from the SVD as A+ = V * Sigma+ * U^T, where Sigma+ replaces each non-zero diagonal entry with its reciprocal. It equals the ordinary inverse when A is square and full-rank.