The Slope Calculator finds the gradient between two points in the plane, the angle of inclination of that line, and a line equation in slope-intercept form. Enter two distinct points. The page redraws the segment with rise and run marked.
Slope is rise over run. The same two points also determine distance and midpoint on sibling pages; this page owns the gradient, angle and equation outputs. Cross-link the Distance Calculator and the Midpoint Calculator when those quantities are the goal instead.
Calculate the slope between two points
Slope measures steepness as vertical change divided by horizontal change when moving from the first point to the second. The Slope Calculator subtracts coordinates in a consistent order. Reversing the order of the points negates the sign but keeps the magnitude. Horizontal change zero means the slope is undefined and the line is vertical.
m = (y2 - y1) / (x2 - x1)
For (1, 2) and (4, 8):
m = (8 - 2) / (4 - 1) = 6 / 3 = 2
A slope of 2 means the line rises 2 units for every 1 unit of run. Units cancel when x and y use the same length unit; if axes use different units, treat m as a pure ratio of those axis units.
Parallel lines share the same m. Perpendicular lines in the plane satisfy m1 * m2 = -1 when both slopes are defined. Vertical lines have no finite m; horizontal lines have m = 0.
Calculate the angle of the line
Angle of inclination uses arctangent of the slope measured from the positive x-axis. The Slope Calculator reports degrees by default. Vertical lines need a separate case because slope is undefined; their inclination is 90 degrees.
angle = arctan(m) in degrees
For m = 2:
angle = arctan(2) approx 63.43 deg
Negative slopes give negative angles in the principal arctan range, which correspond to lines that fall as x increases. Adding 180 degrees maps to the same geometric line with opposite direction. Road-grade percentages are 100 * m when m is rise over run; a slope of 0.08 is an 8 percent grade, not an 8 degree angle.
Find the equation of the line
Slope-intercept form y = m * x + b uses m from two points and b from substituting either point. Point-slope form y - y1 = m * (x - x1) is equivalent before rearranging. The Slope Calculator returns slope-intercept when the line is non-vertical.
b = y1 - m * x1
y = m * x + b
For m = 2 through (1, 2):
b = 2 - 2 * 1 = 0
y = 2 * x
Through (4, 8) the same b appears: 8 - 2 * 4 = 0. When b is not zero the intercept is the y-value at x = 0. Vertical lines are written x = constant instead of slope-intercept form.
Calculate the distance between the points
Distance between the same two points is the hypotenuse of horizontal and vertical legs. The Slope Calculator can show that length for context, while the Distance Calculator owns the full 2D and 3D treatment.
d = sqrt((x2 - x1)^2 + (y2 - y1)^2)
For (1, 2) and (4, 8):
d = sqrt(3^2 + 6^2) = sqrt(9 + 36) = sqrt(45) = 3 * sqrt(5) approx 6.71
Rise 6 and run 3 give slope 2 and distance sqrt(45). Those are different outputs from the same legs: division versus Pythagorean combination. Midpoint of the same segment is ((1+4)/2, (2+8)/2) = (2.5, 5), owned by the Midpoint Calculator.
Solve for points (1,2) and (4,8)
Use the reference pair for slope, angle and equation. Distance is included as a cross-check. 1. Slope
m = 2
2. Angle
arctan(2) approx 63.43 deg
3. Equation
y = 2 * x
4. Distance
d = sqrt(45) approx 6.71
Starting from other presentations of the same line (for example y = 2x + 0 through any other point on the line) yields the same m and angle.
Understand positive, negative and zero slope
Positive slope means the line rises as x increases (uphill left to right). Negative slope means the line falls as x increases (downhill). Zero slope means a horizontal line with constant y. Undefined slope means a vertical line with constant x.
| Kind | Condition | Example |
|---|---|---|
| Positive | m > 0 | (1, 2) to (4, 8), m = 2 |
| Negative | m < 0 | (1, 8) to (4, 2), m = -2 |
| Zero | y2 = y1, x2 ≠ x1 | (1, 5) to (4, 5), m = 0 |
| Undefined | x2 = x1, y2 ≠ y1 | (3, 1) to (3, 7) |
Steeper magnitude |m| means a sharper incline whether the sign is positive or negative. A slope of -2 is as steep as +2 but in the opposite vertical direction.
Frequently asked questions
How do I calculate slope between two points?
Use m = (y2 - y1) / (x2 - x1). For (1, 2) and (4, 8), m = 2.
What is the angle of the line?
Angle of inclination is arctan(m) in degrees. For m = 2, the angle is about 63.43 degrees.
What is the line equation?
With slope m and intercept b = y1 - m*x1, the equation is y = m*x + b. For the reference points, y = 2x.
What if the line is vertical?
Slope is undefined. Write the line as x = the shared x-coordinate instead of y = mx + b.
How does slope relate to distance?
Both use rise and run. Slope divides them; distance takes the square root of the sum of squares. Use the Distance Calculator for full distance work.
How does slope relate to midpoint?
Midpoint averages coordinates; slope ratios differences. Use the Midpoint Calculator for the segment center.
What is a zero slope?
Zero slope means a horizontal line. y stays constant while x changes.
Can slope be a percentage grade?
Yes. Percent grade is 100 * m when m is rise over run. That is not the same number as the inclination angle in degrees.
Do units cancel?
When x and y use the same unit, m is dimensionless. Mixed axis units keep m as a ratio of those units.
What is the slope for (1,2) and (4,8)?
The slope is 2, the inclination is about 63.43 degrees, and the equation is y = 2x.
What is the distance for that same pair?
Distance is sqrt(45) approx 6.71. Full distance treatment lives on the Distance Calculator.
Summary
Slope Calculator returns gradient, inclination angle and line equation from two points, with substituted arithmetic and a labelled rise-run figure. Worked numbers match (1, 2) and (4, 8): m = 2, angle about 63.43 degrees and y = 2x. Use the Distance Calculator and Midpoint Calculator for the other two-point outputs from the same segment.