We're looking for a line of best fit of the form

. Set up a matrix equation:

Multiply both sides on the left by the transpose of the coefficient matrix:


Multiply both sides by the inverse of the new coefficient matrix:


So we end up with a best-fit line of
