Tutorials › Topology (Undergraduate) › The Discrete Metric and Its Unusual Balls

Metric Spaces and Open Balls · Tutorial 41 of 799

The Discrete Metric and Its Unusual Balls

Learn why the discrete metric satisfies the metric axioms and why its open balls change abruptly at radius one.

Beginner 8 min read

What You'll Learn

  • Define the discrete metric on an arbitrary set.
  • Verify nonnegativity, identity of indiscernibles, symmetry, and the triangle inequality.
  • Compute open balls when the radius is below one, exactly one, and above one.
  • Explain why a ball of radius one excludes points at distance one.
  • Apply the definition to finite, infinite, and one-point sets.

A Distance That Takes Only Two Values

In the usual distance on the real line, changing the radius gradually changes the size of a ball. The discrete metric behaves differently: the distance between any two distinct points is always exactly one. As a result, the open balls have just two possible forms for positive radii: a singleton or the entire space. The boundary between these forms is important because an open ball uses a strict inequality.

Let \(X\) be any set. A metric on \(X\) is a function \(d:X\times X\to[0,\infty)\) such that, for all \(x,y,z\in X\), (1) \(d(x,y)\ge 0\), with \(d(x,y)=0\) if and only if \(x=y\); (2) \(d(x,y)=d(y,x)\); and (3) \(d(x,z)\le d(x,y)+d(y,z)\). The last condition is the triangle inequality.

Definition: The discrete metric on a set \(X\) is the function \(d:X\times X\to[0,\infty)\) defined by $$ d(x,y)= \begin{cases} 0,&x=y,\\ 1,&x\ne y. \end{cases} $$ The definition applies to every set \(X\), including the empty set.

There are no other distance values: a point has distance zero from itself, and every different point has distance one from it. We first verify that this rule really defines a metric. The triangle inequality is the condition that needs the most care, because it concerns triples of points that may coincide in different ways.

Verifying the Metric Axioms

Theorem: For every set \(X\), the discrete metric is a metric on \(X\).

Proof. Suppose first that \(X\) is nonempty, and let \(x,y,z\in X\). By its definition, \(d(x,y)\) is either \(0\) or \(1\), so it is nonnegative. Also \(d(x,y)=0\) exactly when \(x=y\). The definition is unchanged when the two inputs are exchanged: \(x=y\) exactly when \(y=x\), and \(x\ne y\) exactly when \(y\ne x\). Thus \(d(x,y)=d(y,x)\).

For the triangle inequality, first suppose \(x=z\). Then \(d(x,z)=0\), and \(0\le d(x,y)+d(y,z)\) because both terms on the right are nonnegative. Now suppose \(x\ne z\). Then \(d(x,z)=1\). If \(y=x\), the right-hand side is \(d(x,x)+d(x,z)=0+1=1\). If \(y=z\), it is \(d(x,z)+d(z,z)=1+0=1\). If \(y\) is different from both \(x\) and \(z\), it is \(d(x,y)+d(y,z)=1+1=2\). In all three cases the right-hand side is at least \(1=d(x,z)\). This proves the triangle inequality. If \(X=\varnothing\), there are no pairs or triples of points, so all the metric axioms, which quantify over points of \(X\), hold vacuously. \(\square\)

This proof also explains why the triangle inequality works: when the endpoints differ, a route through an intermediate point either includes one distance of one or two such distances. It cannot have total distance less than one.

Worked Example: A Three-Point Set

Let \(X=\{a,b,c\}\) and give it the discrete metric. Calculate the distances from \(a\), then find the open balls centered at \(a\) for radii \(1/2\), \(1\), and \(3/2\).

The defining rule gives \(d(a,a)=0\), because the two points are equal. Since \(a\ne b\), \(d(a,b)=1\); since \(a\ne c\), \(d(a,c)=1\). Thus the distances from \(a\), in the order \(a,b,c\), are \(0,1,1\).

For a positive radius \(r\), the open ball is \(B_d(a,r)=\{y\in X:d(a,y)<r\}\). With \(r=1/2\), the membership tests are \(0<1/2\) for \(a\), \(1<1/2\) for \(b\), and \(1<1/2\) for \(c\). Only \(a\) passes, so \(B_d(a,1/2)=\{a\}\). With \(r=1\), the tests are \(0<1\), \(1<1\), and \(1<1\). Only the first is true, so \(B_d(a,1)=\{a\}\). With \(r=3/2\), the tests are \(0<3/2\), \(1<3/2\), and \(1<3/2\); all are true, so \(B_d(a,3/2)=\{a,b,c\}=X\).

Check: Each result is exactly the set of points whose already computed distances from \(a\) are strictly less than the chosen radius. In particular, the two points at distance \(1\) are excluded at radius \(1\), but included at radius \(3/2\).

Open Balls: The Three Radius Cases

For any metric \(d\), an open ball of center \(x\) and radius \(r\) is defined only for \(r>0\), and consists of the points \(y\) satisfying \(d(x,y)<r\). Applying this definition to the discrete metric gives the full classification below. The equality case \(r=1\) belongs with the smaller radii, not with the larger ones, because the ball condition is strict.

Theorem: If \(d\) is the discrete metric on \(X\), \(x\in X\), and \(r>0\), then $$ B_d(x,r)= \begin{cases} \{x\},&0<r\le 1,\\ X,&r>1. \end{cases} $$

Proof. Fix \(x\in X\). If \(0<r\le1\), then \(d(x,x)=0<r\), so \(x\in B_d(x,r)\). For any \(y\ne x\), \(d(x,y)=1\), and \(1\not<r\) because \(r\le1\). Thus no point different from \(x\) lies in the ball, and \(B_d(x,r)=\{x\}\). This argument includes \(r=1\): points at distance exactly one do not satisfy \(d(x,y)<1\).

