UnitConv

Slope Calculator

Find the slope, line equation, distance and midpoint from two points, with a graph

Point 1
Point 2

Graph

xyrun 2rise 4(0, 0)(2, 4)

The two points and the line through them, drawn to scale with the rise and run.

Slope (m)
2
Line equation
y = 2x
y-intercept (b)
0
x-intercept
0
Distance
4.4721
Midpoint
(1, 2)
Angle of inclination
63.43°
Grade (%)
200%

Step-by-step

m = (y₂ − y₁) / (x₂ − x₁) = (40) / (20) = 4 / 2 = 2
b = y₁ − m·x₁ = 0 − (20 = 0
d = √((x₂ − x₁)² + (y₂ − y₁)²) = √(2² + 4²) = 4.4721

What is the slope calculator?

This slope calculator takes two points (x₁, y₁) and (x₂, y₂) and works out everything about the straight line and the segment between them. It returns the slope m, the equation of the line in slope-intercept form y = mx + b, the y-intercept and x-intercept, the distance between the two points, their midpoint, the angle the line makes with the horizontal and the slope expressed as a percentage grade. A coordinate graph is drawn to scale so you can see the two points, the line through them and the rise and run that define the slope. Special cases are handled clearly: a vertical line gives an undefined slope, a horizontal line gives a slope of zero, and two identical points are flagged because they do not define a unique line.

How to use this calculator

1. Enter the x and y coordinates of the first point. 2. Enter the x and y coordinates of the second point. 3. The result updates instantly — no button to press. 4. Read off the slope, the line equation y = mx + b, the intercepts, the distance, the midpoint and the angle, and check the graph to see the line drawn to scale.

The formulas behind the answer

Slope (rise over run): m = (y₂ − y₁) / (x₂ − x₁). y-intercept: b = y₁ − m·x₁, giving the line y = mx + b. x-intercept (when m ≠ 0): x = −b / m. Distance between the points: d = √((x₂ − x₁)² + (y₂ − y₁)²). Midpoint: ((x₁ + x₂) / 2, (y₁ + y₂) / 2). Angle of inclination: θ = arctan(m). Example: for (0, 0) and (2, 4), m = 4 / 2 = 2, b = 0, so y = 2x; the distance is √(4 + 16) ≈ 4.472, the midpoint is (1, 2) and the angle is about 63.43°.

Reading the results

The slope tells you how steep the line is: a positive slope rises from left to right, a negative slope falls, and the larger the absolute value the steeper the line. A slope of 0 is a flat, horizontal line (y = b). When the two points share the same x-value the line is vertical, the run is zero and the slope is undefined — there is no y-intercept and the equation is simply x = constant. The y-intercept is where the line crosses the y-axis and the x-intercept is where it crosses the x-axis. The grade percentage (slope × 100) is the same measure used for road and ramp inclines, and the angle of inclination is that slope expressed in degrees.

Frequently asked questions

How is the slope calculated?

The slope is the change in y divided by the change in x: m = (y₂ − y₁) / (x₂ − x₁), often called rise over run. For the points (0, 0) and (2, 4) the slope is (4 − 0) / (2 − 0) = 2.

What happens with a vertical line?

If both points have the same x-coordinate the run is zero, so the slope is undefined (you would be dividing by zero). The line is vertical and is written x = constant; it has no y-intercept.

How do I find the equation of the line?

First compute the slope m, then the y-intercept b = y₁ − m·x₁. The line in slope-intercept form is y = mx + b. For (1, 1) and (3, 5): m = 2 and b = −1, so y = 2x − 1.

What are the distance and midpoint?

The distance is the straight-line length between the two points, d = √((x₂ − x₁)² + (y₂ − y₁)²). The midpoint is the point exactly halfway between them, ((x₁ + x₂) / 2, (y₁ + y₂) / 2).