advertisement

Derive Least Squares Line This problem concerns what happens when you select the “add trendline” function in Excel, use Origin or SigmaPlot to fit a straight line, etc. The goal is to start with a set of x,y data pairs (let the number of pairs be N) and derive the best fit line y = a +bx. This line is defined by minimizing the squares of the distance (in the y direction) and the line. You could picture this as minimizing the area of a square with both sides equal to the vertical distance defined by the line and the point. One such square is shown below for the fourth data point, but you are trying to minimize the sum of such squares. y x Use calculus to derive equations for the intercept, a, and slope, b, in terms of the values yi, xi (from i = 1 to N), sums of these and sums of their products. Program this into an Excel spreadsheet that will permit you to enter new points x and y and determine a and b. This does NOT mean use the Excel trendline or linear fitting procedure.