Distance Formula Calculator
Enter the x and y coordinates of two points and this tool returns the straight-line distance between them along with the midpoint of the segment and the slope of the line through them. The distance comes from the Pythagorean theorem, taking the square root of the squared horizontal gap plus the squared vertical gap. Distance, midpoint and slope are each rounded to four decimal places, and the change in x and change in y are shown so you can follow the steps.
How to use the distance formula
- Under Point 1, type the coordinates into the x1 and y1 fields.
- Under Point 2, type the coordinates into the x2 and y2 fields.
- Read the Distance card for the straight-line length between the two points.
- Check the Midpoint, Slope, delta x and delta y cards for the full breakdown of the segment.
- Click Copy result to place every value on your clipboard as labelled lines of text.
Examples
A 3-4-5 right triangle
(1, 2) and (4, 6)
distance 5, midpoint (2.5, 4), slope 1.3333, delta x 3, delta y 4
A vertical line has no slope
(0, 0) and (0, 5)
distance 5, midpoint (0, 2.5), slope undefined
Negative coordinates and a square root distance
(0, 0) and (3, 3)
distance 4.2426, midpoint (1.5, 1.5), slope 1
Frequently asked questions
What is the distance formula?
The distance between two points is the square root of the change in x squared plus the change in y squared. It is the Pythagorean theorem applied to the right triangle whose legs are the horizontal and vertical gaps between the points.
How is the midpoint found?
The midpoint is the average of the two x coordinates paired with the average of the two y coordinates. For (1, 2) and (4, 6) that is ((1+4)/2, (2+6)/2), which is (2.5, 4), the exact center of the segment.
Why is the slope sometimes undefined?
Slope is the change in y divided by the change in x. When both points share the same x coordinate the change in x is zero, the line is vertical, and division by zero has no value, so the tool shows the slope as undefined rather than a number.
What do the delta x and delta y cards mean?
Delta x is the second x minus the first x, and delta y is the second y minus the first y. They are the horizontal and vertical legs of the triangle the distance is built from, shown so you can retrace the calculation.
Does the order of the points matter?
The distance and midpoint are identical whichever point you enter first, because squaring and averaging erase the sign of the difference. The slope is also the same, though delta x and delta y will flip sign if you swap the points.
Why are some results rounded?
Distances and slopes are often irrational, so every output is rounded to four decimal places to tame floating-point noise and keep the display readable. A distance shown as 4.2426 is the square root of 18 to that precision.
Can I use negative or decimal coordinates?
Yes. Every field accepts any finite number, positive, negative or decimal, across a wide range. Only infinite or non-numeric values are rejected, in which case the tool shows a short error instead of a result.
Does this measure distance on a map or a globe?
No. This is straight-line distance on a flat plane using Cartesian x and y coordinates. Distances between latitude and longitude points on the curved surface of the Earth need a great-circle formula instead.
Is my input private?
Yes. The whole calculation happens in your browser as you type. No coordinates are sent to a server or stored anywhere.
Learn more
- The distance formula and the Pythagorean theorem
Why the distance between two points is just the Pythagorean theorem in disguise, plus midpoint and slope worked through.
Related tools
Distance Between Two Points Calculator
Find the distance between two points with the distance formula. Get the length, midpoint and slope of the segment, computed live with full precision.
Slope Calculator
Find the slope, y-intercept, line equation, distance, midpoint and angle from two points. Enter two coordinates and read every value instantly.
Pythagorean Theorem Calculator
Find the missing side of a right triangle with a squared plus b squared equals c squared. Get the legs, hypotenuse, area and perimeter instantly.
Vector Calculator
Add, subtract, scale, and find the dot and cross product of 2D and 3D vectors. Get magnitude, unit vector, angle, distance, and projection instantly.
Annulus Area Calculator
Calculate the area of an annulus, the ring between two concentric circles, from its outer and inner radius. Returns both circumferences and width too. Free.
Area Calculator
Find the area of a circle, square, rectangle, triangle, trapezoid, parallelogram, ellipse, sector or rhombus. Free and runs in your browser.