Linear least square method for singular matrices

In summary: I thought it was only able to solve a single equation.Naturally I should have thought of the least squares solution, but for some reason I convinced myself that there was a different solution =)In summary, the problem discussed is finding the least squares solution to a system of linear equations with an inconsistent matrix. Various methods were discussed, including using the generalized inverse, SVD, and LAPACK DGELSS. The solution involves embedding the underdetermined part of the system in the x vector and solving for the least squares solution, which is unique if the matrix A is full rank. The MATLAB linsolve function can be used to solve such systems.
  • #1
alyflex
9
0
I have stumbled upon a problem which I have so far been unable to solve.

I we consider a general set of linear equations:
[tex]Ax=b[/tex],

I know the the system is inconsistent which makes least square method the logical choice.

So the mission is to minimize [tex]||Ax-b||[/tex]

And the usual way I do this is by setting Ax=p, where p is the projection of b onto Ax.
By isolating:
[tex]x=(A^TA)^{-1}A^T \cdot p
=(A^TA)^{-1} \cdot A^T \cdot b[/tex]

However the product [tex]A^T*A[/tex] is also singular, and thus I am unable to do this.

I pretty sure there is a very simple way to do this, but when i look in my old algebra book I see no solution to the problem.

Anyone know the way?
 
Physics news on Phys.org
  • #2
Yes, that is the standard "least squares" method for solving such a problem with [itex](A^TA)^{-1}A^T[/itex] being the "generalized inverse". For most such problems [itex]A^TA[/itex] is invertible. If your A is such that [itex]A^TA[/itex] is not invertible then you have a very pathological problem for which there probably is no "simple" way to solve it. What is A?
 
  • #3
Isn't it true that [tex]A^TA[/tex] is only not invertible if there are actually multiple solutions to [tex]Ax=b[/tex]?
 
  • #4
Wizlem said:
Isn't it true that [tex]A^TA[/tex] is only not invertible if there are actually multiple solutions to [tex]Ax=b[/tex]?
Correct. The least square solution satisfies the normal equation A^TAx=A^Ty. This solution is unique if and only if A^TA is invertible. See here for a similar discussion.
 
  • #5
I can think of a couple of possibilities, both involving miniminum norm solutions. If A has more columns than rows, it is an underdetermined system that has an easy 'least norm' solution. If A has more rows than columns and is rank deficient (my guess in your case), there is a way to minimize the norm of Ax-b and the norm of x at the same time using SVD, but I'm not familiar with the details. Look up LAPACK DGELSS.

* DGELSS computes the minimum norm solution to a real linear least
* squares problem:
*
* Minimize 2-norm(| b - A*x |).
*
* using the singular value decomposition (SVD) of A. A is an M-by-N
* matrix which may be rank-deficient.
 
  • #6
Landau said:
Correct. The least square solution satisfies the normal equation A^TAx=A^Ty. This solution is unique if and only if A^TA is invertible. See here for a similar discussion.
This was what I suspected, but thanks for making it clear. Now I just need a method to compute it for non-invertible matrices

hotvette said:
I can think of a couple of possibilities, both involving miniminum norm solutions. If A has more columns than rows, it is an underdetermined system that has an easy 'least norm' solution. If A has more rows than columns and is rank deficient (my guess in your case), there is a way to minimize the norm of Ax-b and the norm of x at the same time using SVD, but I'm not familiar with the details. Look up LAPACK DGELSS.
The more I look at this the more afraid I am, that a numerical solution might be the best way. I was really hoping for a clear and illuminating analytical method.
HallsofIvy said:
What is A?
The initial system I stumbled upon was this:

[tex]\left[ {\begin{array}{ccc}
1 & 1 & 3 \\
-1 & 3 & 1 \\
1 & 2 & 4 \\
\end{array} } \right]
\left( {\begin{array}{c}
x \\
y \\
z \\
\end{array} } \right)
= \left( {\begin{array}{c}
-2 \\
0 \\
8 \\
\end{array} } \right)[/tex]

but then I considered more simple system but with the same problem.
One example could be:

y=x
y=x+1

It is clear what the least square solution to this system should be, but I have no idea how to find it methodically
 
Last edited:
  • #7
Consider A being column eliminated with R as

[tex]
A R R^{-1}x = b
[/tex]

