Calculating Diagonal Distance

Introduction

Welcome back to Distance on the Coordinate Plane! You have reached the third of four lessons in this course, and this is where everything comes together. In Lesson 1 you learned to measure horizontal and vertical distances, and in Lesson 2 you built right triangles whose legs are those distances and whose hypotenuse is the diagonal between two points. The missing piece has been calculating that diagonal — and the Pythagorean theorem is the tool that fills the gap. Let's put it to work.

Connecting the Triangle to the Theorem

From earlier in this learning path, you know that the Pythagorean theorem states:

a2+b2=c2a^2 + b^2 = c^2

where aa and bb are the legs of a right triangle and cc is the hypotenuse. In our coordinate-plane triangles the two legs are the horizontal and vertical segments we already know how to measure, and the hypotenuse is the diagonal distance we want to find. Since aa and bb are known, all we need to do is square them, add the results, and take the square root to get cc.

Think back to the city-grid analogy from Lesson 2: you walk several blocks east and then several blocks north, forming an "L" shape, while a bird flies straight between the two intersections. The legs of the "L" are the values we plug into the theorem, and the bird's flight path is the distance the theorem returns. Now let's see the numbers in action.

A Whole-Number Distance

Consider the points (0,0)(0, 0) and (3,4)(3, 4). Placing the right-angle corner at (3,0)(3, 0) gives us:

  • Horizontal leg: ∣3−0∣=3|3 - 0| = 3
  • Vertical leg: ∣4−0∣=4|4 - 0| = 4

Applying the theorem with a=3a = 3 and b=4b = 4:

c2=32+42=9+16=25c^2 = 3^2 + 4^2 = 9 + 16 = 25 c=25=5c = \sqrt{25} = 5

The straight-line distance between the two points is exactly 5 units. You may recognize this as the famous 3-4-5 triple from the earlier course on solving for unknown sides. Whenever a problem produces a perfect square under the radical, the answer comes out as a clean whole number.

Coordinate plane showing the right triangle from (0,0) to (3,4) with legs 3 and 4 and diagonal 5.

When the Distance Is Not a Whole Number

Now let's return to the triangle from Lesson 2 built from the points (1,2)(1, 2) and (5,7)(5, 7). We already found horizontal and vertical legs of 4 and 5 units, but back then we had no way to calculate the hypotenuse. Now we do.

Setting a=4a = 4 and b=5b = 5:

c2=42+52=16+25=41c^2 = 4^2 + 5^2 = 16 + 25 = 41 c=41c = \sqrt{41}

Because 41 is not a perfect square, the exact distance is 41\sqrt{41} units. We can also express this as a decimal approximation: 41≈6.40\sqrt{41} \approx 6.40 units, rounded to two decimal places. The radical form is exact, while the decimal gives a quick sense of the actual length — both are useful depending on the situation.

Negative Coordinates Work the Same Way

Points in different quadrants do not change the method at all. Take (−2,3)(-2, 3) and (4,−1)(4, -1), another pair from Lesson 2. The horizontal leg is ∣4−(−2)∣=6|4 - (-2)| = 6 and the vertical leg is ∣−1−3∣=4|-1 - 3| = 4. From here the calculation is identical:

c2=62+42=36+16=52c^2 = 6^2 + 4^2 = 36 + 16 = 52 c=52c = \sqrt{52}

Since 52=4×1352 = 4 \times 13, we can simplify:

c=213≈7.21 unitsc = 2\sqrt{13} \approx 7.21 \text{ units}

The absolute values handled the negative signs when we found the legs. Once those leg lengths are in hand, the Pythagorean theorem works exactly the same way every time.

Coordinate plane showing points (-2,3) and (4,-1) connected by a right triangle with horizontal leg 6, vertical leg 4, and diagonal 2√13.

From Points to Distance in Four Steps

No matter which two points you are given, the process is always the same. Here is the complete method for finding the distance between (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2):

  1. Find the horizontal leg: compute ∣x2−x1∣|x_2 - x_1|.
  2. Find the vertical leg: compute ∣y2−y1∣|y_2 - y_1|.
  3. Square each leg and add the results.
  4. Take the square root of that sum to get the distance.

This method works everywhere on the coordinate plane — whether the points sit in the same quadrant, straddle an axis, or land in opposite corners of the grid. It also applies directly to real-world maps and layouts. If you know two locations as coordinates on a city map, these four steps tell you the straight-line shortcut between them, even when streets only let you travel in an "L" shape.

One useful detail: when you square a difference in Step 3, any negative sign disappears automatically. Squaring naturally handles the absolute value for you. We will build on this idea in the next lesson when we combine all four steps into a single formula.

Conclusion and Next Steps

In this lesson you applied the Pythagorean theorem to the right triangles from Lesson 2, completing the journey from two coordinate points to a straight-line distance. Whether the result is a tidy whole number like 5 or an exact radical like 2132\sqrt{13}, the four-step method — horizontal leg, vertical leg, square-and-add, square root — stays the same every time.

Up next, we will condense these steps into one compact expression called the distance formula. Before that, head into the practice exercises to work through the full process on your own. You will calculate clean distances, simplify radicals, and even find a shortcut across a park on a city-grid map!

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal