Linear regression (line of best fit) calculator

Least-squares straight line through your data, with R². Enter your values and see the formula, your numbers plugged in and every step of the working. Free, no sign-up, SI and imperial units.

Formula

m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)²
c = ȳ − m · x̄,   R² = r²

Inputs

  • x values (x)
  • y values (same count) (y)

Worked example: Five measured points

  • x values x = 1, 2, 3, 4, 5
  • y values (same count) y = 2.1, 3.9, 6.2, 7.8, 10.1
  1. x̄ = 3, ȳ = 6.02
  2. Σ(x − x̄)(y − ȳ) = 19.9; Σ(x − x̄)² = 10
  3. m = 19.9 ÷ 10 = 1.99
  4. c = 6.02 − 1.99 × 3 = 0.05
  5. R² = 0.997305

Answer: Slope m = 1.99 ; Intercept c = 0.05 ; R² R² = 0.997305 ; Equation: y = 1.99x + 0.05

More engineering maths calculators

Engineering Maths formula sheet · All calculators · Practice problems