41.3: Overdetermined Systems
- Page ID
- 70550
When we have more equations than unknowns, we have the overdetermined system \(Ax=b\). In this assignment, we assume that the matrix \(A\) has full column rank. Therefore, the system may not be feasible, i.e., we cannot find \(x\) such that \(Ax=b\). Then we want to find the \(x\) to minimize \(\|Ax-b\|^2\), which is the least squares problem. We mentioned in previous assignments that we can solve this least squares problem by finding the left inverse of the matrix \(A\). That is \(x=(A^\top A)^{-1}A^\top b\).
In this assignment, we show that we can solve it by QR decomposion.
Consider the following system of equations:
\[\begin{split}\begin{bmatrix}5&-2&2 \\ 4 & -3 &4 \\ 4& -6 &7 \\ 6 & 3 & -3\end{bmatrix}\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}=\begin{bmatrix}1\\2\\3\\-1\end{bmatrix}\end{split} \nonumber \]
We solve the least squares problem in the following steps
- Find the QR decomposition of the matrix \(A\) such that \(R\) is a square upper-triangular matrix. (\(Q\) is not a square matrix any more)
- Use the
back_subst
function we defined before to solve \(Rx=Q^{\top}b\)
We can not use the np.linalg.solve
because the matrix \(A\) is not a square matrix (you can try if you do not believe it). However, we can use the np.linalg.lstsq
function to find the least squares solution to minimize \(\|Ax-b\|^2\). The next cell compares the result from lstsq
and our result from the QR decomposition. (If everything is correct, you will expect a True
result.)
Explain why we can use the QR decomposition to solve the least squares problem.