Linear Regression Calculator

Fit a best-fit line through up to four points.

Best-fit line y = 1.9x + 0
Slope 1.9
Intercept 0
0.9627

Formula: least squares: slope = Σ(x−x̄)(y−ȳ) ÷ Σ(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₄ = 8
10.
11. Best-fit line = y = 1.9x + 0
12. Slope = 1.9
13. Intercept = 0
14. R² = 0.9627
Did we solve your problem today?

Find the least-squares line of best fit through your data points.

How the Math Works

The Linear Regression Calculator uses the least squares method to find the best-fit line through your data points. This formula calculates the slope by comparing how your x and y values vary together (the numerator) versus how your x values vary on their own (the denominator). Specifically, it sums the product of each point's deviation from the mean x and mean y values, then divides by the sum of squared deviations from the mean x. This gives you the steepness of the line that minimizes the total distance between all points and the line itself.

Practical Applications

To use this calculator, simply enter up to four data points with their corresponding x and y coordinates. The calculator will automatically compute the slope and y-intercept of the best-fit line, giving you an equation in the form y = mx + b. You can then use this equation to predict y-values for x-values not in your original dataset, or to understand the relationship between your variables. This is particularly useful when you want to model trends from limited experimental or observational data.

Day-to-Day Use

This calculator helps you make sense of patterns in everyday situations, like predicting your monthly expenses based on historical data, estimating how much time you'll need for a task based on past experience, or understanding how different factors relate to each other in your daily decisions. By finding the best-fit line through your data, you can spot trends quickly and make more informed predictions about future outcomes, helping you budget, plan, and optimize your daily activities with mathematical confidence.

Worked example

Sample points → y ≈ 1.9x + 0 (R² ≈ 0.92).

FAQ

R²?

The fraction of variance in y explained by x (0–1).