Slope Calculator

Point 1

Point 2

Slope2
Angle of incline63.43°
Distance between points6.7082
Midpoint(2.5, 5)
Equation of the liney = 2x + 0
How this was calculated
  1. Slope = rise ÷ run = (y₂ − y₁) ÷ (x₂ − x₁) = (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. A positive slope climbs left to right.
  2. The same two points are 6.7082 units apart by Pythagoras (√(3² + 6²)), their midpoint is (2.5, 5), and the line climbs at 63.43° above horizontal.
  3. Using point-slope form with the first point gives the equation y = 2x + 0 — handy because it also hands you the y-intercept, 0, where the line crosses the y-axis.

A slope calculator takes two points and gives you the slope of the line through them. Enter (x1, y1) and (x2, y2) and it returns the slope m, the angle of incline in degrees, the distance between the points, the midpoint, and the line's equation. The slope formula is m = (y2 - y1) / (x2 - x1) — rise over run. A vertical line (x1 = x2) has an undefined slope because the run is zero; a horizontal line has slope exactly 0. The angle of incline is arctan(m), converting the ratio into degrees — a slope of 1 is 45°, and road grades quote slope x 100 as a percentage.

This method is the accepted standard because the same two points give slope, distance by Pythagoras, the midpoint by averaging coordinates, and the line's equation from point-slope form. Verified examples confirm the results: from (1, 2) to (4, 8), slope = 2, angle 63.43°, distance 6.708, midpoint (2.5, 5), equation y = 2x. From (0, 0) to (5, 5), slope = 1 (a 45° line), distance 7.071, midpoint (2.5, 2.5). From (-2, 3) to (3, -7), slope = -2, angle -63.43°, distance 11.18, midpoint (0.5, -2). This page shows the formula, step-by-step workings, worked examples and sources.

Worked examples

From (1, 2) to (4, 8)

Slope 2, climbing at 63.43°; the points are 6.708 apart with midpoint (2.5, 5). (1 · 2 · 4 · 8)

Slope2
Angle of incline63.43°
Distance between points6.7082
Midpoint(2.5, 5)
Equation of the liney = 2x + 0

From (0, 0) to (5, 5)

The 45° diagonal: slope exactly 1, distance 7.071. (0 · 0 · 5 · 5)

Slope1
Angle of incline45.00°
Distance between points7.0711
Midpoint(2.5, 2.5)
Equation of the liney = 1x + 0

From (−2, 3) to (3, −7)

A falling line: slope −2 at −63.43°, distance 11.18, midpoint (0.5, −2). (-2 · 3 · 3 · -7)

Slope-2
Angle of incline-63.43°
Distance between points11.1803
Midpoint(0.5, -2)
Equation of the liney = -2x − 1

Slope is a ratio, not a mystery

Slope is a ratio, not a mystery. Strip away the algebra and you are left with a simple comparison: how far up or down a line moves compared with how far across it travels. The formula slope m = (y2 - y1) / (x2 - x1) is just rise over run written in symbols. Rise is the vertical change between two points, and run is the horizontal change. A slope calculator does this division for you instantly, but the reasoning behind it is something you can follow step by step.

Take the verified example from (1, 2) to (4, 8). The rise is 8 - 2 = 6, and the run is 4 - 1 = 3. Divide 6 by 3 and the slope is 2. In plain terms, the line gains 2 units of height for every 1 unit across. The same two points also reveal more about the line: the distance between them is 6.708 by the Pythagorean theorem, the midpoint is (2.5, 5) by averaging the coordinates, and the line's equation is y = 2x when you use point-slope form. One ratio opens the door to all of it.

The sign of the slope tells you which way the line leans. From (-2, 3) to (3, -7), the rise is -7 - 3 = -10 and the run is 3 - (-2) = 5, giving a slope of -2. The line drops 2 units for every 1 unit across, and the angle of incline is -63.43 degrees. Compare that with the line from (0, 0) to (5, 5), where the rise and run are both 5. The slope is 1, which is a 45 degree line, with a distance of 7.071 and a midpoint of (2.5, 2.5). A slope of 1 means the line rises and runs by the same amount at every step.

Two special cases break the pattern. A vertical line, where x1 equals x2, has an undefined slope because the run is zero and you cannot divide by zero. A horizontal line has a slope of exactly 0 because the rise is zero. The angle of incline is arctan of m, converting the ratio into degrees, which is why a slope of 1 always equals 45 degrees. Road grades take this ratio and multiply by 100 to quote it as a percentage, so a slope of 0.05 becomes a 5 percent grade.

A slope of 2 means the line gains 2 units of height per unit across. A slope of -2 means it drops 2 units per unit across. Same ratio, opposite direction.

One pair of points, five answers

A slope calculator does more than find one number. From a single pair of points, the same coordinate differences produce five distinct results: the slope, the angle of incline, the straight-line distance, the midpoint, and the equation of the line. Each answer is a one-line derivation from the two values you already computed — the rise (y2 - y1) and the run (x2 - x1).

Slope itself is rise over run: m = (y2 - y1) / (x2 - x1). Once you have m, the angle of incline is arctan(m), converting that ratio into degrees. A slope of 1, for example, corresponds to 45°. The distance comes from Pythagoras, using the rise and run as the two legs of a right triangle. The midpoint is simply the average of the coordinates: ((x1 + x2) / 2, (y1 + y2) / 2). The line's equation follows from point-slope form, plugging in m and one of the original points. Road grades quote slope multiplied by 100 as a percentage, so a slope of 1 becomes a 100% grade.

The table below shows three verified point pairs with all five results. Notice how each column traces back to the same rise and run. From (1, 2) to (4, 8), the rise is 6 and the run is 3, giving a slope of 2, an angle of 63.43°, a distance of 6.708, a midpoint of (2.5, 5), and the equation y = 2x. From (0, 0) to (5, 5), the rise and run are both 5, so the slope is 1 — a 45° line — with a distance of 7.071 and a midpoint of (2.5, 2.5). From (-2, 3) to (3, -7), the rise is -10 and the run is 5, giving a slope of -2, an angle of -63.43°, a distance of 11.18, a midpoint of (0.5, -2), and a line descending from left to right.

Two edge cases deserve attention. A vertical line, where x1 equals x2, has an undefined slope because the run is zero — division by zero is not allowed. A horizontal line, where y1 equals y2, has a slope of exactly 0 because the rise is zero. In both cases the other four results still exist: the distance, midpoint, and equation remain well defined, and the angle is either 90° or 0°.

Point 1Point 2Slope (m)AngleDistanceMidpointEquation
(1, 2)(4, 8)263.43°6.708(2.5, 5)y = 2x
(0, 0)(5, 5)145°7.071(2.5, 2.5)—
(-2, 3)(3, -7)-2-63.43°11.18(0.5, -2)—
Every result in the table comes from the same two differences — rise and run. Compute them once, and the slope, angle, distance, midpoint, and equation each follow in a single step.

How to use this slope calculator

To use this slope calculator, enter the coordinates of your two points. The formula behind the result is slope m = (y2 - y1) / (x2 - x1), which is rise over run. You can enter the two points in either order and still get the same slope, as long as you pair the subtractions consistently. In other words, if you swap which point is first, you subtract in the opposite order for both x and y, so the negatives cancel out.

One special case to watch for is a vertical line, where x1 = x2. Here the run is zero, so the slope is undefined. A horizontal line, by contrast, has a slope of exactly 0 because the rise is zero. For all other lines, the same two points you enter also let the tool report the distance between the points by Pythagoras, the midpoint by averaging the coordinates, and the line's equation from point-slope form. The angle of incline is arctan(m), which converts the ratio into degrees. A slope of 1, for example, corresponds to a 45 degree line. Road grades often quote slope multiplied by 100 and expressed as a percentage.

A few verified examples show what to expect. From (1, 2) to (4, 8), the slope is 2, the angle is 63.43 degrees, the distance is 6.708, the midpoint is (2.5, 5), and the equation is y = 2x. From (0, 0) to (5, 5), the slope is 1, a 45 degree line, with distance 7.071 and midpoint (2.5, 2.5). From (-2, 3) to (3, -7), the slope is -2, the angle is -63.43 degrees, the distance is 11.18, and the midpoint is (0.5, -2).

Slope, angle and grade: three dialects

Slope, angle and grade: three dialects

Slope, angle, and grade describe the same tilt, but each field speaks its own dialect. Mathematicians use the ratio: slope m = (y2 - y1) / (x2 - x1), rise over run. Surveyors convert that ratio into degrees with the angle of incline, arctan(m). Road engineers multiply the slope by 100 and quote it as a percentage. A slope of 1 is 45 degrees, and that same line is a 100 percent grade. Our slope calculator handles all three so you can move between them without confusion.

That last point is worth pausing on, because 100 percent grade sounds like a vertical wall to many drivers. It is not. A 100 percent grade simply means the rise equals the run, which is a 45 degree line. A vertical line, where x1 equals x2, has an undefined slope because the run is zero, so you cannot even compute a percentage. A horizontal line has slope exactly 0, which is a 0 percent grade. The percent grade scale keeps climbing past 100 as the angle steepens toward vertical, but it never reaches a wall within ordinary arithmetic.

The angle of incline is arctan(m), converting the ratio into degrees. For the line from (0, 0) to (5, 5), slope is 1, a 45 degree line, with distance 7.071 and midpoint (2.5, 2.5). Move to (1, 2) through (4, 8) and slope rises to 2, angle 63.43 degrees, distance 6.708, midpoint (2.5, 5), equation y = 2x. Drop to the line from (-2, 3) to (3, -7) and slope is -2, angle -63.43 degrees, distance 11.18, midpoint (0.5, -2). The same two points also give distance by Pythagoras, the midpoint by averaging coordinates, and the line's equation from point-slope form.

Negative angles simply mean the line descends as you move left to right. The ratio, the degree measure, and the percent grade all agree underneath, they just report the same fact in different units. Knowing which dialect your project uses prevents costly mistakes, especially when a specification says percent grade and a drawing shows degrees.

  • Slope m = (y2 - y1) / (x2 - x1): the mathematician's ratio, rise over run.
  • Angle = arctan(m): the surveyor's measure in degrees; slope 1 gives 45 degrees.
  • Percent grade = slope x 100: the road engineer's measure; slope 1 gives 100 percent, which is 45 degrees, not vertical.
  • Vertical line (x1 = x2): undefined slope, because run is zero.
  • Horizontal line: slope exactly 0, which is 0 percent grade.
A 100 percent grade is a 45 degree slope, not a vertical wall. Vertical lines have undefined slope because the run is zero, so no percentage applies.

From slope to the equation of the line

Once a slope calculator has found the slope m from two points, you can write the full equation of the line in point-slope form. The point-slope form is y - y1 = m(x - x1), where (x1, y1) is either of the two points you started with. Because the slope is rise over run, m = (y2 - y1) / (x2 - x1), the same value works no matter which point you pick. After substituting m and one point, a little algebra rearranges the equation into the familiar slope-intercept form, y = mx + b. In that form, b is the y-intercept, the exact spot where the line crosses the y-axis.

A concrete example shows how this works. Take the two points (1, 2) and (4, 8). The slope is (8 - 2) / (4 - 1) = 6 / 3 = 2. Using point-slope form with the first point, you get y - 2 = 2(x - 1). Distribute the 2 on the right side: y - 2 = 2x - 2. Add 2 to both sides and the equation becomes y = 2x + 0, or simply y = 2x. Using the second point instead gives the same result: y - 8 = 2(x - 4), which simplifies to y - 8 = 2x - 8, and again y = 2x. Because b equals 0, this line passes straight through the origin, crossing the y-axis at the point (0, 0).

The y-intercept is what makes the slope-intercept form so useful for graphing and prediction. Once you know m and b, you can plot any point on the line by plugging in an x-value and solving for y. A line with a positive slope rises from left to right, while a line with a negative slope falls. For example, the points (-2, 3) and (3, -7) produce a slope of -2, so that line tilts downward as x increases. A horizontal line has a slope of exactly 0, giving the equation y = b, since the line never rises or falls. A vertical line, where x1 equals x2, has an undefined slope because the run is zero, so it cannot be written in y = mx + b form at all.

The same two points that produce the line's equation also reveal other geometric properties. By applying the Pythagorean theorem to the horizontal and vertical distances between the points, you get the straight-line distance. Averaging the x-coordinates and the y-coordinates gives the midpoint. For the (1, 2) to (4, 8) example, the distance is 6.708 and the midpoint is (2.5, 5). The angle of incline is arctan(m), which converts the slope ratio into degrees. A slope of 1 corresponds to 45 degrees, and a slope of 2 corresponds to 63.43 degrees. Road grades quote slope multiplied by 100 as a percentage, so a slope of 0.05 is a 5 percent grade.

Where slope shows up outside maths class

Slope is not just a topic in a textbook. The same rise-over-run ratio that a slope calculator computes shows up in building design, accessibility codes, plumbing, and data analysis. Wherever a surface or a trend rises or falls at a steady rate, the math is identical.

Roofers describe pitch as rise over a 12-unit run. A roof that rises 4 inches for every 12 inches of horizontal distance is called a 4:12 pitch, which is simply a slope of 4 divided by 12, or 0.333. Wheelchair ramps follow the same logic: accessibility guidelines set a maximum slope of 1:12, meaning 1 inch of rise for every 12 inches of run. That ratio equals a slope of about 0.083, or an incline angle of roughly 4.76 degrees. Drainage pipes use the same idea in reverse, with a gentle fall so water moves without flowing too fast.

Road grades quote slope as a percentage, multiplying the ratio by 100. A 5% grade means the road rises 5 feet over 100 feet of horizontal distance, giving a slope of 0.05. The angle of incline comes from arctan(m), so a 5% grade tilts upward at about 2.86 degrees. A slope of 1 is 45 degrees, and a vertical line is undefined because the run is zero while a horizontal line sits at exactly 0.

In data analysis, trend lines use the same formula. A scatter plot of two variables gets a line of best fit whose slope tells you how much the y-value changes per unit of x. A slope of 2 means each step in x adds 2 to y, the same relationship seen in the line y = 2x. Whether you are checking a roof, a ramp, a pipe, or a chart, the ratio is always rise divided by run.

FAQs

How do you calculate slope?

Use the formula m = (y2 - y1) / (x2 - x1). For example, from (1, 2) to (4, 8): (8 - 2) / (4 - 1) = 2. Subtract the first point's y and x from the second point's y and x, then divide the y difference by the x difference to get the slope.

What is the distance between the two points?

Use the Pythagorean theorem on the same differences. From (1, 2) to (4, 8) it is sqrt(3² + 6²) = 6.708. The horizontal difference is 3 and the vertical difference is 6, so the straight-line distance between the points equals 6.708 units.

What does a slope of 2 mean?

The line rises 2 units for every 1 unit across — an incline of 63.43°, or a 200% grade. This means for each step right on the x-axis, the line goes up twice as far on the y-axis, creating a steep upward angle.

Why is the slope of a vertical line undefined?

Its run is zero, and dividing by zero is undefined — not infinite. A horizontal line, by contrast, has slope exactly 0. Since slope equals rise divided by run, a vertical line has no run, making the calculation impossible rather than infinite.

How do I get the equation of the line?

Use y - y1 = m(x - x1) with either point, then rearrange: the (1, 2) to (4, 8) line is y = 2x. Plug in the slope and one point's coordinates, distribute, and solve for y to get the equation in slope-intercept form.

Does the order of the points matter?

No, provided both subtractions use the same order: (2 - 8) / (1 - 4) also equals 2. Mixing orders flips the sign — the most common slope error. Always subtract the coordinates in the same sequence for both x and y to get the correct result.

Sources

Related calculators

Quadratic Equation Calculator
Solve ax² + bx + c = 0 with the quadratic formula: both roots, the discriminant, the vertex and the axis of symmetry — with a substitution check.
Pythagorean Theorem Calculator
Find the hypotenuse from two legs, or a missing leg from the hypotenuse — with area and perimeter of the triangle thrown in.
Triangle Calculator
Triangle area three ways: base × height, Heron's formula from three sides, or two sides with the included angle — plus perimeter and side classification.
Percent Error Calculator
Percent error between a measured and an accepted value — plus absolute error and percent difference, and when to use each.