Through M(2.5, 4) at right angles to P₁P₂: y = −0.75x + 5.875.
About the slope, distance and midpoint calculator
Enter two points to get the straight-line distance d = √((x₂ − x₁)² + (y₂ − y₁)²), the midpoint ((x₁ + x₂)/2, (y₁ + y₂)/2) and the slope m = (y₂ − y₁)/(x₂ − x₁). The line through them is written in slope-intercept form y = mx + b, in standard form Ax + By = C with whole-number coefficients and in point-slope form, alongside its perpendicular bisector. Fractions stay exact, so a slope of 4/3 is not rounded to 1.3333.
The default points (1, 2) and (4, 6) are 5 apart, a 3-4-5 triangle, with midpoint (2.5, 4) and line y = (4/3)x + 2/3. Switching on a second line adds whether the two are parallel, perpendicular or intersecting, the angle between them and the crossing point.
A vertical line has no slope, so only its standard form, such as x = 3, is given. Coordinates carry no unit: the distance is in whatever unit they use.
How to find the slope between two points
Slope is the change in y divided by the change in x: m = (y₂ − y₁)/(x₂ − x₁) (OpenStax, College Algebra 2e, §4.1). From (2, 3) to (6, 11), y rises 8 while x runs 4, so m = 8/4 = 2, a climb of 2 units per unit to the right. Any two points with different x-values have one.
Distance and midpoint formulas
The distance between two points is Pythagoras' theorem applied to the horizontal and vertical gaps: d = √((x₂ − x₁)² + (y₂ − y₁)²). For (2, 3) and (6, 11), d = √(4² + 8²) = √80 = 4√5 ≈ 8.94427191.
The midpoint averages each coordinate: M = ((x₁ + x₂)/2, (y₁ + y₂)/2). Here M = ((2 + 6)/2, (3 + 11)/2) = (4, 7).
Equation of a line through two points
Put the slope into y = mx + b and find the intercept from either point: b = y₁ − mx₁ = 3 − 2 × 2 = −1, so the line is y = 2x − 1. Substituting the other point checks it: 2 × 6 − 1 = 11.
The same line in standard form is 2x − y = 1, and in point-slope form y − 3 = 2(x − 2). Its angle of inclination, measured counterclockwise from the positive x-axis, is arctan 2 ≈ 63.43°.
Positive, negative, zero and undefined slope
Positive: the line rises from left to right.
Negative: it falls from left to right.
Zero: it is horizontal, with an equation y = constant.
Undefined: it is vertical, x = constant, because the run x₂ − x₁ is zero.
Slope, distance and midpoint examples
Points
Distance
Slope
Midpoint x, y
(1, 2) to (4, 6)
5
1.33333333
2.5, 4
(0, 0) to (3, 4)
5
1.33333333
1.5, 2
(0, 0) to (2, 2)
2.82842712
1
1, 1
(0, 4) to (4, 0)
5.65685425
-1
2, 2
(3, 1) to (3, 7)
6
Undefined (vertical)
3, 4
(-2, 5) to (4, 5)
6
0
1, 5
(-3, -4) to (0, 0)
5
1.33333333
-1.5, -2
(1/2, 1) to (5/2, 4)
3.60555128
1.5
1.5, 2.5
From (0, 4) to (4, 0), y falls 4 while x rises 4, so the slope is −1. The first two rows share the slope 4/3 (1.33333333 rounded), and both are 3-4-5 triangles, so their distance is 5.
The vertical segment from (3, 1) to (3, 7) still has a length and a midpoint; only its slope is missing. Fractions work like any number: from (1/2, 1) to (5/2, 4), m = 3/2.
Parallel and perpendicular lines
Parallel lines have equal slopes. Perpendicular lines have slopes that multiply to −1, so a line perpendicular to slope 2 has slope −1/2; a vertical and a horizontal line are perpendicular too.
The line through (0, 0) and (4, −2) has slope −1/2, so it crosses y = 2x − 1 at a right angle, at (0.4, −0.2). For other pairs, the angle between them satisfies tan θ = |(m₂ − m₁)/(1 + m₁m₂)|.
The perpendicular bisector of a segment passes through its midpoint at a right angle, and every point on it is the same distance from both ends. For (2, 3) and (6, 11) it is y = −0.5x + 9.
Common mistakes
Subtracting in different orders. (11 − 3)/(2 − 6) = −2 has the wrong sign. Keep the same point first on top and bottom; reversing both gives (3 − 11)/(2 − 6) = 2 again.
Run over rise. 4/8 = 0.5 is the reciprocal of the slope.
Treating undefined as zero. A horizontal line has slope 0; a vertical line has no slope at all.
Latitude and longitude as x and y. A degree of longitude shrinks toward the poles, so the flat distance formula misstates map distances.
Dropping units. When x is hours and y is kilometers, the slope is a speed in km/h.
Fractions, repeated points and a second line
Fractions such as 1/2 stay exact, so the equations keep 4/3 instead of 1.3333.
Two identical points define no line, so the points must differ.
A second pair of points adds whether the lines are parallel, perpendicular, intersecting or the same line, the angle between them and where they cross.
Checked against: dx = 3, dy = 4 (3-4-5), m = 4/3, b = 2 − 4/3 = 2/3; bisector through (5/2, 4) with slope −3/4 has b = 47/8 = 5.875 (terminating fractions print as decimals)
Vertical line (edge case: no slope)
Point 1: x
3
Point 1: y
1
Point 2: x
3
Point 2: y
7
Distance P₁P₂
6
Standard form
x = 3
Angle of inclination
90 °
Perpendicular bisector
y = 4
Midpoint y
4
Checked against: Equal x-coordinates: the line x = 3 is vertical; the bisector is the horizontal line through (3, 4)
Decimal coordinates
Point 1: x
-1.5
Point 1: y
2.25
Point 2: x
3.5
Point 2: y
-0.75
Distance P₁P₂
5.83095189
Slope
-0.6
Slope-intercept form
y = −0.6x + 1.35
Standard form
12x + 20y = 27
Checked against: dx = 5, dy = −3, √34; −3x − 5y = −27/4 scaled by −4
Two intersecting lines
Point 1: x
1
Point 1: y
2
Point 2: x
4
Point 2: y
6
Compare with a second line
yes
Line 2, point 3: x
0
Line 2, point 3: y
6
Line 2, point 4: x
6
Line 2, point 4: y
0
The lines are
Intersecting
Angle between the lines
81.869898 °
Intersection x
2.28571429
Intersection y
3.71428571
Line 2
y = −x + 6
Checked against: intersection (16/7, 26/7) by with exact fractions
Questions
How do you find the slope between two points?
Divide the change in y by the change in x: m = (y₂ − y₁)/(x₂ − x₁). From (1, 2) to (4, 6) the rise is 4 and the run is 3, so m = 4/3 ≈ 1.3333. A positive slope rises to the right, a negative one falls, 0 is horizontal, and when x₂ = x₁ the line is vertical and the slope is undefined.
What is the distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)²), which is Pythagoras' theorem applied to the horizontal and vertical gaps. Between (1, 2) and (4, 6) the gaps are 3 and 4, so d = √25 = 5. For points given as latitude and longitude use a great-circle formula instead, because the flat formula ignores the Earth's curvature.
How do you find the equation of a line through two points?
Find the slope m, then the intercept b = y₁ − m·x₁, and write y = mx + b. Through (1, 2) and (4, 6), m = 4/3 and b = 2 − 4/3 = 2/3, so y = (4/3)x + 2/3. Multiplying by 3 and rearranging gives the standard form 4x − 3y = −2, with whole-number coefficients.
How do you tell if two lines are parallel or perpendicular?
For nonvertical lines, equal slopes mean the lines are parallel or coincident, and slopes whose product is −1 mean they are perpendicular, such as 1/2 and −2. A vertical and a horizontal line are also perpendicular. Distinct parallel lines do not meet. For other pairs with finite slopes, tan θ = |(m₂ − m₁)/(1 + m₁m₂)|: slopes of 4/3 and −1 give tan θ = 7, so the smaller angle between the lines is 81.87°.
What is a perpendicular bisector?
The line through the midpoint of a segment at right angles to it; every point on it is equally far from both endpoints. For (1, 2) and (4, 6) it passes through (2.5, 4) with slope −3/4, the negative reciprocal of 4/3, giving y = −0.75x + 5.875. The bisectors of a triangle's three sides meet at the centre of its circumscribed circle.
This calculator includes 6 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.
Put this calculator on your site
Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.