# Linear Regression Calculator

URL: https://speedycalculator.com/calculators/statistics/linear-regression/
Last updated: 2026-10-25

> The linear regression calculator fits the least-squares line y = mx + b to paired data and predicts y for a new x. It also reports R² to show how well the line fits.

## Inputs

- X values
- Y values
- Predict y at x =

## Results

- Slope (m)
- Intercept (b)
- Predicted y
- R²

## Formula

```
m = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
b = ȳ − m x̄
```

## Explanation

Regression lines are used for forecasting, trend analysis and calibration curves.

### How to use the Linear Regression Calculator

- **X values**
- **Y values**
- **Predict y at x =**

Results update as you type, and every field accepts the units shown in its menu.

### How it works

The slope minimises the sum of squared vertical distances between the points and the line.

### Inputs explained

FieldWhat to enterX valuesA list of numbers separated by commas, spaces or new linesY valuesA list of numbers separated by commas, spaces or new linesPredict y at x =A number

### What each result means

- **Slope (m)** = slope([X values], [Y values])
- **Intercept (b)** = intercept([X values], [Y values])
- **Predicted y** = [Slope (m)]×[Predict y at x =] + [Intercept (b)]
- **R²** = corr([X values], [Y values])^2

### Example values

How the main result changes when **Predict y at x =** changes and everything else stays at the example values above:

Predict y at x =Predicted y3061.64590.160118.675147.190175.6120232.6

## Worked example

Inputs — X values: 10, 20, 30, 40, 50; Y values: 25, 41, 62, 79, 101; Predict y at x =: 60.

Results — Slope (m) = 1.9; Intercept (b) = 4.6; **Predicted y = 118.6**; R² = 0.99746.

## FAQ

**Is extrapolation reliable?**
Predictions outside the data range assume the trend continues, which may not hold.

**What if the relationship is curved?**
Consider polynomial or exponential regression.

**What formula does the Linear Regression Calculator use?**
m = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)².


## Sources

- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
