Math · 5 min read
How to Calculate the Slope of a Line
Rise over run between two points
Slope measures how steep a line is: the vertical change divided by the horizontal change between two distinct points. This tutorial walks through m = (y₂ − y₁) / (x₂ − x₁), a (1, 2) to (5, 4) worked example with slope 1/2, and a playground that draws the line and the rise/run triangle. A vertical line has undefined slope because the run is zero.
Written by the My Calculator Stack editorial team. About our methods
Two distinct points define a unique line. If x₂ = x₁ the run is zero and slope is undefined (a vertical line). This sketch is teaching geometry, not a full graphing calculator.
1.What slope is
Slope is a rate: how many units y changes for each one unit of x. Positive slope climbs left to right; negative slope falls; zero slope is horizontal. The same ratio holds for any two points on a straight line — similar rise/run triangles are scaled copies of each other. Slope is not the angle in degrees; the angle’s tangent is the slope.
2.The formula
Given points (x₁, y₁) and (x₂, y₂), rise is y₂ − y₁ and run is x₂ − x₁. Then m = rise / run, provided the run is not zero. Swapping the two points changes the sign of both rise and run, so m is unchanged. Point-slope form of the line is then y − y₁ = m(x − x₁).
\[ m = \frac{y_2-y_1}{x_2-x_1} \]
3.Worked example
Take P₁ = (1, 2) and P₂ = (5, 4). Rise = 4 − 2 = 2 and run = 5 − 1 = 4, so m = 2/4 = 1/2. From (1, 2) the line goes up 1 for every 2 across. If the second point were (1, 6) instead, run would be 0 and the slope would be undefined — a vertical line through x = 1.
\[ m=\frac{4-2}{5-1}=\frac{2}{4}=\tfrac{1}{2} \]
4.Rise/run playground
Move the two points. The sketch draws the line and a right triangle whose vertical leg is the rise and whose horizontal leg is the run. The caption substitutes into m = (y₂ − y₁) / (x₂ − x₁). This is a teaching widget — no full graphing chrome. Browse math calculators when you want equation solvers and related geometry tools.
Inline playground
Point 1 (x₁, y₁)
Point 2 (x₂, y₂)
Rise
2
Run
4
Slope m
0.5
m = (4 − 2) / (5 − 1) = 1/2
Teaching aid only — if the run is zero the slope is undefined (a vertical line).
Browse math calculators →5.Browse math calculators
There is no standalone slope calculator on this site. The math hub collects equation helpers (including a linear-equation solver), geometry tools, and fraction arithmetic if you want to keep the rise/run ratio in lowest terms.
Try it yourself
Open the related calculator and put these formulas to work.