Smekys
Ad Space

Distance Formula Calculator

Free distance formula calculator finds the straight-line distance between two points (x1,y1) and (x2,y2), plus midpoint and slope, step by step.

Enter Values

units

The horizontal coordinate of the first point (x1, y1). May be negative.

units

The vertical coordinate of the first point (x1, y1). May be negative.

units

The horizontal coordinate of the second point (x2, y2). Must differ from x1.

units

The vertical coordinate of the second point (x2, y2). May be negative.

Result

Distance Between Points
5
Horizontal Change (dx)
3
Vertical Change (dy)
4
Midpoint — x coordinate
1.5
Midpoint — y coordinate
2
Slope of Segment
1.33

The distance formula is one of the first things students meet in coordinate geometry, and it quietly powers everything from GPS mapping to game physics. It grows directly out of the Pythagorean theorem: if you know the coordinates of two points on a flat plane, the straight line between them becomes the hypotenuse of a right triangle whose legs are the horizontal and vertical gaps. This distance formula calculator takes the four coordinates for your two points, applies that theorem step by step, and also returns the midpoint of the segment and its slope.

Type in the coordinates and every result updates instantly. Because the midpoint sits exactly 50% of the way along the segment and the slope tells you how steeply the line climbs, you get the whole geometry of the segment in one screen.

How to Use

  1. Enter the x coordinate of Point 1 — the horizontal position of your first point, usually written x1.
  2. Enter the y coordinate of Point 1 — the vertical position, y1.
  3. Enter the x and y coordinates of Point 2 (x2 and y2). Negative coordinates are perfectly fine: the formula squares the differences, so signs disappear inside the calculation.
  4. Read the result card. The Distance line is the straight-line (Euclidean) distance; below it you see the horizontal change dx and vertical change dy that fed the formula, the Midpoint coordinates, and the Slope of the segment.
  5. If the calculator returns "undefined slope", your two points share the same x value — the segment is vertical, and rise-over-run would divide by zero. Pick a different x2 to continue.

The engine computes dx = x2 − x1 and dy = y2 − y1, then evaluates d = √(dx² + dy²). It uses a numerically stable hypot routine so that even coordinates around a million do not overflow when squared.

The Distance Formula

For two points (x1, y1) and (x2, y2), the distance formula is:

d = √((x2 − x1)² + (y2 − y1)²)

You can read it as the Pythagorean theorem on a coordinate grid. Plot the two points, draw a horizontal leg from the first point to align vertically under the second, and a vertical leg up to the second point. The leg lengths are dx and dy. The straight line you wanted is the hypotenuse c, and c² = a² + b² becomes d² = dx² + dy². Taking the square root gives d.

The companion quantities fall out for free:

  • dx = x2 − x1 — how far right (positive) or left (negative) you move.
  • dy = y2 − y1 — how far up (positive) or down (negative) you move.
  • Midpoint M = ((x1 + x2)/2, (y1 + y2)/2) — the point halfway between them.
  • Slope m = dy / dx — the steepness; expressed as a percent, a slope of 1.00 is a 100% grade.

Worked example on (0, 0) and (3, 4): dx = 3, dy = 4, so d = √(9 + 16) = √25 = 5. The midpoint is ((0+3)/2, (0+4)/2) = (1.5, 2), and the slope is 4/3 ≈ 1.33, a rise of about 133% for every unit run.

Why Negative Coordinates Are No Problem

A common worry is that a negative coordinate will "break" the square root. It cannot, because each difference is squared before it is added. Take (−3, −2) and (1, 1): dx = 1 − (−3) = 4 and dy = 1 − (−2) = 3. Squaring both gives 16 and 9, exactly as in the classic 3-4-5 case, so d = 5. The midpoint is (−1, −0.5), and the slope is 3/4 = 0.75. Signs only affect where the points sit on the plane, not how far apart they are.

Examples

Example 1 — The textbook 3-4-5. Points (0, 0) and (3, 4). dx = 3, dy = 4, distance = √(9 + 16) = 5.00, midpoint (1.5, 2.0), slope 1.33. This is the most-asked example in algebra homework, and it is the default loaded on the page.

Example 2 — A long baseline offset by a million. Points (1,000,000, 0) and (1,000,003, 4). Because both x coordinates share the same large offset, dx is still just 3 and dy is 4, so the distance stays 5.00 even though the numbers are huge. The midpoint lands at (1,000,001.5, 2.0). This shows why the calculator uses a stable hypot routine: squaring 1,000,000 directly would risk overflow on very large inputs.

Example 3 — Scaled up by two. Points (2, 3) and (8, 11). dx = 6, dy = 8, distance = √(36 + 64) = √100 = 10.00, midpoint (5, 7), slope 1.33. Doubling both legs doubles the distance and keeps the slope — the segment is just a scaled copy of the 3-4-5 triangle.

FAQ

What is the distance formula?

The distance formula is d = √((x2 − x1)² + (y2 − y1)²). It is the Pythagorean theorem applied to two points on a coordinate plane: the horizontal difference and vertical difference are the legs of a right triangle, and the straight-line distance between the points is the hypotenuse.

How do I find the distance between (0,0) and (3,4)?

Substitute into the formula: dx = 3 − 0 = 3 and dy = 4 − 0 = 4. Then d = √(3² + 4²) = √(9 + 16) = √25 = 5. The distance is 5 units. The midpoint is (1.5, 2) and the slope is 4/3 ≈ 1.33.

Can the coordinates be negative?

Yes. Negative coordinates are handled exactly like positive ones because each difference is squared before it is added. For (−3, −2) and (1, 1), dx = 4 and dy = 3, giving a distance of 5 — the same as the classic 3-4-5 case.

What is the midpoint of a segment?

The midpoint is the point exactly halfway between the two endpoints: M = ((x1 + x2)/2, (y1 + y2)/2). For (0, 0) and (3, 4) it is (1.5, 2.0). Geometrically it sits 50% of the way along the segment, and the distance from either endpoint to the midpoint is half the total distance.

Why is my slope undefined?

Slope is dy / dx, so it is undefined when x2 equals x1 — that makes dx = 0 and you would divide by zero. This happens for a vertical segment: the line goes straight up and down and has no single steepness. Change one of the x coordinates and the slope will appear.

Is this the same as Euclidean distance?

Yes. The distance formula computes the Euclidean (straight-line) distance, the shortest possible distance between two points in a flat plane. It is distinct from Manhattan (grid) distance, which adds |dx| + |dy| instead of combining them through a square root.

Disclaimer

This distance formula calculator is provided for informational purposes only and does not constitute mathematical, engineering, or academic advice. Results are computed directly from the coordinates you enter using the standard Euclidean distance formula; rounding and display precision may vary slightly from hand calculations. Always double-check critical measurements against a trusted source before relying on them.

Related Calculators

Disclaimer

Results are estimates for illustration only. Verify important figures independently.