Least Squares Criteria for the Least Squares Regression Line
Prepared by Mariel Maughan and Bruce Torrence 
The least squares regression line is commonly used as the best fitting line to a fixed collection of points. This Demonstration provides a visualization of the squares used in determining this line. For each of three datasets, the residuals from the points to a line are shown as dashed vertical segments. The squares of the residuals are shown with a red border. You can adjust the slope and intercept of the line in an effort to find the line for which the sum of the areas of these squared residuals is least. Click the button to obtain the least squares regression line.

Download the CDF file to view the simulation using the free Wolfram CDF player.