Distance Formula

Calculates the shortest distance between two points on a coordinate plane using their coordinates and the Pythagorean theorem.

d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

Solve a problem with Distance Formula

Type the problem. The solver will use Distance Formula where Distance Formula is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Distance Formula takes
dd
x1x_1
y1y_1
x2x_2
y2y_2
Distance Formula
SymbolMeaning
ddThe distance between the two points; it is always zero or positive and uses the same units as the coordinates.
x1x_1The horizontal coordinate of the first point; swapping it with x2x_2 reverses the order but gives the same distance.
y1y_1The vertical coordinate of the first point; along with x1x_1 it completely specifies where the first point sits.
x2x_2The horizontal coordinate of the second point; the difference x2x1x_2 - x_1 captures the horizontal separation.
y2y_2The vertical coordinate of the second point; the difference y2y1y_2 - y_1 captures the vertical separation.

When to use it

Use it when you need to find how far apart two points are on a coordinate plane.

Level

Usually taught in: Geometry · Appears on: SAT, ACT

Worked examples

1. Find distance between points with positive integer coordinates

Problem

Find the distance between the points (1,2)(1, 2) and (4,6)(4, 6).
  1. (x1,y1)=(1,2),(x2,y2)=(4,6)(x_1, y_1) = (1, 2), \quad (x_2, y_2) = (4, 6)

    Write down both points clearly so you do not mix up which is which.

  2. x2x1=41=3x_2 - x_1 = 4 - 1 = 3

    This is the difference in the xx-coordinates; keep it separate from the vertical difference.

  3. y2y1=62=4y_2 - y_1 = 6 - 2 = 4

    Similarly, find how much the yy-coordinates differ.

  4. (x2x1)2=32=9,(y2y1)2=42=16(x_2 - x_1)^2 = 3^2 = 9, \quad (y_2 - y_1)^2 = 4^2 = 16

    Squaring removes any negative signs and is required by the Pythagorean theorem.

  5. 9+16=259 + 16 = 25

    This sum represents the square of the hypotenuse of a right triangle.

  6. d=25=5d = \sqrt{25} = 5

    Taking the square root gives the actual distance between the points.

Answer: d=5d = 5

This is a straightforward application of the distance formula with positive integer coordinates and a perfect-square answer. The horizontal and vertical separations form the legs of a right triangle, and the distance is the hypotenuse.

2. Find distance with negative coordinates

Problem

Find the distance between the points (2,3)(-2, 3) and (1,1)(1, -1).
  1. (x1,y1)=(2,3),(x2,y2)=(1,1)(x_1, y_1) = (-2, 3), \quad (x_2, y_2) = (1, -1)

    Keep track of the negative signs; they are part of the coordinates.

  2. x2x1=1(2)=1+2=3x_2 - x_1 = 1 - (-2) = 1 + 2 = 3

    Subtracting a negative number becomes addition; this is where sign errors often occur.

  3. y2y1=13=4y_2 - y_1 = -1 - 3 = -4

    This difference is negative, but that does not matter because it will be squared.

  4. (x2x1)2=32=9,(y2y1)2=(4)2=16(x_2 - x_1)^2 = 3^2 = 9, \quad (y_2 - y_1)^2 = (-4)^2 = 16

    Squaring the negative vertical difference gives a positive result, just as it does for the horizontal difference.

  5. 9+16=259 + 16 = 25

    The sum is still positive regardless of the signs of the original differences.

  6. d=25=5d = \sqrt{25} = 5

    Even though the coordinates contained negatives and a difference was negative, the distance is positive.

Answer: d=5d = 5

Negative coordinates and differences are handled correctly by the squaring step, which eliminates sign ambiguity. This example shows that the order of the points does not affect the distance because squaring makes the formula symmetric.

3. Find the diagonal length of a rectangular garden plot

Problem

