Lines & Graphs

Distance Formula Practice Problems

The distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. Subtract the x-values, subtract the y-values, square each gap, add, and take the square root.

d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}

Try it with your numbers

Show every step

Sketching the two points first, even roughly, on a grid like the one in plotting points on the coordinate plane takes ten seconds and catches most arithmetic slips. The solver above shows every step for your own numbers, and the practice quiz further down moves from easy to hard. For the full lesson behind the formula, see the distance formula page.

Where the distance formula comes from

Put two points on a grid and draw a horizontal line from one and a vertical line from the other until they meet. That makes a right triangle whose legs are ∣x2−x1∣|x_2-x_1| and ∣y2−y1∣|y_2-y_1|, and the segment you want is the hypotenuse. The Pythagorean theorem says c2=a2+b2c^2=a^2+b^2, so

d2=(x2−x1)2+(y2−y1)2d^2=(x_2-x_1)^2+(y_2-y_1)^2

and taking the square root gives the formula. Nothing needs memorizing beyond that picture.

The squares explain two features that confuse people. The order of the points does not matter, because (x2−x1)2=(x1−x2)2(x_2-x_1)^2=(x_1-x_2)^2. The absolute value bars from the leg lengths also vanish, because squaring already makes every gap positive.

The triangle also explains the special cases. If the points share an x-value, the horizontal leg is 0 and the distance is just ∣y2−y1∣|y_2-y_1|, which is why horizontal and vertical lines need no formula at all.

Quick check

Find the distance between (1,1)(1, 1) and (9,16)(9, 16).

How to use the distance formula step by step

Take (−4,6)(-4, 6) and (3,−2)(3, -2).

  1. Label the points: (x1,y1)=(−4,6)(x_1, y_1)=(-4, 6) and (x2,y2)=(3,−2)(x_2, y_2)=(3, -2).
  2. Subtract in matching order: x2−x1=3−(−4)=7x_2-x_1=3-(-4)=7 and y2−y1=−2−6=−8y_2-y_1=-2-6=-8.
  3. Square each gap and add: 72+(−8)2=49+64=1137^2+(-8)^2=49+64=113.
  4. Take the root: 113\sqrt{113}.

d=(3−(−4))2+(−2−6)2=72+(−8)2=49+64=113≈10.63d=\sqrt{(3-(-4))^2+(-2-6)^2}=\sqrt{7^2+(-8)^2}=\sqrt{49+64}=\sqrt{113}\approx 10.63

Since 113 has no square factor, 113\sqrt{113} is already the exact answer. Give the decimal only when the problem asks for rounding.

The step that costs the most points is step 3. The square of −8-8 is +64+64, never −64-64, and the whole gap is squared, not just the number. Treat the parentheses and exponents the way order of operations demands: finish the subtraction inside, then square.

Keep pairs together

Every x-value pairs with an x-value and every y-value with a y-value. Subtracting x2−y1x_2-y_1 is the most common way to get a wrong answer from correct-looking steps.

Distance formula with negative numbers and fractions

Subtracting a negative is addition, so 3−(−4)3-(-4) becomes 3+43+4. A reliable habit is to write the subtraction with parentheses around the second value before simplifying. That one habit removes almost every sign error.

Fractions follow the same pattern. Find the distance between (12,−32)\left(\tfrac12, -\tfrac32\right) and (72,52)\left(\tfrac72, \tfrac52\right):

x2−x1=72−12=3,y2−y1=52−(−32)=82=4x_2-x_1=\tfrac72-\tfrac12=3,\qquad y_2-y_1=\tfrac52-\left(-\tfrac32\right)=\tfrac82=4

d=32+42=25=5d=\sqrt{3^2+4^2}=\sqrt{25}=5

When the denominators differ, scale first. For (13,12)\left(\tfrac13, \tfrac12\right) and (53,32)\left(\tfrac53, \tfrac32\right), multiply every coordinate by 6 to get (2,3)(2, 3) and (10,9)(10, 9). The gaps are 8 and 6, so the scaled distance is 10. Divide by 6 to undo the scaling: d=106=53d=\tfrac{10}{6}=\tfrac53. Direct check: (43)2+12=259=53\sqrt{\left(\tfrac43\right)^2+1^2}=\sqrt{\tfrac{25}{9}}=\tfrac53.

Try this: Find the distance between (2,−3)(2, -3) and (−1,1)(-1, 1) twice, once with each point listed first. Both runs should give 5, and the gaps should be −3,4-3, 4 the first time and 3,−43, -4 the second.

How to check a distance formula answer

Number line showing a distance answer must fall between the longer leg 8 and the leg sum 15
For legs 7 and 8, any distance outside 8 to 15, such as 3, is wrong; 10.63 fits.

Let a=∣x2−x1∣a=|x_2-x_1| and b=∣y2−y1∣b=|y_2-y_1|. The distance must satisfy

max⁡(a,b)≤d≤a+b\max(a, b)\le d\le a+b

because the hypotenuse is longer than either leg but shorter than the two legs laid end to end. For the earlier example, a=7a=7 and b=8b=8, so dd must fall between 8 and 15. The answer 10.63 passes. An answer of 3, or 15.5, would fail instantly.

