Regression & correlation
Slope and Intercept Calculator
Rise over run, from two points — or the least-squares line through a whole column of data.
Also called slope calculator, y-intercept calculator, slope-intercept form calculator, point-slope form calculator.
Have a spreadsheet? Drop a CSV here
Or . CSV, TSV or plain text. You pick which column is which after it loads — the names in your file do not have to match ours. The file is read in your browser and never uploaded.
How to read this result
Slope is rise over run: how much y changes for each unit of x. Positive slopes go up to the right, negative ones down, zero is horizontal, and a vertical line has no slope at all because the run is zero.
The intercept is where the line crosses the y-axis — the fitted value of y when x is zero. Whether that is meaningful depends on your data: for a line through height and weight, x = 0 is not a person.
Two points give an exact line; more points give an estimate. With two points there is no uncertainty and no error term — it is geometry. With a column of data, the line is the least-squares fit and comes with standard errors, which is linear regression.
The same slope, three ways. Slope-intercept (y = mx + b) is the usual form; point-slope is convenient when you know a point on the line; standard form is preferred in some textbooks. All three are shown, along with the percentage grade used for ramps and roads.
The formula
- the slope — rise over run
- the y-intercept
A vertical line (x₁ = x₂) has an undefined slope: the run is zero, and its equation is simply x = constant.
Worked example
The line through (2, 3) and (6, 11)
Two points. What is the equation of the line through them, and where does it cross the axes?
- The rise: how much y changes.11 − 3 = 8
- The run: how much x changes.6 − 2 = 4
- Slope is rise over run.m = 8 / 4 = 2
- Substitute one point to find the intercept.b = 3 − 2 × 2 = −1
- The x-intercept: where y = 0.0 = 2x − 1 → x = 0.5
A slope of 2 is also a 200% grade and an angle of 63.4°, both of which the calculator reports — the same number in the units different trades use.
Checked against arithmetic — (11 − 3)/(6 − 2).
The calculator above is loaded with these numbers by the Load the worked example button.
Assumptions, and when to use something else
For two points, none: this is geometry, and the answer is exact. The only special case is a vertical line, where the slope is undefined rather than infinite in any useful sense.
For a data set, the least-squares fit inherits every assumption of linear regression — linearity, independence, constant variance — and the slope becomes an estimate with a standard error rather than a fact.
- You have many points, not twoLinear regressionThe least-squares line with standard errors, p-values and a residual plot.
- You want the strength of the relationshipCorrelation coefficientHow tightly the points follow the line.
- You want to plot the pointsScatter plot makerDraws the points and the fitted line, with a PNG to download.
Questions people ask
What is slope-intercept form?
y = mx + b, where m is the slope and b is the y-intercept. It is the form that makes both properties readable at a glance, which is why it is the standard way to write a line.
What does a slope of zero mean?
A horizontal line: y does not change as x does. In a regression that means no linear relationship, which is exactly the null hypothesis a slope's p-value tests.
Why is the slope of a vertical line undefined?
Because the run is zero and the calculation divides by it. The line still exists — its equation is x = constant — but it cannot be written as y = mx + b.
How do I convert a slope to a percentage grade?
Multiply by 100. A slope of 0.08 is an 8% grade, which is also a rise of 1 in 12.5. All three forms are reported above, since ramps, roads and railways each use a different one.