Suppose we are given the equations \left\{\begin{array}[l] 2x - y = 2 \\ x + 2y = 1 \\ x + y = 4\end{array}\right.. Let's try solving for the values of x and y that satisfy all three equations.
211121[xy]=214
By performing Gaussian elimination, we end up with
200−1−51[xy]=20−3
The system is overdetermined! y cannot equal 0 and −3 simultaneously. In this type of situation, we have to resort to using least squares. We will find values of x′ and y′ that is the "closest" to each of the equations (imagine minimizing the squared distances between (x′,y′) and each of the lines). Let's solve for this using the equation ATAx=ATb.
ATA=[2−11211]211−121=[6116]
Sanity check: ATA is always a symmetric matrix. Why? (ATA)T=ATATT=ATA