Then,
[tex]
\left[ {\begin{array}{ccc}
1 & 0 & 0 \\
-1 & 4 & 0 \\
1 & 1 & 0 \\
\end{array} } \right] \left( {\begin{array}{c}
x + y +3z \\
y +z \\
z \\
\end{array} } \right) =\left( {\begin{array}{c}
-2 \\
0 \\
8 \\
\end{array} } \right)
[/tex]
now we solve a different linear eq. set, since the last variable does not play a role in the equations we reduce the number of columns.
[tex]
\underbrace{\left[ {\begin{array}{cc}
1 & 0 \\
-1 & 4 \\
1 & 1 \\
\end{array} } \right]}_{A_r} \left( {\begin{array}{c}
x + y +3z \\
y +z
\end{array} } \right) = \left( {\begin{array}{c}
x + y +3z \\
-x +3y + z \\
x+2y+4z
\end{array} } \right) =\underbrace{\left( {\begin{array}{c}
-2 \\
0 \\
8 \\
\end{array} } \right)}_{b}
[/tex]

From the second equation, you can see that it is not solvable. So back your least squares, and call the variables a b i.e.

[tex]
\left( {\begin{array}{c}
x + y +3z \\
y +z
\end{array} } \right) = \begin{pmatrix}a\\b\end{pmatrix}
[/tex]
And Matlab gave (from linsolve(Ar,b))

[tex]
\begin{pmatrix}a\\b\end{pmatrix} = \begin{pmatrix}3\\1\end{pmatrix}
[/tex]

And from this solution, you can construct admissible least squares solutions. I might have made mistakes so please check the steps but conceptually it should be OK if I didn't mess it up. To your small example, the least squares solution is a = y-x = 0.5 So the whole trick is to embed the underdetermined part inside the x vector and solve the least squares solution. Then you get infinitely many solutions that satisfy the least squares solution.EDIT: By the way, I forgot to write that any full rank decomposition of [itex]A = MN^T[/itex] leads to a similar solution. Similarly with SVD mentioned above.
 
Last edited:
  • #8
Thank you very much for the illuminating answer trambolin.

I'm going to work it through in the weekend using your method.

I'll post a longer and more conclusive reply once I have tried the method.

But to all of you, thank you very much for an enlightening discussion on a subject, which was causing me severe headaches yesterday. =)
 
  • #9
Well I just went through the calculation myself and as far as I can see everything you wrote was spot on, so thank you very much.

Btw I had no idea that the linsolve function in MATLAB solved a system of linear equations using least squares, I only thought it could find consistent solutions.
 
  • #10
alyflex,

Try the truncated SVD of the matrix A (Demmel, Applied Numerical Linear Algebra). Let [tex]A=U\Sigma V^T[/tex] where [tex]A,U\in \Re^{m\times n}, \Sigma,V\in \Re^{n \times n}[/tex]. See en.wikipedia.org/wiki/Singular_value_decomposition for details. Every good linear algebra software should have an algorithm. Let [tex]\hat{U}\in \Re^{m\times k},\ \hat{\Sigma} \in \Re^{k \times k},\ \hat{V}\in \Re^{n \times k}[/tex] where k is the numerical rank of A (ignore smallest singular information).

Your least squares solution is [tex]x=A^+b=\hat{V}\hat{\Sigma}^{-1}\hat{U}^Tb[/tex].
This should work if your matrix is decently sized (around 1000 unknowns).
Another plus is that of all the residual minimizers, this x has a minimal 2-norm.

Matthew
 

Related to Linear least square method for singular matrices

1. What is the purpose of the linear least square method for singular matrices?

The linear least square method for singular matrices is used to approximate a solution for an overdetermined system of linear equations where the coefficient matrix is singular. It minimizes the sum of squared errors between the actual and predicted values of the variables in the system.

2. How does the linear least square method handle singular matrices?

The linear least square method for singular matrices uses a technique called the pseudoinverse, which is a generalization of the inverse for non-invertible matrices. It finds the closest approximation to the solution that minimizes the error, even when the matrix is singular.

3. Can the linear least square method for singular matrices be used for underdetermined systems?

No, the linear least square method is only suitable for overdetermined systems where the number of equations is greater than the number of unknowns. For underdetermined systems, other methods such as the minimum norm solution or the singular value decomposition must be used.

4. What are the advantages of using the linear least square method for singular matrices?

The linear least square method allows for the solution of overdetermined systems with singular coefficient matrices, which cannot be solved using traditional methods. It also provides a measure of the error in the solution and can be extended to handle noisy data.

5. Are there any limitations to the linear least square method for singular matrices?

One limitation of the linear least square method is that it can only handle linear systems. Nonlinear systems cannot be solved using this method. Additionally, the pseudoinverse can be sensitive to small changes in the input data, leading to potential inaccuracies in the solution.

Similar threads

  • Linear and Abstract Algebra
Replies
5
Views
1K
Replies
7
Views
874
  • Linear and Abstract Algebra
Replies
16
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
3
Views
1K
  • Computing and Technology
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
998
  • Linear and Abstract Algebra
Replies
1
Views
1K
  • Linear and Abstract Algebra
Replies
9
Views
895
Back
Top