A rectangular garden plot has corners at (0,0)(0, 0), (8,0)(8, 0), (8,6)(8, 6), and (0,6)(0, 6) on a coordinate grid measured in meters. A gardener wants to install fencing along the diagonal from (0,0)(0, 0) to (8,6)(8, 6). How long does the diagonal fencing need to be?
  1. (x1,y1)=(0,0),(x2,y2)=(8,6)(x_1, y_1) = (0, 0), \quad (x_2, y_2) = (8, 6)

    The diagonal connects opposite corners of the rectangle.

  2. x2x1=80=8 metersx_2 - x_1 = 8 - 0 = 8 \text{ meters}

    This is the length of the rectangle.

  3. y2y1=60=6 metersy_2 - y_1 = 6 - 0 = 6 \text{ meters}

    This is the width of the rectangle.

  4. (x2x1)2=82=64,(y2y1)2=62=36(x_2 - x_1)^2 = 8^2 = 64, \quad (y_2 - y_1)^2 = 6^2 = 36

    These represent the squares of the rectangle's dimensions.

  5. 64+36=10064 + 36 = 100

    We are using the Pythagorean theorem applied to the rectangle's length and width.

  6. d=100=10 metersd = \sqrt{100} = 10 \text{ meters}

    The diagonal is exactly 10 meters long.

Answer: d=10 metersd = 10 \text{ meters}

The rectangular garden has length 8 meters and width 6 meters. The diagonal of a rectangle with these dimensions acts as the hypotenuse of a right triangle with legs 8 and 6. The distance formula correctly gives 10 meters, which is what a contractor would need for the diagonal fencing.

Common mistakes

Where Distance Formula usually goes wrong
Answer came out wrong
d=(x2x1)+(y2y1)d = (x_2 - x_1) + (y_2 - y_1) instead of squaring the differences
Square each difference before adding: d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
Stopping after calculating (x2x1)2+(y2y1)2(x_2 - x_1)^2 + (y_2 - y_1)^2 and not taking the square root
Always finish by taking the square root: d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
Subtracting in the wrong order: using x1x2x_1 - x_2 or y1y2y_1 - y_2 instead of x2x1x_2 - x_1 or y2y1y_2 - y_1
Always subtract the first point's coordinate from the second point's coordinate: (x2x1)(x_2 - x_1) and (y2y1)(y_2 - y_1).
The mistakeWhy it is wrongThe fix
d=(x2x1)+(y2y1)d = (x_2 - x_1) + (y_2 - y_1) instead of squaring the differencesAdding the differences directly gives Manhattan distance (distance along a grid), not the straight-line distance.Square each difference before adding: d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
Stopping after calculating (x2x1)2+(y2y1)2(x_2 - x_1)^2 + (y_2 - y_1)^2 and not taking the square rootThis gives the square of the distance, not the distance itself; for example, d2=25d^2 = 25 means d=5d = 5, not d=25d = 25.Always finish by taking the square root: d=(x2x1)2+(y2y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}.
Subtracting in the wrong order: using x1x2x_1 - x_2 or y1y2y_1 - y_2 instead of x2x1x_2 - x_1 or y2y1y_2 - y_1This changes the sign of the difference; because the difference is squared immediately after, the sign does not matter mathematically, but it shows a misunderstanding and can lead to errors if the formula is misremembered.Always subtract the first point's coordinate from the second point's coordinate: (x2x1)(x_2 - x_1) and (y2y1)(y_2 - y_1).

Tips and when to use something else

  • The formula is rooted in the Pythagorean theorem: the horizontal and vertical differences form the two legs of a right triangle, and the distance is the hypotenuse.
  • If both coordinates are integers, try to factor the sum under the square root to see if you get a perfect square (like 25=5225 = 5^2).
  • For points on a vertical line, x1=x2x_1 = x_2, so the distance is just y2y1|y_2 - y_1|; for a horizontal line, y1=y2y_1 = y_2, so the distance is x2x1|x_2 - x_1|.
  • Use the Midpoint Formula if you need the point halfway between two points rather than the distance between them.

Frequently asked questions

Does the order of the points matter when using the distance formula?
No, the order does not matter because you square the differences immediately afterward. (3)2(3)^2 and (3)2(-3)^2 both equal 9. However, for consistency, it is good practice to always subtract the first point's coordinates from the second point's coordinates.
What is the distance between a point and itself?
The distance is zero. Both differences are zero, so d=02+02=0=0d = \sqrt{0^2 + 0^2} = \sqrt{0} = 0. This makes sense: a point has no distance from itself.
Can the distance between two points ever be negative?
No, distance is always zero or positive. The squaring step removes any possibility of a negative result, and the square root of a non-negative number is non-negative.
How does the distance formula relate to the Pythagorean theorem?
The two differences (x2x1)(x_2 - x_1) and (y2y1)(y_2 - y_1) are the lengths of the two legs of a right triangle. The distance dd is the length of the hypotenuse. Squaring, adding, and then taking the square root is exactly what the Pythagorean theorem does: a2+b2=c2a^2 + b^2 = c^2, solved for cc.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18