core26 min studyLesson 161 in Mathematics

Metrics, open balls, and neighborhoods

Turn a distance rule into a precise language of local behavior and compare different geometries on the same set.

On this page

What you’ll understand

  • Check the metric axioms and identify a failed axiom in a proposed distance.
  • Compute open balls in Euclidean, maximum, and discrete metrics.
  • Use the triangle inequality to prove that an open ball is open.

Distance need not measure physical length. Two signals may be close when their maximum discrepancy is small; two strings may be close when few edits separate them. A metric isolates the rules that make such comparisons support analysis. Once those rules hold, limits and continuity can be studied without coordinates, angles, or differentiability. The first task is to separate a distance formula from the neighborhoods it creates: different formulas can describe the same local notion of closeness.

What a distance must guarantee

A metric on a set X assigns a nonnegative real number to every ordered pair of points. The value is zero exactly when the points agree, reversing the order leaves it unchanged, and traveling directly costs no more than traveling through an intermediate point. That last condition, the triangle inequality, is what allows nearby-to-nearby reasoning. It also prevents a shortcut through a third point from contradicting the claimed distance. These requirements must hold for every pair or triple, rather than just for examples plotted on a screen.

On the real line, absolute difference is a metric, while squared difference is not. For the points 0, 1, and 2, the squared direct distance is four but the two squared legs sum to two. Squared distance remains useful as an optimization loss, but the metric theorems cannot automatically be applied to it. A second warning concerns zero distance: allowing distinct points at distance zero gives a pseudometric. Identifying such points can produce a metric quotient, but that identification is an additional mathematical step.

d(x,y)=0  ⟺  x=y,d(x,y)=d(y,x),d(x,z)≤d(x,y)+d(y,z)d(x,y)=0\iff x=y,\qquad d(x,y)=d(y,x),\qquad d(x,z)\le d(x,y)+d(y,z)
Together with nonnegativity and finite real values, these conditions define a metric on X.↔ Scroll wide equations horizontally.

A ball depends on the selected metric

An open ball centered at x contains points whose distance from x is strictly less than a positive radius. In the Euclidean plane its picture is a disk. With the maximum metric, which takes the larger coordinate difference, its picture is an axis-aligned open square. The word ball denotes the inequality, not a commitment to a round shape. In the discrete metric, every distinct pair has distance one, so a radius at most one isolates its center and a radius greater than one includes the whole space.

Open sets are sets that contain a ball around each of their points. The radius may vary from point to point. To prove that a Euclidean interval is open, a point near its endpoint needs a smaller radius than a point near its center. A neighborhood of x is any set containing an open set around x; it need not itself be open. These distinctions become useful when functions, sequences, or spaces have no useful visual picture but still admit an explicit distance estimate.

Bd(x,r)={y∈X:d(x,y)<r},d∞(u,v)=max⁡{∣u1−v1∣,∣u2−v2∣}B_d(x,r)=\{y\in X:d(x,y)<r\},\qquad d_\infty(u,v)=\max\{|u_1-v_1|,|u_2-v_2|\}
The radius r is positive. A maximum-metric ball in the plane bounds each coordinate difference separately.↔ Scroll wide equations horizontally.

Use the unused distance to stay inside

Why is an open ball open? Choose a point y inside a ball centered at x with radius r. There is a positive margin between r and d(x,y). If z is closer to y than that margin, the triangle inequality places z inside the original ball. This proof is more valuable than the picture because it works for every metric, including edit distances and distances between functions. The local radius is produced from information already available rather than guessed from a drawing.

Two metrics can have identical open sets even when numerical distances differ. In the plane, Euclidean and maximum distances satisfy inequalities that place a ball for one metric inside a suitable ball for the other. Thus they define the same topology. This equivalence preserves convergence and continuity, but a general agreement of open sets does not by itself preserve Cauchy sequences or completeness. Later lessons will identify why these latter notions require control over pairs throughout a tail of a sequence.

Fit a smaller square inside a larger square

Use the maximum metric on the plane. Let the outer ball have center (0,0) and radius 3. For y=(2,1), give a positive radius whose ball around y stays inside the outer ball.

  1. The maximum distance from the origin to y is max(2,1)=2, so y lies inside the outer radius 3 with margin 1.

  2. Choose radius 1 around y, with the strict open-ball inequality. Any point z in this smaller ball has maximum distance less than 1 from y.

  3. Apply the triangle inequality: its distance from the origin is at most 2 plus a number strictly less than 1, hence is strictly less than 3. The entire smaller ball is inside.

The result

Radius 1 works. A point on the smaller square's boundary is excluded, which preserves the strict inequality required by the outer ball.

Explore the model

Interactive lab

Interactive lab · vectors

Distance from the origin in two metrics

The controls set a vector's angle and magnitude. Hold magnitude fixed and rotate it: Euclidean distance from the origin stays fixed, while the maximum absolute coordinate generally changes. Compute that maximum from the projection readouts. This lab displays one Euclidean vector, not selectable metric balls or a general metric-space renderer.

Distance from the origin in two metricsPlayback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Current readings: x component: 1.393; y component: 0.975; Magnitude: 1.7. All parameters are adjustable with the labeled controls below.−7.46−3.7303.737.46−3.5−1.7501.753.5xyvvₓ = 1.39
Vectorx / y projectionsTrace marker
x component
1.393
y component
0.975
Magnitude
1.7
t = 0 s

Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forChanging a distance rule changes numerical closeness even when the underlying points are unchanged.

Check your understanding

Which calculation disproves that squared absolute difference is a metric on the real line?

Try it yourself

For the discrete metric on an arbitrary nonempty set X, determine the ball of radius 1 and the ball of radius 1.1 around x. Explain why every subset of X is open.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Separate the center's distance zero from every other point's distance one. Open balls use a strict inequality.

Compare with the solution

The radius-1 ball is {x}, because other points have distance exactly 1 and are excluded. The radius-1.1 ball is all of X. For any subset U and any x in U, the radius-1 ball around x is contained in U. That is precisely the open-set condition. The empty set also satisfies it vacuously because there is no point at which the condition can fail.

Take it with you

  • A useful loss or similarity score need not satisfy the metric axioms.
  • Open balls are defined by distance inequalities, not their shape in a drawing.
  • The triangle inequality turns a positive margin into a neighborhood contained in a larger ball.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.