[Math] Solving overdetermined linear system with $3$ equations in $2$ unknowns

linear algebramatricesmatrix equations

I have the linear system $$3x+2y = 1$$ $$x-y=2$$ $$4x+2y=2$$
So I set up the matrix equation $$\begin{bmatrix}3&2\\1&-1\\4&2\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=\begin{bmatrix}1\\2\\2\end{bmatrix}$$ And then I realized: how am I going to figure out what $x$ equals or $y$ equals if there are only two variables but there are 3 equations? I.e., how do I solve systems where there are matrices of different dimensions?

Also, the determinant of the first matrix is undefined due to dimension – how would you find the determinant of a non square matrix? Does the fact that this determinant is undefined mean that it is "zero" and therefore solutions cannot be found by using the inverse (I tried calculating the inverse and that didn't work either)? What then would be the next step to find the solution in cases like these?

I know that column space determines whether there is a solution and null space finds that solution, but I honestly don't know how to calculate either, and google hasn't helped me as I can't understand the explanations. Sorry about the number of questions, but they're all very closely related.

Thanks! Any help would be appreciated.

Best Answer

There is a direct solution, that is, $$ \mathbf{A} x - b = 0 $$ iff $x\in\mathcal{R}\left( \mathbf{A} \right)$. In other words, when the data vector $b$ is in the column space of the matrix $\mathbf{A}$.

Of the options for solving, we pick the method least squares. Form the normal equations: $$ \begin{align} \mathbf{A}^{*} \mathbf{A} x &= \mathbf{A}^{*} b \\ % \left[ \begin{array}{cc} 26 & 13 \\ 13 & 9 \\ \end{array} \right] % \left[ \begin{array}{c} x \\ y \end{array} \right] % &= % \left[ \begin{array}{c} 13 \\ 4 \end{array} \right]. % \end{align} % $$ The solution is $$ \begin{align} % x_{LS} &= \left( \mathbf{A}^{*}\mathbf{A} \right)^{-1} \mathbf{A}^{*} b \\[5pt] % &= \frac{1}{65} \left[ \begin{array}{rr} 9 & -13 \\ -13 & 26 \\ \end{array} \right] % \left[ \begin{array}{c} 13 \\ 4 \end{array} \right] \\[5pt] % & = % \left[ \begin{array}{r} 1 \\ -1 \end{array} \right] % % \end{align} $$

Is this a direct solution? Yes. $$ r\left( x_{LS} \right) = \mathbf{A} x_{LS} - b = % \left[ \begin{array}{r} 0 \\ 0 \\ 0 \end{array} \right] $$