Linear Regression

Best-fit line y = mx + b with R²

Linear Regression calculator — free online tool

🔒 Locally run · Method · · Disclaimer · Linear Regression

Linear Regression turns the numbers behind best-fit line y = mx + b with R² into a result, step by step. You supply X values (comma separated) and Y values (comma separated) to Linear Regression; the answer follows at once. Linear Regression ties each output to its formula. Students and professionals reach for Linear Regression when speed matters. Linear Regression runs in your browser. Math data stays in the tab. Linear Regression sits in the Math section next to related tools and linear regression calculator least squares slope intercept r squared. Linear Regression is great for comparing scenarios. Change one value and watch. Linear Regression is free, instant and local.

What the defaults give

x = 1, 2, 3, 4 against y = 2, 4, 6, 8 fits y = 2.0000x + 0.0000.

R² is 1.0000, a perfect fit, because every y value is exactly twice its x value.

The least-squares formulas

slope = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²

intercept = ȳ − slope × x̄

R² = (Σ(x − x̄)(y − ȳ))² ÷ (Σ(x − x̄)² × Σ(y − ȳ)²)

With x̄ = 2.5 and ȳ = 5, the slope comes out at 2 and the intercept at 0, so the line passes through the origin.

Worked examples

(1,2) (2,4) (3,6) (4,8) → y = 2x + 0, R² = 1
(1,2) (2,3) (3,5) (4,6) → positive slope below 2, R² near 0.96
(1,10) (2,8) (3,6) (4,4) → y = −2x + 12, R² = 1
(1,5) (2,5) (3,5) (4,5) → slope 0, intercept 5

What R² does and does not say

R² is the share of the variation in y explained by the line. A value near 1 means the points sit close to it; near 0 means the line explains almost nothing. It says nothing about whether the relationship is causal, whether the slope is meaningful, or whether a straight line was the right shape to begin with. A strong R² on a curved relationship is still the wrong model.

When a straight line misleads

A perfect fit, with R² of 1.0, is a warning as much as a result: real measurements almost never fall exactly on a line, so an exact fit usually means the data were constructed or too few points were used. The slope is the quantity to interpret — 2.0 means y rises two units for every unit of x — while the intercept is where the line crosses zero, which can sit outside the data range and be meaningless in context.

Frequently Asked Questions

Why is the slope 2 for these points?

Because each y value is exactly twice its x value, so the best-fit line is y = 2x with no intercept and R² of 1.

What does R² = 1 mean?

That every point lies exactly on the fitted line — all the variation in y is explained by x, which is unusual in real data.

How many points do I need?

At least two for a line, but three or more before R² tells you anything useful about the fit.

Does a high R² prove causation?

No. It only measures how closely the points follow the line, not why they do.

What happens with an outlier?

Least squares weights distant points heavily, so one outlier can rotate the line and pull R² down sharply.

Can I fit a curve instead?

Not with this tool. Transform the data — for example take logs of y — and fit a line to the transformed values.

About CalcProMaster calculators

CalcProMaster is a free library of 1285 online calculators across 20 categories — finance, health, math, business, construction, engineering, conversion, education and more. Every calculator runs entirely in your browser: no sign-up, no paywall, and no data leaves your device.

What makes these calculators different is transparency. Each tool shows the exact formula it uses. It also shows a step-by-step breakdown of how your inputs become the result. That way you can check the math instead of trusting a black box. Every calculator page explains how to read the result. It also lists common mistakes, assumptions and limitations. An FAQ sits with every one, and the most-used tools add a worked example. Health and finance tools name the formula they follow. Calorie needs use Mifflin-St Jeor. Loans use standard amortization. Each page says plainly when an answer should be confirmed with a professional.

The guides library goes deeper on the calculations people search for most. It covers percentage and discount math, loan EMI and amortization, income-tax brackets, calorie and macro planning, and concrete volumes. Each guide gives the formula, worked examples and links to the matching calculator. The glossary defines the terminology in plain language. The public formula QA dashboard shows the verification status of every calculator's math.

Popular starting points: loan EMI calculator, BMI calculator, percentage calculator, random number generator, and concrete calculator. You can also browse a category above to find the tool you need.

↑ ↓ navigate↵ openesc close