This is closely related to Least Squares The red lines are the deviation/error/residuals in approximation.

We were finding an to minimize . This is the same thing as minimizing . Now, over all ,

So basically we are trying to minimize the square of the residual.