A car does not always take the shortest route through city blocks, and a drone does not need to follow roads at all. If two locations are marked on a grid, the shortest path between them is a straight line. That simple idea leads to one of the most useful geometry tools in middle school: using the Pythagorean Theorem to find distance on a coordinate plane.
On a map, a video game screen, or a graph, locations are often shown as points. Each point is named by an ordered pair, such as \(3, 5\) or \(-2, 4\). The first number tells how far to move left or right, and the second number tells how far to move up or down.
When you want the distance between two points, you are really asking for the length of the line segment joining them. If the points are not directly above one another and not directly beside one another, that segment becomes the slanted side of a right triangle, as [Figure 1] shows. Once that triangle appears, the Pythagorean Theorem becomes the perfect tool.
The coordinate plane is formed by two number lines that cross at right angles. The horizontal axis is the x-axis, and the vertical axis is the y-axis. Their intersection point is called the origin, written as \(0, 0\).
Suppose you have two points, \(A(x_1, y_1)\) and \(B(x_2, y_2)\). You can move from one point to the other in two simpler steps: horizontally and vertically. Those two moves form the legs of a right triangle. The straight segment from \(A\) to \(B\) is the hypotenuse.
The horizontal distance depends only on the difference between the \(x\)-coordinates, and the vertical distance depends only on the difference between the \(y\)-coordinates. That is why coordinate geometry and right triangles fit together so well.

Remember that the distance between two numbers on a number line is their positive difference. For example, the distance between \(2\) and \(7\) is \(5\), and the distance between \(-3\) and \(4\) is \(7\).
This number-line idea is important because coordinate differences work the same way. The horizontal change might be \(x_2 - x_1\) or \(x_1 - x_2\), but once you square it, the order will not change the final distance.
The Pythagorean Theorem applies to a right triangle. If the legs have lengths \(a\) and \(b\), and the hypotenuse has length \(c\), then
Pythagorean Theorem: In any right triangle, the sum of the squares of the leg lengths equals the square of the hypotenuse.
\[a^2 + b^2 = c^2\]
The hypotenuse is always the side opposite the right angle, and it is the longest side of the triangle. In coordinate geometry, the segment between two points often plays the role of the hypotenuse.
If you can find the lengths of the horizontal and vertical legs, then you can square them, add them, and take the square root to find the distance between the two points.
The geometry shows why distance can be found from coordinate differences. If one leg of the triangle is the horizontal change and the other leg is the vertical change, then the segment joining the points is the hypotenuse.
[Figure 2] For points \(A(x_1, y_1)\) and \(B(x_2, y_2)\), the horizontal change is \(x_2 - x_1\) and the vertical change is \(y_2 - y_1\). Using the Pythagorean Theorem gives
\[(x_2 - x_1)^2 + (y_2 - y_1)^2 = d^2\]
where \(d\) is the distance between the two points. Taking the square root of both sides gives the distance formula:
\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\]
This formula is not something completely new. It is just the Pythagorean Theorem written for points on a coordinate plane.

