From the Discrete Metric to Coordinate Geometry
The discrete metric assigns the same distance to every pair of distinct points, without using any geometry the set may have. In \(\mathbb{R}^n\), the coordinates provide another natural way to measure separation: take the square root of the sum of the squared coordinate differences. This is the Euclidean distance. It agrees with the familiar straight-line distance in the plane and in three-dimensional space, and its formula extends to every positive integer dimension.
The formula is built from the Euclidean norm of a vector difference. Earlier, in “Why Metric Spaces?”, we established that a norm induces a metric by the rule \(d(x,y)=\|x-y\|\). We will verify the needed norm properties for the Euclidean norm, with the triangle inequality as the main step. We will then compare the resulting distance with two other ways to measure coordinate differences.
Each coordinate difference is squared, so every term under the square root is nonnegative. The metric is zero when the two points agree in every coordinate, and changing the order of the points changes only the signs of the differences, not their squares. The triangle inequality takes more work; it follows from the Cauchy–Schwarz inequality.
The Inequality Behind the Triangle Inequality
Proof. If \(y=0\), then \(x\cdot y=0\), so the inequality holds. Suppose \(y\ne0\), and set \(t=(x\cdot y)/\|y\|_2^2\). Since a squared norm is nonnegative, $$ 0\leq\|x-ty\|_2^2 =\|x\|_2^2-2t(x\cdot y)+t^2\|y\|_2^2. $$ Substituting the chosen value of \(t\) gives $$ 0\leq\|x\|_2^2-\frac{(x\cdot y)^2}{\|y\|_2^2}. $$ Multiplying by \(\|y\|_2^2>0\), we obtain $$ (x\cdot y)^2\leq\|x\|_2^2\|y\|_2^2. $$ Taking nonnegative square roots proves the stated inequality. \(\square\)
Proof. The value \(\|x\|_2\) is nonnegative because it is a square root of a sum of squares. That sum is zero exactly when every \(x_i=0\), so \(\|x\|_2=0\) exactly when \(x=0\). For any real number \(a\), $$ \|ax\|_2 =\left(\sum_{i=1}^{n}(ax_i)^2\right)^{1/2} =|a|\left(\sum_{i=1}^{n}x_i^2\right)^{1/2} =|a|\|x\|_2. $$ It remains to prove the triangle inequality. For \(x,y\in\mathbb{R}^n\), expand the square: $$ \|x+y\|_2^2 =\|x\|_2^2+2(x\cdot y)+\|y\|_2^2. $$ By the Cauchy–Schwarz inequality, \(x\cdot y\leq|x\cdot y|\leq\|x\|_2\|y\|_2\). Hence $$ \|x+y\|_2^2 \leq\|x\|_2^2+2\|x\|_2\|y\|_2+\|y\|_2^2 =(\|x\|_2+\|y\|_2)^2. $$ Both sides before squaring are nonnegative, so taking square roots yields \(\|x+y\|_2\leq\|x\|_2+\|y\|_2\). All the norm axioms hold. \(\square\)
Proof. The norm properties just proved imply that \(d_2(x,y)\geq0\), and that \(d_2(x,y)=0\) exactly when \(x-y=0\), or \(x=y\). Also, $$ d_2(x,y)=\|x-y\|_2=\|-(y-x)\|_2=\|y-x\|_2=d_2(y,x). $$ Finally, for \(x,y,z\in\mathbb{R}^n\), write \(x-z=(x-y)+(y-z)\). The norm triangle inequality gives $$ d_2(x,z)=\|(x-y)+(y-z)\|_2 \leq\|x-y\|_2+\|y-z\|_2 =d_2(x,y)+d_2(y,z). $$ Thus \(d_2\) satisfies all metric axioms. This is also an instance of the theorem “A Norm Induces a Distance” from “Why Metric Spaces?”. \(\square\)
Calculating Euclidean Distances
Worked Example: Distance Between Two Points in the Plane
Let \(p=(2,-1)\) and \(q=(-1,3)\) in \(\mathbb{R}^2\). Their coordinate differences are \(2-(-1)=3\) and \(-1-3=-4\). Therefore, $$ d_2(p,q)=\sqrt{3^2+(-4)^2} =\sqrt{9+16} =5. $$ Reversing the order gives differences \(-3\) and \(4\), and the calculation remains \(\sqrt{(-3)^2+4^2}=5\), as required by symmetry.
Worked Example: A Three-Dimensional Distance
Take \(u=(1,2,-2)\) and \(v=(4,-2,1)\) in \(\mathbb{R}^3\). Subtract coordinate by coordinate: $$ u-v=(1-4,\,2-(-2),\,-2-1)=(-3,4,-3). $$ Thus $$ d_2(u,v)=\sqrt{(-3)^2+4^2+(-3)^2} =\sqrt{9+16+9} =\sqrt{34}. $$ The distance is not the sum of the absolute coordinate differences, which here is \(3+4+3=10\); the Euclidean formula takes the square root of the sum of the squares.
The same formula works on sets that are not all of \(\mathbb{R}^n\). If \(A\) is any nonempty subset of \(\mathbb{R}^n\), define the distance between \(x,y\in A\) by the same expression \(d_2(x,y)\). The metric axioms continue to hold because they hold for every pair or triple of points in \(\mathbb{R}^n\), and points of \(A\) are points of \(\mathbb{R}^n\). No assumption that \(A\) contains the straight line segment between its points is needed: the distance is calculated using their coordinates, whether or not that segment lies inside \(A\).
Worked Example: The Euclidean Metric on a Circle
Let \(A=\{(x,y)\in\mathbb{R}^2:x^2+y^2=1\}\), the unit circle, with the restricted Euclidean metric. For \(p=(1,0)\) and \(q=(0,1)\), both points lie in \(A\) because \(1^2+0^2=1\) and \(0^2+1^2=1\). Their distance within this metric space is $$ d_2(p,q)=\sqrt{(1-0)^2+(0-1)^2}=\sqrt{2}. $$ This is the Euclidean distance between the points, not the length of an arc along the circle. Restricting a metric to a subset keeps the same pairwise distances; it does not replace them by lengths of paths constrained to stay in the subset.
Comparing Coordinate Distance Formulas
Other metrics on \(\mathbb{R}^n\) can be defined using the same coordinate differences but combining them differently. For \(x,y\in\mathbb{R}^n\), write \(z=x-y\), and define $$ d_\infty(x,y)=\max_{1\leq i\leq n}|x_i-y_i|, \qquad d_1(x,y)=\sum_{i=1}^{n}|x_i-y_i|. $$ These measure, respectively, the largest coordinate difference and the sum of the absolute coordinate differences. The following comparisons show exactly how they bound the Euclidean distance.
Proof. Put \(z=x-y\). Since \(|z_i|\leq\max_j|z_j|=d_\infty(x,y)\) for every \(i\), we have $$ d_2(x,y)^2=\sum_{i=1}^{n}|z_i|^2 \leq n\,d_\infty(x,y)^2. $$ Taking square roots proves \(d_2(x,y)\leq\sqrt{n}\,d_\infty(x,y)\). Also, each term \(|z_i|^2\) is at most the sum \(\sum_j|z_j|^2\). Taking the largest \(|z_i|\) therefore gives \(d_\infty(x,y)\leq d_2(x,y)\).
For the other pair of inequalities, the nonnegative terms \(|z_i|\) satisfy $$ \left(\sum_{i=1}^{n}|z_i|\right)^2 =\sum_{i=1}^{n}|z_i|^2+2\sum_{1\leq i<j\leq n}|z_i||z_j| \geq\sum_{i=1}^{n}|z_i|^2. $$ Taking square roots yields \(d_2(x,y)\leq d_1(x,y)\). Finally, apply the Cauchy–Schwarz inequality to the vectors \((|z_1|,\ldots,|z_n|)\) and \((1,\ldots,1)\): $$ d_1(x,y) =\sum_{i=1}^{n}|z_i| \leq \left(\sum_{i=1}^{n}|z_i|^2\right)^{1/2} \left(\sum_{i=1}^{n}1^2\right)^{1/2} =\sqrt{n}\,d_2(x,y). $$ This proves all four inequalities. \(\square\)
Worked Example: Comparing Three Distances in the Plane
For the points \(p=(2,-1)\) and \(q=(-1,3)\), the absolute coordinate differences are \(3\) and \(4\). Therefore, $$ d_\infty(p,q)=4,\qquad d_2(p,q)=5,\qquad d_1(p,q)=7. $$ In dimension \(n=2\), the comparison theorem gives $$ 4\leq5\leq\sqrt{2}\cdot4 \quad\text{and}\quad 5\leq7\leq\sqrt{2}\cdot5. $$ The upper bounds hold because \(\sqrt{2}\cdot4\) is approximately \(5.66\), and \(\sqrt{2}\cdot5\) is approximately \(7.07\). The distances differ, but each controls the others up to a dimension-dependent factor.
Why the Coordinate Comparisons Matter
The comparison inequalities explain why the Euclidean formula is a natural choice without making it the only useful one. A calculation may be simpler with \(d_\infty\) or \(d_1\), but in a fixed finite dimension the Euclidean distance cannot differ from either by an arbitrarily large factor: the theorem supplies explicit bounds. The factors depend on \(n\), so the estimates are dimension-specific.
A common pitfall is to treat “distance” as if it had one universal formula on a set. The same coordinate space has several metrics, and they can assign different numerical distances to the same pair. For example, the plane calculation above gives distances \(4\), \(5\), and \(7\) under \(d_\infty\), \(d_2\), and \(d_1\), respectively. Each formula is useful for a different purpose, but a metric must still satisfy the metric axioms. The Euclidean formula does so because its underlying norm satisfies the triangle inequality.
Check Your Understanding
Use the Euclidean distance formula and the results established here to answer the following questions.
- Compute the Euclidean distance between \((3,1)\) and \((-1,4)\) in \(\mathbb{R}^2\).
- Why does the Cauchy–Schwarz inequality imply the triangle inequality for the Euclidean norm?
- If a metric is restricted to a subset of \(\mathbb{R}^n\), do the distances between the remaining points change? Explain.
- For a pair of points in \(\mathbb{R}^5\), what upper bound does the comparison theorem give for \(d_2\) in terms of \(d_\infty\)?
- For \(x,y\in\mathbb{R}^n\), which is always at least as large: \(d_1(x,y)\) or \(d_2(x,y)\)?