If \(r>1\), then \(d(x,x)=0<r\), and for each \(y\ne x\) we have \(d(x,y)=1<r\). Hence every point of \(X\) belongs to the ball, so \(B_d(x,r)=X\). These cases cover every positive radius, and prove the formula. \(\square\)

The theorem says that there is no intermediate ball in the discrete metric. A positive radius below one, or exactly one, selects only the center. Once the radius is larger than one, every point qualifies. Radius zero is not included in the definition of an open ball; if one informally applies the inequality \(d(x,y)<0\), no point qualifies because all distances are nonnegative.

Worked Example: An Infinite Set

Take \(X=\mathbb{N}=\{1,2,3,\dots\}\) with the discrete metric, and center a ball at \(x=4\). Compute the balls for radii \(2/3\), \(1\), and \(5/4\).

The distance from \(4\) to \(4\) is \(0\). For every natural number \(n\ne4\), the distance \(d(4,n)\) is \(1\). At radius \(2/3\), the center passes because \(0<2/3\), while every other natural number fails because \(1\not<2/3\). Therefore \(B_d(4,2/3)=\{4\}\).

At radius \(1\), the center passes because \(0<1\). Each \(n\ne4\) fails because its distance is \(1\), and \(1<1\) is false. Hence \(B_d(4,1)=\{4\}\). At radius \(5/4\), the center passes because \(0<5/4\), and every \(n\ne4\) passes because \(1<5/4\). Thus \(B_d(4,5/4)=\mathbb{N}\).

Check: The calculation uses only whether a point equals \(4\), not how large or small the natural number is. The distances are \(0\) for \(4\) and \(1\) for every other \(n\), so the stated membership tests account for every point of \(\mathbb{N}\).

Worked Example: The Real Line with a Different Metric

Let the underlying set be \(\mathbb{R}\), but use the discrete metric rather than the usual distance \(|x-y|\). Find the ball centered at \(0\) with radius \(1/4\), and the ball centered at \(0\) with radius \(2\).

Under this metric, \(d(0,0)=0\). If \(y\in\mathbb{R}\) and \(y\ne0\), then \(d(0,y)=1\), regardless of the usual numerical size of \(y\). For radius \(1/4\), \(0<1/4\), but \(1\not<1/4\). The center is the only member, so \(B_d(0,1/4)=\{0\}\). For radius \(2\), both \(0<2\) and \(1<2\) hold. Every real number therefore belongs, and \(B_d(0,2)=\mathbb{R}\).

Check: The number \(100\), for example, is not in the first ball because \(100\ne0\) gives \(d(0,100)=1\), and \(1\not<1/4\). It is in the second because \(1<2\). This is a different metric on the same set: membership is determined by equality with the center, not by the usual numerical distance.

The One-Point Case and a Common Mistake

The formula for balls also handles a space with just one point. If \(X=\{p\}\), then every ball centered at \(p\) is \(\{p\}\) for every positive radius. For \(0<r\le1\), the theorem gives \(\{p\}\); for \(r>1\), it gives \(X=\{p\}\), which is again \(\{p\}\). Thus the two cases in the formula can produce the same set in a one-point space. This does not invalidate the classification.

Common pitfall. A frequent error is to treat the ball condition as \(d(x,y)\le r\) instead of \(d(x,y)<r\). For \(X=\{a,b\}\) with the discrete metric, \(d(a,a)=0\) and \(d(a,b)=1\). The incorrect calculation \(B_d(a,1)=\{y:d(a,y)\le1\}=\{a,b\}\) uses a non-strict inequality. The correct calculation uses \(0<1\), so \(a\) is included, and \(1\not<1\), so \(b\) is excluded. Therefore the actual open ball is \(B_d(a,1)=\{a\}\).

This distinction is not a technicality at a single special value. The value one is the distance from the center to every other point, so the strictness of the inequality decides whether those other points are in the ball. At any radius larger than one they are included; at radius one they are not.

What the Calculation Reveals

The discrete metric is a useful test case because the metric axioms and the ball definition can both be checked directly. Its triangle inequality holds even when a route through an intermediate point does not shorten the distance, and its balls change form at a precise threshold. The key calculation is always the same: compare \(r\) with the only possible distances, \(0\) and \(1\).

For any center \(x\), the center is in every positive-radius ball because \(d(x,x)=0\). A different point has distance exactly one, so it belongs precisely when \(1<r\). The resulting rule is therefore \(\{x\}\) for \(0<r\le1\), and \(X\) for \(r>1\). Remembering the strict inequality resolves the equality case without ambiguity.

Check Your Understanding

Use the definition \(B_d(x,r)=\{y:d(x,y)<r\}\) and the two possible discrete distances to answer these questions.

  1. On \(X=\{u,v,w\}\), find \(B_d(v,1/3)\), \(B_d(v,1)\), and \(B_d(v,4/3)\).
  2. For what positive radii does a point \(y\ne x\) belong to \(B_d(x,r)\) in the discrete metric?
  3. Explain why the triangle inequality holds when \(x\ne z\), separating the cases \(y=x\), \(y=z\), and \(y\) different from both.
  4. On a one-point set \(X=\{p\}\), compare \(B_d(p,1/2)\) with \(B_d(p,2)\). Why are the answers equal even though the radii fall into different cases?
  5. Identify and correct the error in the claim that \(B_d(a,1)=\{a,b\}\) when \(d\) is the discrete metric on \(\{a,b\}\).