Consider the following set of equations: $$ax+by=g$$ $$cx+dy=h$$ $$ex+fy=i$$ which could be represented as: $$ \begin{bmatrix} a & b\\ c & d\\ e & f\\ \end{bmatrix} \begin{bmatrix} x\\ y\\ \end{bmatrix} =\begin{bmatrix} g\\ h\\ i\\ \end{bmatrix} $$ $a$ through $i$ are all known constants. $x$ and $y$ are unknown. In a normal case, one could solve this through traditional methods taught in Algebra I, or by matrix math, etc. The two problems are:
All the numbers are approximations, so the equals sign would be more appropriately be a $\approx$. I want to find the closest approximation for $x$ and $y$.
I have more equations than variables.
I have heard of techniques for solving this kind of problem but cannot find them, partially due to the fact that I don't know what you would call this kind of problem.
The Linear Least Squares is a method of solving equations $\mathbf{Ax}=\mathbf{b}$ wherein the vector $\mathbf{b}$ may or may not be in $\mathrm{R}(\mathbf{A})$. The solution that minimizes the mean squared error $|\mathbf{Ax}- \mathbf {b}|^2$ when $\mathbf{A}$ is full rank is given by the Least Squares solution:$$\hat{\mathbf{x}}=(\mathbf{A}^\mathrm{T}\mathbf{A})^{-1}\mathbf{A}^\mathrm{T}\mathbf{b}$$ which can be computed in MATLAB quickly as
x=A\b. If $\mathbf{b}$ were in the Range space then the solution obtained is indeed the exact solution which may not happen too often because of the errors in measured quantities in the real world.