Distance, Midpoint & Slope Calculator

Coordinate geometry problems usually start with two points. Enter their coordinates to get the distance between them, the midpoint, the slope, the angle with the x-axis and the equation of the line, all with working.

How it is calculated

Enter the coordinates of both points.

Read the distance, midpoint and slope.

Use the line equation for graphing.

Formula

Distance: d = √((x₂ − x₁)² + (y₂ − y₁)²)

Midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)

Slope: m = (y₂ − y₁) ÷ (x₂ − x₁)

What is the Distance, Midpoint & Slope Calculator?

Give this calculator two points, (x₁, y₁) and (x₂, y₂), and it returns five results: the straight-line distance between them, the midpoint, the slope, the angle the line makes with the x-axis, and the equation of the line in the form y = mx + c. Vertical lines, where the slope is undefined, are handled as x = constant.

Coordinate geometry is introduced in Class 9 and developed in Class 10 and Class 11, and the distance, section and slope formulas are among the most used results in board and entrance exams. The same ideas appear in maps and GPS, computer graphics, game development, and in plotting data to find a trend. Working through one pair of points gives you every basic property of the segment and the line through it.

How to calculate it by hand

1. Find the horizontal and vertical changes: Δx = x₂ − x₁ and Δy = y₂ − y₁.

2. Distance: d = √(Δx² + Δy²).

3. Midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).

4. Slope: m = Δy ÷ Δx. If Δx = 0, the line is vertical and its equation is x = x₁.

5. Intercept: c = y₁ − m × x₁, giving the line y = mx + c.

6. Angle with the x-axis: θ = tan⁻¹(m), taking account of the direction from the first point to the second.

The distance formula is Pythagoras

Draw a horizontal line from the first point and a vertical line from the second. They meet at a right angle, forming a right triangle with legs |Δx| and |Δy|. The segment joining the points is the hypotenuse, so its length is √(Δx² + Δy²). Squaring removes any negative signs, so the order of the points does not matter. The same idea gives √(Δx² + Δy² + Δz²) for points in three dimensions.

Midpoint and the section formula

The midpoint is simply the average of the x-coordinates and the average of the y-coordinates, because moving halfway along the segment means moving halfway in each direction. It is the special case of the section formula: a point dividing the segment in ratio m : n is ((mx₂ + nx₁) ÷ (m + n), (my₂ + ny₁) ÷ (m + n)). With m = n = 1 this gives the midpoint. The centroid of a triangle is found the same way, by averaging three vertices.

Slope, angle and the line's equation

Slope measures rise over run: how much y changes for each unit increase in x. It equals tan θ, where θ is the angle with the positive x-axis. Positive slope rises to the right, negative falls, zero is horizontal, and a vertical line has no defined slope. Two lines are parallel when their slopes are equal and perpendicular when their slopes multiply to −1. The calculator reports the direction angle from point 1 to point 2, which can be negative or exceed 90°.

Worked example, step by step

On a graph-paper map for a school project, Neha marks the bus stop at (−2, 1) and her house at (4, 9), with each square representing 100 metres.

Distance: d = √((x₂ − x₁)² + (y₂ − y₁)²) d = √((6)² + (8)²) = √100 = 10

Midpoint: ((-2 + 4) ÷ 2, (1 + 9) ÷ 2) = (1, 5)

Slope: m = (y₂ − y₁) ÷ (x₂ − x₁) = 8 ÷ 6 = 1.333333

Equation of the line: c = y₁ − m x₁ = 1 − 1.3333 × -2 = 3.6667 y = 1.3333x + 3.6667

Answer: Distance 10; Midpoint (1, 5); Slope 1.333333

Common mistakes to avoid

Mixing up the order in the slope, such as (y₂ − y₁) ÷ (x₁ − x₂), which flips the sign.

Forgetting that squaring a negative difference gives a positive number in the distance formula.

Subtracting coordinates for the midpoint instead of adding them.

Writing y = mx + c for a vertical line instead of x = constant.

Taking tan⁻¹ of the slope and ignoring which quadrant the direction actually points into.

Where it is used

Solving Class 9 to 11 coordinate geometry problems quickly and checking answers.

Finding straight-line distances between places on a map grid.

Locating a meeting point halfway between two positions.

Finding the gradient of a road, ramp or graph between two readings.

Computing positions, directions and collisions in games and graphics.

Frequently asked questions

What does an undefined slope mean?

The line is vertical (x₁ = x₂), so its equation is x = constant.

Can I use negative coordinates?

Yes, any real coordinates work.