# Singular value decomposition method for solving least squares problems

25 views (last 30 days)
Jiapeng on 16 Nov 2022
Answered: John D'Errico on 16 Nov 2022
For Ax=y, how to show in matlab?
In particular, how to show the inverse of the sum of the matrix.

Steven Lord on 16 Nov 2022
In this case Σ does not represent summation. One of the ways in which the singular value decomposition is represented is:
"Specifically, the singular value decomposition of an complex matrix M is a factorization of the form where U is an complex unitary matrix, is an rectangular diagonal matrix with non-negative real numbers on the diagonal, V is an complex unitary matrix, and is the conjugate transpose of V."

John D'Errico on 16 Nov 2022
If you are asking how to solve a least squares problem of the form A*x = y, using the svd, then you already have a simple formula right there, based on the output of the SVD, in the form
[U,S,V] = svd(A,0);
Remember that Sigma is a square MATRIX, but that it is also a diagonal matrix, so computing the inverse is easy, as long as none of the singular values are zero, or too close to zero, in which case your matrix was numerically singular anyway. In that case, the pinv solution falls into your lap.
If you are asking how to show that expression does result in a least squares solution, then this is not even a question about MATLAB. Regardless, then you could start with the normal equations solution for least squares. (Usually a bad idea, but it does work here.) Effectively, what is called the OLS method here:
Substitute in the factorization for A=U*S*V' from the SVD, and everything collapses. How to show that is not a question about MATLAB however, but just basic linear algebra.