# Solving overdetermined linear system with $3$ equations in $2$ unknowns

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.

• If there is a solution $(x,y)$ then one of the equations is irrelevant. – Ahmed S. Attaalla Sep 18 '16 at 21:14
• This looks like a least squares problem. Left-multiply both sides by the transpose of the matrix and solve the resulting so-called "normal equations". – Rodrigo de Azevedo Sep 18 '16 at 21:15
• The usual way to solve a system like this is to use matrix reduction; have you studied Gaussian elimination or Gauss-Jordan reduction? (It looks as if $x=1, y=-1$ is the only solution.) – user84413 Sep 18 '16 at 21:15
• @user84413, well, um, no, though I'd be willing to try. Thing is, I'm in 8th grade and trying to teach myself this stuff, so if it requires calculus or higher, well... – heather Sep 18 '16 at 21:18
• @AhmedS.Attaalla, does that mean I can take out one of the equations and solve accordingly? – heather Sep 18 '16 at 21:19

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]$$