Least Squares Regression Calculator

Least Squares Regression Calculator

Find the best-fit line for a set of data points.

Last updated: June 2026 | By Patchworkr Team

Main Calculator

Data Points
1
2
3
4
5
Regression Equation
y = 2x + 1
Slope
2
Intercept
1
Inputs are valid.

What is This?

The calculator fits a straight line that minimizes the squared vertical error from the input points.

How to Use This Calculator

  1. Enter at least two valid points.
  2. Add or remove rows as needed.
  3. Read the best-fit line in the result panel.

Worked Example

Points: (1, 3), (2, 5), (3, 7), (4, 9)
Best-fit line: y = 2x + 1

Frequently Asked Questions

Why require valid numbers in every field?

That prevents empty cells or malformed text from being silently treated as zeros.

What if all x-values are the same?

The regression line is undefined because the denominator becomes zero, so the calculator rejects that case.

Does the tool accept decimals?

Yes. Each coordinate can be any finite real number, including scientific notation.

Can I use more than two points?

Yes. The fit is computed from all of the points you enter.

Related Tools