Distance is a tricky concept. Distance in a plane, like a chess board, is the straightline distance between two points. But what is a straight line? Is it the shortest distance between two points? Doesn't that definition involve the concept of distance that we're trying to define in the first place?
It turns out that the concept of a straight line is one we have to take for granted — a postulate, a thing that must be assumed to exist or to be true in order for anything else to be built upon it. A straight line is a "line of zero curvature" or "the path of a point traveling in a constant direction." So we accept the definition that the distance between two points on a plane is the length of the straight line (line segment) that joins them.
The distance between two points on a plane is the length of the straightline segment that connects them.
It gets strange when we move off of the plane. Consider: How far is it from one side of a room to another? From one part of a city to another? From one city to another? How far is it from Boston to Beijing? That one is tricky, because we know Earth is roughly a sphere, and when we travel from Boston to China, we take a curved path, not the straight one that drills through the middle of the planet.
How far apart are the two cities? There are two answers, right? So we have to be specific, at least in mathemiatics, about what we mean by distance. For most of our purposes, we'll be talking about distance on a plane.
To determine the distance between any two points on a coordinate plane (just a plane to which we've assigned a coordinate system and some units, like cm), we use the Pythagorean theorem.
The figure at right shows two points with coordinates (x_{1}, y_{1}) and (x_{2}, y_{2}). The distances along the axes, y_{2}y_{1} and x_{2}x_{1} are parallel to the coordinate axes and therefore orthogonal (form a right angle).
Because the line segment representing the distance of interest makes a right triangle with these two differences, we can easily calculate the length of that segment (the distance between the points) using the Pythagorean Theorem:
$$d^2 = (x_2  x_1)^2 + (y_2  y_1)^2$$
The distance between two points in a plane, (x_{1}, y_{1}) and (x_{2}, y_{2}) is
$$d = \sqrt{(x_2  x_1)^2 + (y_2  y_1)^2}$$
This is just a restatement of the Pythagorean theorem.
Calculate the distance between point p_{1} = (3, 5) and p_{2} = (8, 1).
$$ \begin{matrix} x_1 = 3, && x_2 = 8 \\[5pt] y_1 = 5, && y_2 = 1 \end{matrix}$$
Now plugging those into the distance formula will give us the distance. It doesn't matter whether we subtract x_{2} from x_{1} or x_{1} from x_{2}, just that we're consistent from x to y. The trickiest part is usually keeping track of subtracting negative numbers (the same as adding).
Start with the distance formula:
$$d = \sqrt{(x_2  x_1)^2 + (y_2  y_1)^2}$$
Plugging in our numbers gives
$$d = \sqrt{(8  (3))^2 + (1  5)^2}$$
Now pay attention to the negatives: 8  (3) = 8 + 3 = 11, and so on:
$$d = \sqrt{(11)^2 + (6)^2}$$
Notice that if we'd subtracted the other way around we'd just have (11)2 and (6)2, which, because squaring always yields a positive number, is the same. Taking the squares (before evaluating the radical) gives us
$$d = \sqrt{121 + 36}$$
... and finally the square root of the result gives us the distance between the points.
$$d = \sqrt{157} = \bf 12.53 \: units$$
Find the distance between the following sets of points on the 2D plane:
1. 

2. 

3. 

4. 

5. 

6. 

To determine the distance between any two points on a 3Dimensional coordinate grid, we just extend our formula with a term that brings in the zcomponents of the ordered triples of the endpoints.
The figure at right shows two points with coordinates (x_{1}, y_{1}, z_{1}) and (x_{2}, y_{2}, z_{2}). The distances along the axes, y_{2}y_{1}, x_{2}x_{1}, and z_{2}z_{1} are parallel to the coordinate axes.
Because the line segment representing the distance of interest makes a right triangle with these two differences, we can easily calculate the length of that segment (the distance between the points) using the Pythagorean Theorem:
$$d^2 = (x_2  x_1)^2 + (y_2  y_1)^2 + (z_2  z_1)^2$$
We can easily extend the 2d or 3d distance formula to any number of dimensions:
$$d = \sqrt{(x_{12}  x_{11})^2 + (x_{22}  x_{21})^2 + \dots + (x_{n2}  x_{n1} )^2}$$
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons AttributionNonCommercialShareAlike 3.0 Unported License. © 2016, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.