You are on page 1of 25
Singular value decomposition From Wikipedia, the free encyclopedia In linear algebra, the singular value decomposition (SVD) is 2 factorization of a real or complex matrix, with many useful applications in signal processing and statistics Formally, the singular value decomposition of an m>n real or complex matrix M is a factorization of the form M=UXV’", Where U is an mm real or complex unitary matrix, Bis an m*n 5,3, diagonal matrix with nonnegative real numbers on the diagonal, SS and V* (the conjugate transpose of F) is an nn real or complex Pas Pha unitary matrix. The diagonal entries ¥,, of ¥ are known as the singular values of M. The m columns of U and the n columns of V are called the left singular veetors and right singular veetors of -M, respectively. Visualization ofthe SVD ofa 2-dimensional, real shearing matrix M, First, we see the nit disc in blue together withthe wo canonical unit vectors We then see the action of M, which distorts the Singular value decomposition and cigendecomposition are closely _diskto anclipse. The SVD decomposes M into related. Namely: three simple transformations: a rotation Va sealing along the rotated coordinate axes anda » The left singular vectors of M are eigenvectors of second rotation U. The lengths 0 and op of he MM* semi-axes ofthe ellipse are the singular values of » The right singular vectors of M are eigenvectors of M. M*M. » The non-zero singular values of S are the square roots of the non-zero eigenvalues of M* Mor MM* Applications which employ the SVD include computing the pseudoinverse, least squares fitting of data, matrix: approximation, and determining the rank, range and mull space of a matrix. Contents = 1 Statement of the theorem 2 Intuitive interpretations * 2.1 Rotation, sealing, rotation = 2.2 Singular values as semiaxis of an ellipse or ellipsoid = 2.3 Uand V are orthogonal bases = 3 Example 1 4 Singular values, singular vectors, and their relation to the SVD tions of the SVD 5.1 Pseudoinverse 5.2 Solving homogeneous linear equations 53 Total least squares minimization 54 Range, null space and rank 5.5 Low-rank matrix approximation 5.6 Separable models = 5.7 Neatest orthogonal matrix = 5.8 The Kabsch Algorithm = 5.9 Other examples * 6 Relation to eigenvalue decomposition = 7 Existence 1 7.1 Based on the spectral theorem = 7.2 Based on variational characterization = 8 Geometric meaning = 9 Calculating the SVD = 9.1 Numerical Approach = 9.2 Analytic Result of 2-by-2 SVD = 10 Reduced SVDs = 10.1 Thin SVD = 10.2 Compact SVD = 10.3 Truncated SVD = 11 Norms = 11.1 Ky Fan norms = 11.2 Hilbert-Schmidt norm = 12 Tensor SVD = 13 Bounded operators on Hilbert spaces ‘13.1 Singular values and compact operators © 14 History = 15 See also = 16 Notes = 17 References = 18 External links = 18.1 Implementations = 18.1.1 Libraries that support complex and real SVD = 18.1.2 Libraries that support real SVD = 18.2 Texts and demonstrations = 183 Songs Statement of the theorem ‘Suppose Mis an mn matrix whose entries come from the field K, which is either the field of real numbers or the field of complex numbers. Then there exists a factorization of the form M=UxVv" where U is an m*m unitary matrix over K, the matrix ¥ is an mxn diagonal matrix with nonnegative real numbers on the diagonal, and *, an nn unitary matrix over K, denotes the conjugate transpose of V. Such a factorization is called the singular value decomposition of M. The diagonal entries ¥,,; of Z are known as the singular values of M. A common convention is to list the singular values in descending order. In this case, the diagonal matrix © is uniquely determined by M (though the matrices U and V are not), Intuitive interpretations Rotation, scaling, rotation In the special but common case in which M is just an mm square matrix with positive determinant whose entries are plain real numbers, then U, V*, and E are mm matrices of real numbers as well, © can be regarded as a sealing matrix, and Uand V* can be viewed as rotation matrices. If the above mentioned conditions are met, the expression []S)]/* can thus be intuitively interpreted as a composition (or sequence) of three geometrical transformations: a rotation, a scaling, and another rotation, For instance, the figure above explains how a shear matrix can be described as such a sequence. Singular values as semiaxis of an ellipse or ellipsoid ‘As shown in the figure, the singular values can be interpreted as the semiaxes of an ellipse in 2-D. This concept can be generalized to n-dimensional Euclidean space, with the singular values of any nn square matrix being viewed as the semiaxes of an n-dimensional ellipsoid. See below for further details. U and V are orthogonal bases Since U and ¥* are unitary, the columns of each of them form a set of orthonormal vectors, which ean be regarded as basis vectors. By the definition of unitary matrix, the same is true for their conjugate transposes U* and V. In short, U, U*, V, and ¥* are orthogonal bases. Example Consider the 4%5 matrix oF oo wo oo ooonN, A singular value decomposition of this matrix is given by ULV * 001 0 40 0 00 ; tte ° 0100 03 0 00 y= De =|Vv A U 000 -1\°= 00 vB00 ve tae . 100 0 00 000 _-J0B 000 VOd Notice ¥ contains only zeros outside of the diagonal. Furthermore, because the matrices U and V * are unitary, multiplying by their respective conjugate transposes yields identity matrices, as shown below, In this case, because Uand V™ are real valued, they each are an orthogonal matrix, 001 07 foo of 1000 y~_]0 10 0] Jo1 0 of _Jo1do w= ly 9 0 1] ]1 0 0 of =]o 0 1 of =” 100 0} joo o} fo oo1 and 00 Yo2 0 -VO8 0 100 0 10000 10 0 0 0 0 010 0 01000 vwr=]01 0 0 O ]-| 2 000 Ys} =]0 010 OJ = 00 0 1 0 0 001 0 00010 00 VO8 0 VO2} |-v08s 000 VO2 oooo01 It should also be noted that this particular singular value decomposition is not unique. Choosing V such that 0 10°00 0 0 01 0 0 =|v02 00 0 Vos vod 0 0 VO5 -VOT -vi4 00 ¥05 VOT is also a valid singular value decomposition. Singular values, singular vectors, and their relation to the SVD Annon-negative real number o is a singular value for M if and only if there exist unit-length vectors w in "and v in K" such that Mv = ou and Mtu=av The vectors u and v are called left-singular and right-singular vectors for o, respectively. In any singular value decomposition M=vUyVv* the diagonal entries of ¥ are equal to the singular values of M. The columns of U and V are, respectively, left- and right-singular vectors for the corresponding singular values. Consequently, the above theorem implies that: = An mn matrix M has at least one and at most p = min(m,n) distinct singular values. = It is always possible to find an orthogonal basis U for K" consisting of left-singular vectors of M. = Itis always possible to find an orthogonal basis V’ for A" consisting of right-singular vectors of M. A singular value for which we can find two left (or right) singular vectors that are linearly dependent is called degenerate. Non-degenerate singular values always have unique left and right singular vectors, up to multiplication by a unit phase factor el? (for the real case up to sign). Consequently, if all singular values of M are non-degenerate and non- zero, then its singular value decomposition is unique, up to multiplication of a column of U by a unit phase factor and simultaneous multiplication of the corresponding column of V by the same unit phase factor. Degencrate singular values, by definition, have non-unique singular vectors. Furthermore, if wy and up are two left- singular vectors which both correspond to the singular value o, then any normalized lincar combination of the two vectors is also a left singular vector corresponding to the singular value 6, The similar statement is true for right singular vectors. Consequently, if M has degenerate singular values, then its singular value decomposition is not unique, Applications of the SVD Pseudoinverse The singular value decomposition can be used for computing the pseudoinverse of a matrix, Indeed, the pscudoinverse of the matrix M with singular value decomposition M = ULV" is M*=VvrrU" where ©: is the pseudoinverse of E, which is formed by replacing every nonzero diagonal entry by its reciprocal and transposing the resulting matrix, The pscudoinverse is one way to solve linear least squares problems, Solving homogeneous linear equations A set of homogeneous linear equations can be written as A x = (for a matrix A and vector x. A typical situation is that Ais known and a non-zero X is to be determined which satisfies the equation. Such an xX belongs (o A's null space and is sometimes called a (right) null vector of A. x can be characterized as a right singular vector corresponding to a singular value of A that is zero. This observation means that if A is a square matrix and has no vanishing singular value, the equation has no non-zero X as a solution, It also means that if there are several vanishing singular values, any linear combination of the corresponding right singular vectors is a valid solution. Analogously to the definition of a (right) null vector, a non-zero x satisfying x* A — (} with x* denoting the conjugate transpose of x, is called a left null vector of A. Total least squares minimization A total least squares problem refers to determining the vector x which minimizes the 2-norm of a vector A under the constrain [x] = 1. The solution turns out to be the right singular vector of \ corresponding to the smallest singular value. Range, null space and rank Another application of the SVD is that it provides an explicit representation of the range and null space of a matrix M. The right singular vectors corresponding to vanishing singular values of M span the null space of M. F.g., the null space is spanned by the last two columns of Vin the above example. The left singular vectors corresponding to the non-zero singular values of M span the range of M. As a consequence, the rank of M equals the number of non-zero singular values which is the same as the number of non-zero diagonal elements in E. In numerical linear algebra the singular values can be used to determine the effective rank of a matrix, as rounding error may lead to small but non-zero singular values in a rank deficient matrix. Low-rank matrix approximation Some practical applications need to solve the problem of approximating a matrix M with another matrix jy which has a specific rank r. In the case that the approximation is based on minimizing the Frobenius norm of the difference between M and iy under the constraint that rank( A) — rit tums out that the solution is given by the SVD of M, namely M=USV* where Sis the same matrix as E except that it contains only the r largest singular values (the other singular values are replaced by zero). This is known as the Eekart-Young theorem, as it was proved by those two authors in 1936 (although it was later found to have been known to earlier authors; see Stewart 1993). Quick proof: We hope to minimize || MF — fl] Subject rank(WD) — rv Suppose the SVD of M= UEV " . Since the Frobenius norm is unitary invariant, we have an equivalent statement: min |Z —U"MV le w Note that since & is diagonal, ¢7* 777 should be diagonal in order to minimize the Frobenius norm, Remember that the Frobenius norm is the square-root of the summation of the squared modulus of all entries. This implies that Vand V are also singular matrices of yj. Thus we can assume that jf to minimize the above statement has the form: M=USV* where S is diagonal, The diagonal entries 5; of S are not necessarily ordered as in SVD. min |S — Slr Mt From the rank constraint, ic. Shas F non-zero diagonal entries, the minimum of the above statement is obtained as follows: a inh Therefore, Jf of rank ris the best approximation of M in the Frobenius norm sense when a; =; (i =1,....,r)and the corresponding singular vectors are same as those of M. Separable models The SVD can be thought of as decomposing a matrix into a weighted, ordered sum of separable matrices. By separable, we mean that a matrix A. can be written as an outer product of two vectors A. = uy @ vs OF in coordinates, A (i, 7) = u(é)v(7) Specifically, the matrix M can be decomposed as: M=S0A=Sotiay Here U; and V;are the t* columns of the corresponding SVD matrices, 0} are the ordered singular values, and each A, is separable. The SVD can be used to find the decomposition of an image processing filter into separable horizontal and vertical filters"! Note that the number of non-zcr0 6; is exactly the rank of the matrix Separable models often a sein biological systems, and the SVD decomposition is useful to analyze such systems, For example, some visuel arca V1 simple cells receptive fields can be well described! by a Gabor filter in the space domain multiplied by ¢ modulation function in the time domain. Thus, given a linear filter evaluated through, for example, reverse correlation, one can rearrange the two spatial dimensions into one dimension, thus yielding a two dimensional filter (space, time) which can be decomposed through SVD. The first column of U in the SVD decomposition is then a Gabor while the first column of V represents the time modulation (or vice-versa). One may 2) Sg? then define an index of separability,” = 71/9 77, which isthe faction of the power in the matrix M which is accounted for by the fist separable matrix in the decomposition 8] Nearest orthogonal matrix Ikis possible to use the SVD of A to determine the orthogonal matrix R closest to, The closeness of fit is measured by the Frobenius norm of R — A. The solution is the product UV * ./4I This intuitively makes sense because an orthonormal matrix would have the decomposition UIV * where [is the identity matrix, so that if A= UEV" then the product A = UV * amounts to replacing the singular values with ones. A similar problem, with interesting applications in shape analysis, is the orthogonal Procrustes problem, which consists of finding an orthogonal matrix R which most closely maps A to B. Specifically, R=argmin |AQ— Bl|r subject to O72 =1, where | _ |p denotes the Frobenius norm, This problem is equivalent to finding the nearest orthogonal matrix to a given matrix M= A"B, The Kabsch Algorithm The Kabsch algorithm (called Wahba’s problem in other fields) uses SVD to compute the optimal rotation (with, respect to least-squares minimization) that will align a set of points with a corresponding set of points. Itis used, among other applications, to compare the structures of molecules. Other examples The SVD is also applied extensively to the study of linear inverse problems, and is useful in the analysis of regularization methods such as that of Tikhonov. It is widely used in statistics where itis related to principal component analysis and to Correspondence analysis, and in signal processing and pattern recognition. Itis also used in output-only modal analysis, where the non-scaled mode shapes can be determined from the singulat vectors, Yet another usage is latent semantic indexing in natural language text processing, The SVD also plays a crucial role in the field of Quantum information, in a form often referred to as the Schmidt decomposition, Through it, states of two quantum systems are naturally decomposed, providing a necessary and sufficient condition for them to be entangled: ifthe rank of the E matrix is larger than one. One application of SVD to rather large matrices is in numerical weather prediction, where Lanczos methods are used to estimate the most linearly quickly growing few perturbations to the central numerical weather prediction over a given initial forward time period — ice. the singular vectors corresponding to the largest singular values of the linearized propagator for the global weather over that time interval. The output singular vectors in this case are entire weather systems, These perturbations are then run through the full nonlinear model to generate an ensemble forecast, giving a handle on some of the uncertainty that should be allowed for around the current central prediction. Another application of SVD for daily life is that point in perspective view can be unprojected in a photo using the calculated SVD matrix, this application leads to measuring length (a.k.a. the distance of two unprojected points in perspective photo) by marking out the 4 comer points of known-size object in a single photo, PRuler is a demo to implement this application by taking a photo of a regular creditcard Relation to eigenvalue decomposition The singular value decomposition is very general in the sense that it can be applied to any m x n matrix whereas eigenvalue decomposition can only be applied to certain classes of square matrices. Nevertheless, the two decompositions are related, Given an SVD of M, as described above, the following two relations hold: MM =VS*U*USV* = V(S*E)V* MM* = USV*VE*U" = U(ZE")U* The right hand sides of these relations describe the eigenvalue decompositions of the left hand sides. » The columns of (right singular vectors) are eigenvectors of M* M. » The columns of U (left singular vectors) are eigenvectors of MM * » The non-zero elements of E (non-zero singular values) are the square roots of the non-zero cigenvalues of M* Mor MM* In the special case that M is a normal matrix, which by definition must be square, the spectral theorem says that it can be unitarily diagonalized using a basis of eigenvectors, so that it ean be written M= UDU * for a unitary matrix U and a diagonal matrix D. When M is also positive semi-definite, the decomposition M = UDU "is also a singular value decomposition, However, the eigenvalue decomposition and the singular value decomposition differ for all other matrices M: the cigenvalue decomposition is M = UDU~ ! where U is not necessarily unitary and D is not necessarily positive semi-definite, while the SVD is M = UZV * where 2 is a diagonal positive semi-definite, and U and V are unitary matrices that are not necessarily related except through the matrix M. Existence An eigenvalue 2 of a matrix is characterized by the algebraic relation Mu ~7.u. When M is Hermitian, a variational characterization is also available. Let M be a real n * n symmetric matrix. Define f:R" > R by fx) =x! Mx. By the extreme value theorem, this continuous function attains a maximum at some w when restricted to the closed unit sphere {Ils < 1}. By the Lagrange multipliers theorem, w necessarily satisfies Vf=VabMe=\-Vare where the nabla symbol, (7, isthe del operator. A short calculation shows the above leads to Mu = 4 u (symmetry of M is needed here). Therefore J is the largest eigenvalue of M. The same calculation performed on the orthogonal complement of u gives the next largest cigenvalue and so on. The complex Hermitian case is similar; there f(x) = x* Mx is a real-valued function of 2n real variables, ‘Singular values are similar in that they can be described algebraically or from variational principles. Although, unlike the eigenvalue case, Hermiticity, or symmetry, of M is no longer required. This section gives these two arguments for existence of singular value decomposition. Based on the spectral theorem Let M be an m-by-n matrix with complex entries, .M*M is positive semidefinite and Hermitian, By the spectral theorem, there exists a unitary n-by-n matrix V such that vuemy [2 0 varuy = [f a where D is diagonal and positive definite. Partition V appropriately so we can write VWMMY VWM'MV| _ [DO VyMeMY, VsMeMV) ~ [0 0 li] MM[Y Therefore V;*M*MV; = D and V>*M*MYV ~ 0, The latter means MV = 0. Also, since V is unitary, ¥)°V) =I, V"V2 = Land VjV)*+ V2V2*= 1. Define U, =uyp. Then UD? Vt = MVD DPV = M, We sce that his is almost the desired result, except that U; and V are not unitary in general, but merely isometries To finish the argument, one simply has to "fill out" these matrices to obtain unitaries. For example, one can choose Uy such that U= [i Us) is unitary, Define ion x= Oo 0 0 where extra zero rows are added or removed to make the number of zero rows equal the number of columns of Uy. Then [Ui U2] (O a [Kh W)i= [4 “]) 0 piv 0 | UD yt which is the desired result: M=UsV" Notice the argument could begin with diagonalizing MM* rather than M*M (This shows directly that MM* and M*M have the same non-zero eigenvalues). Based on variational characterization The singular values can also be characterized as the maxima of u"Mv, considered as a function of w and v, over particular subspaces. The singular vectors are the values of w and v where these maxima are attained. Let M denote an m n matrix with real entries. Let S” ~ ! and $" ~ | denote the sets of unit 2-norm vectors in R™ and R" respectively. Define the function o(u,v) =u? Mv for vectors u € S”~! and v € S"~ |. Consider the function o restricted to S”~ | x $"~!, since both S”~ ! and S"~ 1 are compact sets their product is also compact. Furthermore, since «is continuous, it attains a largest value for at least one pair of vectors w € 5" ~ 1 and v € $1, This largest value is denoted oy and the corresponding vectors are denoted 11; and vy. Since 6} is the largest value of 6(u,v) it must be non-negative. If it were negative, changing the sign of either ; or v; would make it positive and therefore larger. ‘Statement: 1), v; are left and right singular vectors of M with corresponding singular value o, Proof: Similar to the eigenvalues case, by assumption the two vectors satisfy the Lagrange multiplier equation: Vo=VulMv=d-Vulut ro- Vere After some algebra, this becomes Mv, =u +0. and Mu =0+ 2dr Mutiplyng the frst equation from let by and the second equation from let by p and tang [ll =I ul Mey = 0, = 24 or MT uy, = 01 = 2 So 0) = 22) = 2 Ap. By properties of the functional g defined by o(w) = ww, we have Mo, = or Similarly, Mu =o This proves the statement. More singular vectors and singular values can be found by maximizing o(u, v) over normalized u, v which are orthogonal to uj and v4, respectively. ‘The passage from real to complex is similar to the eigenvalue case. Geometric meaning Because U and are unitary, we know that the columns 1),..,t#q of U yield an orthonormal basis of A" and the columns V45.%q Of V yield an orthonormal basis of K” (with respect to the standard scalar products on these spaces). The linear transformation 7 :X" —» K™ that takes a vector x to Mx has a particularly simple description with respect, to these orthonormal bases: we have T(v) = ¢; uj, for i= 1,...min(m,n), where is the i-th diagonal entry of ¥, and T(v) = 0 for i> min(m,n). ‘The geometric content of the SVD theorem can thus be summarized as follows: for every linear map T:K" —» K™ one can find orthonormal bases of K” and K™ such that T’ maps the i-th basis vector of A" to a non-negative multiple of the ith basis vector of K®, and sends the left-over basis vectors to zero. With respect to these bases, the map T'is therefore represented by a diagonal matrix with non-negative real diagonal entries. To get a more visual flavour of singular values and SVD decomposition —at least when working on real vector spaces— consider the sphere S of radius one in R". The linear map T'maps this sphere onto an ellipsoid in R™. Non-zero singular values are simply the lengths of the semi-axes of this ellipsoid. Especially when n=m, and all the singular values are distinet and non-zero, the SVD of the linear map T'can be easily analysed as a succession of three consecutive moves : consider the ellipsoid 7(S) and specifically its axes ; then consider the directions in R" sent by Tonto these axes. These directions happen to be mutually orthogonal. Apply first an isometry v* sending these directions to the coordinate axes of R”, On a second move, apply an endomorphism d diagonalized along the coordinate axes and stretching or shrinking in each direction, using the semi-axes lengths of 7(S) as stretching coefficients. The composition d o v* then sends the unit-sphere onto an ellipsoid isometric to T(S). To define the third and last move u, just apply an isometry to this ellipsoid so as to carry it over 7(S). As ean be easily checked, the composition wo do v* coincides with 7. Calculating the SVD Numerical Approach The SVD of a matrix M is typically computed by a two-step procedure. Inthe first step, the matrix is reduced to a bidiagonal matrix. This takes O(mn?) floating-point operations, assuming that m > n (this formulation uses the big © notation). The second step is to compute the SVD of the bidiagonal matrix. This step can only be done with an. iterative method (as with eigenvalue algorithms). However, in practice it suffices to compute the SVD up to a certain precision, like the machine epsilon. If this precision is considered constant, then the second step takes O(n) iterations, cach costing O(n) flops. Thus, the first step is more expensive, and the overall cost is Om?) flops. (Trefethen & Bau III 1997, Lecture 31). The first step can be done using Houscholder reflections for a cost of 4mn? ~ 4n¥/3 flops, assuming that only the singular values are needed and not the singular vectors. If m is much larger than m then itis advantageous to first reduce the matrix M to a triangular matrix with the QR decomposition and then use Householder reflections to further reduce the matrix to bidiagonal form; the combined cost is 2mn? + 2n’ flops (Trefethen & Bau III 1997, Lecture 31), The second step can be done by a variant of the QR algorithm for the computation of eigenvalues, which was first described by Golub & Kahan (1965). The LAPACK subroutine DBDSQR!*! implements this iterative method, with some modifications to cover the case where the singular values are very small (Demmel & Kaban 1990). Together with a first step using Householder reflections and, if appropriate, QR decomposition, this forms the DGESVDIS} routine for the computation of the singular value decomposition, The same algorithm is implemented in the GNU Scientific Library (GSL). The GSL also offers an alternative method, which uses a one-sided Jacobi orthogonalization in step 2 (GSL Team 2007). This method computes the SVD of the bidiagonal matrix by solving a sequence of 2-by-2 SVD problems, similar to how the Jacobi eigenvalue algorithm solves a sequence of 2-by-2 eigenvalue methods (Golub & Van Loan 1996, §8.6,3). Yet another method for step 2 uses the idea of divide-and-conquer eigenvalue algorithms (Trefethen & Bau IIT 1997, Lecture 31), Analytic Result of 2-by-2 SVD The singular values of a 2-by-2 matrix can be found analytically. Let the matrix be M = 216 + 267 + 2303, where 2; € Care complex numbers that parameterize the matrix, and 6; denote the Pauli matrices. Then its two singular values are given by + | (Imz23)? + (Im%, + (Imz,2})? Reduced SVDs In applications itis quite unusual for the full SVD, including a full unitary decomposition of the null-space of the matrix, to be required. Instead, itis often sufficient (as well as faster, and more economical for storage) to compute a reduced version of the SVD. The following can be distinguished for an mn matrix M of rank r: Thin SVD M=U,¥,V" Only the n column vectors of U corresponding to the row vectors of V* are calculated. The remaining column vectors of U are not calculated. This is significantly quicker and more economical than the full SVD if n<

You might also like