A tighter lower bound is a+b2\dfrac{a+b}{\sqrt2}, which is about 0.71(a+b)0.71(a+b). It is reached only when a=ba=b. Here it gives about 10.6, almost exactly the true value, so this is a very fast mental estimate.

This also exposes the classic wrong move: a2+b2≠a+b\sqrt{a^2+b^2}\ne a+b. With legs 3 and 4, the real distance is 5, not 7.

Legs (a,b)(a, b) Distance
(3,4)(3, 4) 55
(5,12)(5, 12) 1313
(8,15)(8, 15) 1717
(7,24)(7, 24) 2525
(20,21)(20, 21) 2929

Recognizing these triples, or their multiples, lets you finish many problems without a calculator. When the result is not a perfect square, pull out the largest square factor: for (1,2)(1, 2) and (7,8)(7, 8), d=36+36=72=62≈8.49d=\sqrt{36+36}=\sqrt{72}=6\sqrt2\approx 8.49.

Quick check

A classmate gets d=3d=3 for the points (−2,1)(-2, 1) and (4,9)(4, 9). Using the bounds check, what is the smallest the distance could possibly be?

Distance formula problems with a missing coordinate

Circle of radius 5 around (1, 2) cut by line y = 6 at x = 4 and x = −2
The points 5 units from (1, 2) form a circle, and the line y = 6 crosses it at (4, 6) and (−2, 6).

Suppose (1,2)(1, 2) and (x,6)(x, 6) are 5 units apart. Substitute, then square both sides before doing anything else:

(x−1)2+(6−2)2=25⇒(x−1)2=9⇒x−1=±3(x-1)^2+(6-2)^2=25\quad\Rightarrow\quad (x-1)^2=9\quad\Rightarrow\quad x-1=\pm 3

So x=4x=4 or x=−2x=-2. Both are correct, because the points 5 units from (1,2)(1, 2) form a circle, and the line y=6y=6 cuts that circle twice. Dropping the ±\pm is the usual way to lose half the credit. If the unknown appears in a way that expands into x2+bx+c=0x^2+bx+c=0 that will not factor, the quadratic formula finishes the job.

A related type asks for a point equidistant from two others. Find the point (x,0)(x, 0) on the x-axis that is equally far from (1,3)(1, 3) and (5,7)(5, 7):

(x−1)2+32=(x−5)2+72(x-1)^2+3^2=(x-5)^2+7^2

x2−2x+10=x2−10x+74⇒8x=64⇒x=8x^2-2x+10=x^2-10x+74\quad\Rightarrow\quad 8x=64\quad\Rightarrow\quad x=8

The x2x^2 terms cancel, so the equation is linear. Check: both distances squared equal 58. The reason it works is geometric: points equally far from two locations lie on the perpendicular bisector of the segment between them. That line passes through the midpoint (3,5)(3, 5) and, using perpendicular slopes, has slope −1-1, giving y=−x+8y=-x+8. At y=0y=0, x=8x=8, matching.

Can the distance formula prove a right triangle?

Yes, and it is a standard test question. Take A(0,0)A(0, 0), B(4,3)B(4, 3) and C(−3,4)C(-3, 4). Work with squared distances so no radicals appear:

AB2=42+32=25,AC2=(−3)2+42=25,BC2=(−7)2+12=50AB^2=4^2+3^2=25,\qquad AC^2=(-3)^2+4^2=25,\qquad BC^2=(-7)^2+1^2=50

Since 25+25=5025+25=50, the converse of the Pythagorean theorem gives a right angle at AA. Because AB=AC=5AB=AC=5, the triangle is also isosceles. One distance formula pass proved both facts.

The same approach checks whether three points lie on one line. For (0,0)(0, 0), (1,2)(1, 2) and (3,6)(3, 6), the pieces are 5\sqrt5 and 252\sqrt5, and the full length is 45=35\sqrt{45}=3\sqrt5. The pieces add up exactly to the whole, so the points are collinear. If the sum is strictly larger than the whole, the points form a genuine triangle.

Compare squares, not roots

Testing a2+b2=c2a^2+b^2=c^2 with d2d^2 values avoids rounding. Rounded decimals such as 4.9+4.94.9+4.9 versus 7.17.1 can fail a test that exact values would pass.

Distance formula in 3D and from a point to a line

Add a third coordinate and apply Pythagoras twice: once across the floor, once up the height. The result is

