Slope Calculator: Slope, Line Equation and Distance
Find the slope of the line through two points, as a fraction for whole-number points, with the slope-intercept, point-slope and standard forms, the distance, the midpoint and the angle, with steps. Free in your browser.
Slope
- Slope (m)
- 2
- Δx and Δy
- 3 and 6
m = (y₂ − y₁) / (x₂ − x₁) = (8 − 2) / (4 − 1) = 6 / 3 = 2
Equation of the line
- Slope-intercept form
- y = 2x
- y-intercept (b)
- 0
- Point-slope form
- y − 2 = 2(x − 1)
- Standard form
- 2x − y = 0
b = y₁ − m × x₁ = 2 − 2 × 1 = 0
Distance
- Distance (d)
- 6.7082039325
- Exact distance
- √45 = 3√5
d = √((4 − 1)² + (8 − 2)²) = √(9 + 36) = √45 = 3√5 = 6.7082039325
Midpoint
- Midpoint (M)
- (2.5, 5)
M = ((1 + 4) / 2, (2 + 8) / 2) = (2.5, 5)
Angle
- Angle with the x-axis
- 63.4349488229°
θ = atan(m) = atan(2) = 63.4349488229°
Slope Calculator
Enter two points and this calculator describes the straight line through them. It gives the slope, as a reduced fraction when the points have whole-number coordinates, the equation of the line in slope-intercept, point-slope and standard form, the y-intercept, the distance between the points, the midpoint and the angle the line makes with the x-axis. Every result shows its working. The page opens with the points (1, 2) and (4, 8).
The slope formula
The slope is "rise over run": how far the line goes up for each step to the right. A positive slope rises, a negative slope falls, a slope of 0 is a horizontal line and a vertical line has an undefined slope, because Δx is 0.
Three forms of a line
Forms
- Slope-intercept form: y = mx + b, where b is the y-intercept. For (1, 2) and (4, 8) it is y = 2x.
- Point-slope form: y − y₁ = m(x − x₁), built from the first point: y − 2 = 2(x − 1).
- Standard form: Ax + By = C. For whole-number points, A, B and C are whole numbers with no common factor and A is positive: 2x − y = 0.
Worked example
(−2, 3) and (4, −1)
Δx = 6 and Δy = −4, so m = −4 / 6 = −2/3. The intercept is b = 3 − (−2/3)(−2) = 3 − 4/3 = 5/3, so the line is y = −2/3x + 5/3, or 2x + 3y = 5 in standard form. The distance is √(36 + 16) = √52 = 2√13 = 7.21110255093, the midpoint is (1, 1) and the angle is atan(−2/3) = −33.690067526°.
Distance, midpoint and angle
The angle is measured from the positive x-axis and lies between −90° and 90°; a vertical line makes 90°.
Special lines
A horizontal line through (1, 4) and (6, 4) has slope 0 and the equation y = 4. A vertical line through (3, 1) and (3, 5) has an undefined slope, no y-intercept and the equation x = 3. The two points must be different, since one point does not fix a line.
Parallel and perpendicular lines
Two lines are parallel when they have the same slope, such as y = 2x and y = 2x + 5. They are perpendicular when their slopes multiply to −1, so a line with slope 2 meets a line with slope −1/2 at a right angle. A horizontal line is perpendicular to every vertical line. To write a parallel line through another point, keep m and work out a new intercept from that point; for a perpendicular line, use the negative reciprocal of m instead.
Reading the results
Each result card shows the value first and then the formula with your numbers substituted, so you can copy the working. Whole-number points also give exact fractions and radicals next to the decimals, which keeps homework answers exact. Results print with 12 significant digits, and coordinates must lie between −1e150 and 1e150.
Privacy
Nothing is uploaded; every calculation runs in your browser and never leaves your device.
Related tools
The Distance Formula Calculator and Midpoint Calculator open this tool with that result first. The Right Triangle Calculator solves the triangle formed by Δx, Δy and the distance, and the Fraction Calculator works with fractional slopes.
Frequently asked questions
How do I find the slope from two points?
Divide the change in y by the change in x: m = (y₂ − y₁) / (x₂ − x₁). For (1, 2) and (4, 8) that is 6 / 3 = 2. For (−2, 3) and (4, −1) it is −4 / 6, which reduces to −2/3.
What are the slope-intercept, point-slope and standard forms?
Slope-intercept form is y = mx + b, where b is where the line crosses the y-axis. Point-slope form is y − y₁ = m(x − x₁), using the first point. Standard form is Ax + By = C; for whole-number points A, B and C are whole numbers with no common factor.
What is the slope of a vertical line?
It is undefined, because Δx is 0 and you cannot divide by zero. The line's equation is x = k, it has no y-intercept, and it makes a 90° angle with the x-axis. A horizontal line has slope 0 and the equation y = k.
Why are some slopes shown as fractions?
When all four coordinates are whole numbers, the slope and the y-intercept are exact fractions, such as −2/3 and 5/3, so the page shows them reduced alongside the decimal. With decimal points only the decimal is shown.
How is the angle worked out?
The angle with the positive x-axis is atan(m), between −90° and 90°. A slope of 1 makes 45°, a slope of 2 makes 63.4349488229°, and a negative slope gives a negative angle.
Does the calculator also give the distance and midpoint?
Yes. The distance is √(Δx² + Δy²), with the exact radical for whole-number points, such as √45 = 3√5. The midpoint is the average of the two points' coordinates.