Linear Regression Calculator

Linear Regression Calculator

Fit the least-squares line to a list of x,y data pairs and inspect the slope, intercept, and fit stats.

Last updated: June 2026 | By Patchworkr Team

Regression Solver

Enter one pair per line in the form x,y. Blank lines and malformed rows are rejected.

Best-Fit Line
y = 0.904762x + 1.428571
Slope (m)
0.904762
Intercept (b)
1.428571
Correlation r
0.95119
R^2
0.904762
Std. Error
0.776643
n
8
Excellent fit

What Is Linear Regression?

Linear regression finds the straight line that best fits a set of points by minimizing the sum of the squared vertical distances from the data to the line.

How to Find the Best-Fit Line

  1. Enter one x,y pair per line.
  2. Compute the means of x and y.
  3. Use the least-squares formulas for slope and intercept.
  4. Inspect r, R^2, and standard error to judge the fit.
m = Sxy / Sxx, b = ybar - m xbar

Worked Example

Using the sample data, the calculator fits a line to the points and reports the slope, intercept, and fit statistics in the result panel.

1,2 2,4 3,5 4,4 5,5 6,7 7,8 8,9

Frequently Asked Questions

Why reject blank lines?

Blank rows are treated as invalid so the calculator never silently drops data.

Does the tool accept decimals?

Yes. Each x and y value can be any finite real number, including scientific notation.

What if all x values are the same?

The regression line is undefined because the denominator in the slope formula becomes zero.

When is R^2 undefined?

If y has no variation, correlation is undefined, so the panel shows N/A for r and R^2.

Related Tools