Skip to content
CalcTide logo
Education & Math

Distance Formula Calculator

The distance between (0, 0) and (3, 4) is 5 units. This distance formula calculator measures the straight-line distance between two points on a two-dimensional Cartesian plane. Enter the x and y coordinates for each point to get the distance plus the signed horizontal and vertical changes. The calculation treats the coordinate differences as the legs of a right triangle. It works with positive, negative, zero, and decimal coordinates. The distance is rounded to no more than 4 decimal places, while the reported changes in x and y keep the direct subtraction results. Use it to check coordinate geometry, graphing, design layouts, or any problem that asks for Euclidean distance in a flat coordinate system.

Education & MathBy

Quick answer

The distance formula finds the length of the straight line between two points.

What this tells you

  • The distance formula finds the length of the straight line between two points.
  • It uses the horizontal change (x2 - x1) and the vertical change (y2 - y1).
  • The result is the square root of the sum of those two changes squared.
  • Distance is rounded to no more than 4 decimal places, so whole-number results appear without trailing zeros.
  • The signed changes are x2 - x1 and y2 - y1, so either change can be negative even though distance cannot be negative.
  • Identical points have a horizontal change of 0, a vertical change of 0, and a distance of 0.
  • Reversing the order of the points changes the signs of both reported changes but leaves the distance unchanged.

How to Use

  1. 1Enter the x and y coordinates of the first point (x1, y1).
  2. 2Enter the x and y coordinates of the second point (x2, y2).
  3. 3Click Calculate to get the distance between the two points.
  4. 4Check Change in X and Change in Y to see the signed coordinate differences used by the formula.
  5. 5Interpret the answer in the same unit used for both coordinate axes. If coordinates are in meters, the distance is in meters.
  6. 6Keep more than the displayed 4 decimal places elsewhere if a later calculation requires higher numerical precision.

How It Works

Formula

d = sqrt((x2 - x1)^2 + (y2 - y1)^2)

The distance formula comes from the Pythagorean theorem. The horizontal change (x2 - x1) and the vertical change (y2 - y1) form the two legs of a right triangle, and the distance between the points is the hypotenuse. Squaring each change, adding them, and taking the square root gives the straight-line distance.

Calculation note: values are processed in the order shown above, using the current input units.

Worked Examples

Distance from (1, 2) to (4, 6)

X11
Y12
X24
Y26
Result5

The change in x is 4 - 1 = 3 and the change in y is 6 - 2 = 4. Square each value to get 9 and 16, add them to get 25, then take the square root to get 5.

Distance from (0, 0) to (5, 12)

X10
Y10
X25
Y212
Result13

The change in x is 5 and the change in y is 12. Square each value to get 25 and 144, add them to get 169, then take the square root to get 13.

Distance across a unit square diagonal

X10
Y10
X21
Y21
Result1.4142

Both coordinate changes equal 1. Squaring and adding gives 1 + 1 = 2, so the exact distance is sqrt(2). The calculator rounds that irrational value to 1.4142.

Distance between identical points

X17
Y1-4
X27
Y2-4
Result0

Both differences are zero because the coordinates match. The square root of 0 squared plus 0 squared is 0, so there is no separation between the points.

Second point is lower and left

X15
Y15
X22
Y21
Result5

The reported changes are -3 and -4. Their squares are 9 and 16, so the signs disappear inside the distance calculation and sqrt(25) equals 5.

Example Distances

Common point pairs and the straight-line distance between them.

Point 1Point 2Distance
(0, 0)(3, 4)5
(1, 2)(4, 6)5
(-2, -3)(1, 1)5
(0, 0)(5, 12)13

What the coordinate distance represents

The formula measures Euclidean distance, which means the shortest straight segment joining two points on a flat plane. The horizontal difference and vertical difference create perpendicular legs of a right triangle. The segment connecting the points is its hypotenuse, so the Pythagorean theorem gives the length.

Coordinate order affects direction but not length. From (5, 5) to (2, 1), the changes are -3 and -4. From (2, 1) to (5, 5), they are 3 and 4. Squaring produces 9 and 16 in either order, so both directions have distance 5. This is why distance stays non-negative even when one or both coordinate changes are negative.

The answer has the same unit as the coordinate scale when both axes use the same unit. Coordinates measured in feet produce a distance in feet. If one axis uses meters and the other uses feet, convert them to a shared unit before applying the formula. Otherwise, the result has no consistent physical meaning.

A straight-line answer is not always a travel distance. A road, hallway, trail, or grid route may require turns and obstacles. The formula also assumes a flat Cartesian plane. For latitude and longitude across Earth, a spherical or ellipsoidal geodesic method is more appropriate, especially over long distances.

Try the Midpoint Calculator

Common mistakes

  • Forgetting to square the differences. You must square both the change in x and the change in y before adding them, otherwise the result is wrong.
  • Sign errors with negative coordinates. When a coordinate is negative, subtracting it adds a positive value, so 1 - (-2) = 3, not -1.
  • Swapping x and y values. Keep the x coordinates together and the y coordinates together, and do not mix a point's x value with the other point's y value.
  • Adding coordinates instead of subtracting matching coordinates. The legs are x2 - x1 and y2 - y1, not x1 + x2 and y1 + y2.
  • Taking the square root before adding both squared changes. Add the squares first, then take one square root of the total.
  • Assuming negative delta values mean a negative distance. The deltas describe direction from point 1 to point 2, while distance describes magnitude.
  • Using mixed units on the axes. Convert both coordinate scales to the same unit before interpreting the answer as a physical length.

Embed this calculator on your site

Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.

<script src="https://calctide.com/embed.js" data-tool="distance-formula-calculator" async></script>

Preview the embed at /embed/distance-formula-calculator/.

Frequently Asked Questions

The distance formula is d = sqrt((x2 - x1)^2 + (y2 - y1)^2). It gives the straight-line distance between two points on a coordinate plane by taking the square root of the squared horizontal change plus the squared vertical change.
Subtract the x values to get the horizontal change and subtract the y values to get the vertical change. Square both results, add them together, then take the square root. For example, from (1, 2) to (4, 6) the changes are 3 and 4, so the distance is sqrt(9 + 16) = 5.
The distance between (0, 0) and (3, 4) is 5 units. The change in x is 3 and the change in y is 4, so the distance is sqrt(3^2 + 4^2) = sqrt(9 + 16) = sqrt(25) = 5.
Yes, the distance formula is derived from the Pythagorean theorem. The horizontal and vertical changes between the two points act as the legs of a right triangle, and the distance is the hypotenuse, so a^2 + b^2 = c^2 becomes the distance formula.
No, distance is never negative. The differences are squared before the square root is taken, which removes any negative sign, so the result is always zero or a positive number.
In 3D you add the squared change in z to the formula, giving d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). This calculator covers 2D points only, so it uses just the x and y coordinates.
The distance is 0. Both coordinate differences are 0, so the formula becomes sqrt(0 + 0).
No. Switching the points reverses the signs of delta x and delta y, but squaring those changes gives the same distance.
The calculator rounds distance to 4 decimal places. Sqrt(2) is irrational, so its decimal digits continue and 1.4142 is the displayed approximation.
Yes. Any finite numeric coordinates are accepted, including negatives, zero, and decimals. The same subtraction and squaring steps apply.
The result uses the coordinate unit when both axes share one unit and scale. Coordinates in centimeters produce a distance in centimeters.
It estimates distance formula calculator outputs using the visible inputs and formula assumptions on this page.

Explore More in Education & Math