Why subtraction matters
The formula uses differences because distance depends on how far apart the coordinates are, not on their actual positions alone. Two points can be far from the origin but still close to each other. The differences \(x_2 - x_1\) and \(y_2 - y_1\) measure the true horizontal and vertical separation.
Notice something useful: you do not need to worry much about which point is first. If you reverse the order, the differences change sign, but squaring removes the sign. For example, \(4 - 1 = 3\) and \(1 - 4 = -3\), yet \(3^2 = 9\) and \((-3)^2 = 9\).
Find the distance between \(A(1, 2)\) and \(B(4, 6)\).
Worked example 1
Step 1: Find the horizontal and vertical changes.
The change in \(x\) is \(4 - 1 = 3\). The change in \(y\) is \(6 - 2 = 4\).
Step 2: Use the Pythagorean Theorem or distance formula.
\[d = \sqrt{(4 - 1)^2 + (6 - 2)^2}\]
So \(d = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25}\).
Step 3: Simplify.
\(d = 5\)
The distance between the points is \(5\) units.
This example forms a famous \(3\)-\(4\)-\(5\) right triangle. When the sum under the square root is a perfect square, the final distance is a whole number.
Now consider points with negative coordinates. Find the distance between \(C(-2, 3)\) and \(D(4, -1)\).
Worked example 2
Step 1: Find the coordinate differences.
The change in \(x\) is \(4 - (-2) = 6\). The change in \(y\) is \(-1 - 3 = -4\).
Step 2: Substitute into the formula.
\[d = \sqrt{(4 - (-2))^2 + (-1 - 3)^2}\]
That becomes \(d = \sqrt{6^2 + (-4)^2} = \sqrt{36 + 16}\).
Step 3: Simplify.
\[d = \sqrt{52}\]
Since \(52 = 4 \cdot 13\), we can simplify: \(\sqrt{52} = \sqrt{4 \cdot 13} = 2\sqrt{13}\).
The exact distance is \(2\sqrt{13}\) units.
If a decimal approximation is needed, use a calculator to find \(2\sqrt{13} \approx 7.2\) to the nearest tenth. The exact value and the approximate value both describe the same distance, just in different forms.
Some distances are special cases. Find the distance between \(E(-5, 4)\) and \(F(3, 4)\).
Worked example 3
Step 1: Notice what stays the same.
Both points have the same \(y\)-coordinate, \(4\). That means the segment is horizontal.
Step 2: Find the horizontal distance.
The change in \(x\) is \(3 - (-5) = 8\).
Step 3: Confirm with the formula.
\[d = \sqrt{(3 - (-5))^2 + (4 - 4)^2}\]
So \(d = \sqrt{8^2 + 0^2} = \sqrt{64}\).
\(d = 8\)
The distance is \(8\) units.
When two points have the same \(x\)-coordinate, the segment is vertical, and you only need the difference between the \(y\)-values. When two points have the same \(y\)-coordinate, the segment is horizontal, and you only need the difference between the \(x\)-values.
GPS systems, robotics, and computer graphics all rely on distance calculations built from the same geometric idea: measuring horizontal and vertical change and combining them to find straight-line separation.
That is one reason this topic matters far beyond math class. A theorem from ancient geometry still helps modern technology work.
One common mistake is mixing up subtraction. Suppose the points are \( (2, 7) \) and \( (8, 3) \). The differences are \(8 - 2 = 6\) and \(3 - 7 = -4\). It is fine that one difference is negative because squaring gives \((-4)^2 = 16\).
Another common mistake is forgetting parentheses around negative numbers. For example, \(-4^2\) means \(-(4^2) = -16\), but \((-4)^2 = 16\). In distance problems, the coordinate difference should be squared as a whole quantity.
A third mistake is stopping too early. If you get \(\sqrt{20}\), check whether it can simplify. Since \(20 = 4 \cdot 5\), then \(\sqrt{20} = 2\sqrt{5}\). Exact form is often preferred unless the problem asks for a decimal estimate.
| Situation | What to do |
|---|---|
| Different \(x\) and different \(y\) | Use \(d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\) |
| Same \(y\)-coordinate | Find the horizontal distance using the difference in \(x\)-values |
| Same \(x\)-coordinate | Find the vertical distance using the difference in \(y\)-values |
| Square root is not a perfect square | Leave the answer as a simplified radical or approximate it if needed |
Table 1. Common distance situations and the best method to use.
As we saw earlier in [Figure 1], the horizontal and vertical changes create the legs of a right triangle. That picture helps explain why all of these cases are really versions of the same geometric idea.
[Figure 3] A diagonal shortcut across a field or park is often shorter than walking along two sides. If a field is \(60\) meters long and \(80\) meters wide, then the diagonal distance is \(\sqrt{60^2 + 80^2} = \sqrt{3{,}600 + 6{,}400} = \sqrt{10{,}000} = 100\) meters.
Architects and builders use this relationship when checking whether corners are square. Designers of video games and apps use coordinate distances to control movement and collisions. In sports, tracking data can estimate how far a player moves from one position to another in straight-line terms.

On a digital map, two places may have coordinates in a grid system. The shortest direct route between them follows the same distance idea, even if real roads curve. The geometry gives the straight-line distance, which is often called the "as-the-crow-flies" distance.
Exact answers and approximate answers
An exact answer keeps the square root, such as \(\sqrt{29}\) or \(2\sqrt{13}\). An approximate answer uses decimals, such as \(5.4\) or \(7.2\). Exact answers are more precise, while decimal answers are often more practical in measurement situations.
Later, when students study slopes, circles, and even three-dimensional geometry, this same distance thinking keeps appearing. The theorem is not just one isolated skill. It is a building block for many parts of mathematics.
Suppose the distance between two points is \(\sqrt{41}\) units. That is the exact value. If you use a calculator, \(\sqrt{41} \approx 6.4\). The exact form is best for algebraic work, but the decimal form is often easier to picture in a measurement context.
When a problem asks you to "find the distance," read carefully. If it does not ask for a decimal, giving the simplified radical is usually a strong choice. If it says "nearest tenth," then convert the radical to a decimal and round.
The idea shown in [Figure 2] helps here: the horizontal and vertical changes determine the radical first, and then you decide whether to leave it exact or approximate it.
To find the distance between two points, think like a geometer: build a right triangle. The horizontal difference and vertical difference act as the legs, and the straight segment between the points acts as the hypotenuse.
Then apply
\[d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\]
With practice, you start to notice patterns. A horizontal or vertical segment is simpler. A \(3\)-\(4\)-\(5\) pattern gives a whole-number result. Negative coordinates are not a problem as long as you subtract carefully and square correctly.