Definition of Best Fitting Curve.
Before we can find the curve that is best fitting to a set of data, we need to understand how “best fitting” is defined. We start with the simplest nontrivial example. We consider a data set of 3 points, and a line that we will use to predict the y-value given the x-value, We want to determine how well the line matches that data. For each point, in the set we start by finding the corresponding point, on the line.
This gives us a set of predicted points,

For each point we now compute the difference between the actual y-values and the predicted y-values. Our errors are the lengths of the brown segments in the picture, in this case Finally we add the squares of the errors,
The best fitting line is defined to be the line that that minimizes the sum of the squares of the error. If we are trying to fit the data with a different model, we want to choose the equation from that model that minimizes the sum of the squares of the error.