d=(x2−x1)2+(y2−y1)2+(z2−z1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

For (2,−1,4)(2, -1, 4) and (5,3,16)(5, 3, 16) the gaps are 3, 4 and 12, so d=9+16+144=169=13d=\sqrt{9+16+144}=\sqrt{169}=13.

Distance from a point to a line is a different problem. The nearest spot on a line is where a perpendicular lands, so measuring to a random point on the line overshoots. For a line in the form Ax+By+C=0Ax+By+C=0 (rearranged from standard form) and a point (x0,y0)(x_0, y_0):

d=∣Ax0+By0+C∣A2+B2d=\frac{|Ax_0+By_0+C|}{\sqrt{A^2+B^2}}

Find the distance from (1,2)(1, 2) to 3x+4y−20=03x+4y-20=0. The numerator is ∣3+8−20∣=9|3+8-20|=9 and the denominator is 9+16=5\sqrt{9+16}=5, so d=95=1.8d=\tfrac95=1.8. The formula needs the line moved fully to one side, with a zero on the other. Forgetting that is the usual error.

Quick check

Find the distance from the origin to the point (2,3,6)(2, 3, 6).

Real-world distance formula problems and their limits

Coordinates plus a scale turn the formula into a measuring tool. On a city map where each grid unit is 0.1 mile, a school at (2,1)(2, 1) and a park at (14,6)(14, 6) have gaps of 12 and 5, so the straight-line distance is 144+25=13\sqrt{144+25}=13 units, or 1.3 miles. Walking along streets means going 12 blocks east and 5 north, which is 17 units, or 1.7 miles. Both are valid distances for different questions.

The formula also powers the equation of a circle: every point (x,y)(x, y) at distance rr from the center (h,k)(h, k) satisfies (x−h)2+(y−k)2=r2(x-h)^2+(y-k)^2=r^2. Game developers use it for hit detection, and data analysts use the same idea (called Euclidean distance) to measure how similar two data points are.

Its limit is flatness. The formula assumes a flat plane, which is fine for a classroom, a floor plan or a few city blocks. Across large areas of Earth, latitude and longitude lines do not form a square grid, since a degree of longitude shrinks as you move toward the poles. Long trips need great-circle distance instead.

Distance formula vs midpoint formula vs slope formula

All three formulas start from the same two differences, x2−x1x_2-x_1 and y2−y1y_2-y_1, which is why students mix them up. What differs is the operation and the type of answer:

  • Distance squares the gaps, adds, and roots. It returns one non-negative length.
  • The midpoint averages the coordinates and returns a point, such as (x1+x22,y1+y22)\left(\tfrac{x_1+x_2}{2}, \tfrac{y_1+y_2}{2}\right).
  • Slope divides the vertical gap by the horizontal gap. It returns a ratio that can be negative or undefined.

For (−4,6)(-4, 6) and (3,−2)(3, -2), the distance is 113\sqrt{113}, the midpoint is (−12,2)\left(-\tfrac12, 2\right), and the slope is −87-\tfrac87. A quick sanity test: if your “distance” came out negative or as a pair of numbers, you used another formula.

To practice the neighbors, work through the midpoint formula practice problems and review the slope formula. Once you have a slope and two points, the equation of a line through two points is the natural next step.

Practice problems

0 of 10 solved

  1. Find the distance between (0,0)(0, 0) and (5,12)(5, 12).

  2. Find the distance between (−3,5)(-3, 5) and (4,5)(4, 5).

  3. Find the distance between (−2,−1)(-2, -1) and (4,7)(4, 7).

  4. Find the distance between (−1,−2)(-1, -2) and (6,3)(6, 3). Round to the nearest hundredth.

  5. Find the distance between (4,−3)(4, -3) and (−2,1)(-2, 1). Round to the nearest hundredth.

  6. Find the distance between (0.5,1.2)(0.5, 1.2) and (3.5,−0.8)(3.5, -0.8). Round to the nearest hundredth.

  7. On a map, 1 unit is 0.25 mile. Town A is at (−3,2)(-3, 2) and Town B is at (5,−4)(5, -4). How many miles apart are they in a straight line?

  8. Find the perimeter of the triangle with vertices A(−2,1)A(-2, 1), B(4,1)B(4, 1) and C(1,5)C(1, 5).

  9. Find kk if the distance between (−3,2)(-3, 2) and (k,6)(k, 6) is 41\sqrt{41}.

  10. Find the point on the yy-axis that is the same distance from (2,1)(2, 1) and (6,5)(6, 5).

Common questions

What is the distance formula?

The distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. It is the Pythagorean theorem applied to the horizontal and vertical gaps between two points.

Does it matter which point is first in the distance formula?

No. Swapping the points flips the sign of each difference, and squaring removes that sign. You only need to keep the x-values together and the y-values together, in the same order.

Can a distance be negative?

No. The square root in the formula gives the positive root, and the radicand is a sum of squares, so d≥0d\ge 0. It equals 0 only when the two points are the same.

How do you find the distance from the origin to a point?

Use d=x2+y2d=\sqrt{x^2+y^2}, since the origin's coordinates are both 0. For example, the point (6,8)(6, 8) is 36+64=10\sqrt{36+64}=10 units from the origin.

How do you find a missing coordinate when the distance is given?

Substitute everything into the formula, square both sides to remove the root, and solve the resulting equation. Expect two answers when the unknown is squared, because the points lie on a circle.

Is the distance formula the same as the Pythagorean theorem?

It is the same idea in coordinate form. The differences x2−x1x_2-x_1 and y2−y1y_2-y_1 are the legs of a right triangle, and dd is the hypotenuse.

Up next