ToyTools Guide

What Is a Least Squares Line?

What a least squares line is, how R squared differs from a residual, and why two points always look perfect.

5 min read Updated Oct 2026

Quick Answer

A least squares line is the straight line that minimizes the sum of squared vertical gaps. This linear regression calculator is a least squares calculator, and the same page is the line of best fit calculator. For the five default points the equation is y = 0.91x + 1.11, and R² is 0.880. Drag any point and both the slope and R² update on the canvas. Two points always report R² = 1, so add a third before you trust the fit.

Open The Linear Regression Playground →

What is a least squares line?

A least squares line is the straight line with the smallest sum of squared residuals. The default scatter plot uses (1, 2.2), (2, 2.8), (3, 4.1), (4, 3.9), and (5, 6.2). Their line of best fit is y = 0.91x + 1.11, and R² is 0.880.

How do you read the slope and R squared?

Slope is the y change per unit x, and R squared is the share of scatter explained. What R squared measures on a scatter plot is that share. On the default line that rise is 0.91, from an intercept of 1.11. Dragging points is how you fit the line of best fit, and the slope falls when you drag (5, 6.2) down while R² moves with it. For example, a small nudge at x = 5 changes both the slope and R² at once.

  • Slope 0.91 means y rises by 0.91 when x grows by 1.
  • R² of 0.880 means the line accounts for most of the vertical scatter.
  • The intercept 1.11 is the height of the line at x = 0.

What is the difference between R squared and a residual?

R squared scores the whole line, while a residual is the vertical gap at a single point. The difference between them is scope: the line versus one point. The default line has R² = 0.880 and a largest absolute residual of 0.85 at (4, 3.9). Reading R squared as the size of a residual mixes those two facts.

Why do two points always show a perfect fit?

Two points always show a perfect fit, and R² is 1, because one line passes through both. Two points do not prove a strong linear pattern. Trusting a perfect fit from only two points treats that geometry as evidence. The outlier preset is for showing a class why one outlier moves a line of best fit. Point 6 is (5, 1), and R² falls from 0.880 to about 0.089.

Common Mistakes