Least Squares Regression Line Calculator

Fit a best-fit line y = mx + b through up to five points.

Slope (m) 0.8
Intercept (b) 1.8

Formula: m = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²)

Step-by-step with your numbers:
1. Values used:
2. x₁ = 1
3. y₁ = 2
4. x₂ = 2
5. y₂ = 4
6. x₃ = 3
7. y₃ = 5
8. x₄ = 4
9. y₄ = 4
10. x₅ = 5
11. y₅ = 6
12.
13. Slope (m) = 0.8
14. Intercept (b) = 1.8
Did we solve your problem today?

Least-squares regression finds the straight line that best fits a set of data points.

The math behind it

It minimises the sum of squared vertical distances. The slope and intercept come from the standard normal-equation formulas using sums of x, y, xy and x².

Worked example

Points (1,2)…(5,6) give a best-fit slope near 0.8 and intercept near 1.4.

FAQ

Do I need all five points?

Use as many as you have; set unused points to repeat a real point or leave the defaults.