Slope Calculator
Find the slope of a line through two points, plus its y-intercept, full equation y = mx + b, and the angle it makes with the x-axis.
Enter two points to find the slope, intercept, equation, and angle.
m = (y₂ − y₁) / (x₂ − x₁), b = y₁ − m·x₁, and θ = arctan(m). When x₂ = x₁ the line is vertical and the slope is undefined.
FreeNo sign-upPrivate — runs in your browser, nothing is uploaded
Quick answer
The slope between two points is m = (y2 − y1) / (x2 − x1) — the change in y divided by the change in x. For example, through (1, 2) and (4, 8), m = (8 − 2) / (4 − 1) = 6 / 3 = 2, so the line rises 2 units for every 1 unit right. The y-intercept is b = y1 − m·x1 = 2 − 2·1 = 0, giving the equation y = 2x.
Formula & method
Slope
m = (y₂ − y₁) / (x₂ − x₁)
- m — slope of the line
- (x₁, y₁) — coordinates of the first point
- (x₂, y₂) — coordinates of the second point
Rise over run: vertical change divided by horizontal change. Undefined when x₂ = x₁ (a vertical line).
Y-intercept
b = y₁ − m · x₁
The y-value where the line crosses the y-axis (x = 0). Either point can be substituted; both give the same b.
Line equation
y = m·x + b
Slope-intercept form. Combine the computed m and b to describe the full line.
Angle of inclination
θ = arctan(m), in degrees
The angle the line makes with the positive x-axis. Positive slope gives 0°–90°, negative slope gives −90°–0°.
Examples
Example 1: Positive slope through (1, 2) and (4, 8)
- Input
- x1 = 1, y1 = 2, x2 = 4, y2 = 8
- Result
- m = 2, b = 0, y = 2x, angle ≈ 63.4349°
- Why
- m = (8 − 2) / (4 − 1) = 6 / 3 = 2. b = 2 − 2·1 = 0, so y = 2x. The angle is arctan(2) ≈ 63.4349°.
Example 2: Negative slope through (−3, 4) and (2, −1)
- Input
- x1 = −3, y1 = 4, x2 = 2, y2 = −1
- Result
- m = −1, b = 1, y = −x + 1, angle = −45°
- Why
- m = (−1 − 4) / (2 − (−3)) = −5 / 5 = −1. b = 4 − (−1)·(−3) = 4 − 3 = 1, so y = −x + 1. arctan(−1) = −45°.
Example 3: Horizontal line through (0, 3) and (5, 3)
- Input
- x1 = 0, y1 = 3, x2 = 5, y2 = 3
- Result
- m = 0, b = 3, y = 3, angle = 0°
- Why
- m = (3 − 3) / (5 − 0) = 0 / 5 = 0. A zero slope is a flat line: b = 3 − 0·0 = 3, so y = 3, with angle arctan(0) = 0°.
Example 4: Vertical line through (2, 5) and (2, 9)
- Input
- x1 = 2, y1 = 5, x2 = 2, y2 = 9
- Result
- Slope undefined (vertical line x = 2)
- Why
- Here x2 = x1 = 2, so the run (x2 − x1) = 0 and dividing by zero is undefined. The line is vertical, written x = 2, and has no finite slope or y-intercept.
When to use this tool
- Finding how steep a line, ramp, road, or roof is from two known points or measurements.
- Writing the slope-intercept equation y = mx + b of a line for algebra, graphing, or geometry homework.
- Computing the rate of change between two data points (e.g. how fast a quantity rises per unit of time).
- Checking whether two lines are parallel (equal slopes) or perpendicular (slopes whose product is −1).
Common mistakes
- Subtracting the coordinates in a different order top and bottom — e.g. using (y2 − y1) over (x1 − x2). Keep both differences in the same direction or you flip the sign of the slope.
- Putting x in the numerator. Slope is rise over run: the change in y goes on top, the change in x on the bottom.
- Forgetting that a vertical line (x2 = x1) has an undefined slope, not a slope of 0. A slope of 0 is a horizontal line.
- Mishandling negative coordinates — subtracting a negative is the same as adding, so x2 − (−3) = x2 + 3. Dropping the double-negative gives the wrong run.
Frequently asked questions
What is the formula for slope between two points?
Slope is m = (y2 − y1) / (x2 − x1), the change in y divided by the change in x. This is often remembered as 'rise over run.' For (1, 2) and (4, 8) it gives (8 − 2) / (4 − 1) = 2.
What does a slope of 0 mean?
A slope of 0 means the line is perfectly horizontal — y stays the same no matter how x changes, because the rise (y2 − y1) is zero. Its equation is simply y = b. This is different from an undefined slope, which is a vertical line.
Why is the slope of a vertical line undefined?
For a vertical line, both points share the same x-value, so the run x2 − x1 equals 0. Division by zero is undefined, so the slope has no number. The line is written as x = constant instead of y = mx + b.
How do I find the y-intercept once I have the slope?
Plug one point and the slope into b = y − m·x. Using (1, 2) with m = 2 gives b = 2 − 2·1 = 0. You can use either point — both yield the same intercept — and then write the line as y = mx + b.
How do I convert a slope into an angle?
Take the inverse tangent of the slope: angle = arctan(m), then convert to degrees. A slope of 1 is 45°, a slope of 2 is about 63.43°, and a slope of 0 is 0°. Negative slopes give negative angles (going downhill left-to-right).
What does a negative slope tell me?
A negative slope means the line falls as you move from left to right: y decreases while x increases. For example, a slope of −1 drops one unit down for every unit right and makes a −45° angle with the x-axis.
Sources & references
External references open in a new tab. We are independent and not affiliated with these organizations.
- Free
- No sign-up
- Runs entirely in your browser — nothing is uploaded.
- Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards below.
Related tools
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the tool to appear: