# Distance from Subset of Real Numbers

## Theorem

Let $S$ be a subset of the set of real numbers $\R$.

Let $x \in \R$ be a real number.

Let $d \left({x, S}\right)$ be the distance between $x$ and $S$.

Then:

- $x \in S \implies d \left({x, S}\right) = 0$
- If $S$ is bounded above and $x = \sup S$, then $d \left({x, S}\right) = 0$
- Similarly, if $S$ is bounded below and $x = \inf S$, then $d \left({x, S}\right) = 0$
- If $I$ is a closed real interval, then $d \left({x, I}\right) = 0 \implies x \in I$
- If $I$ is an open real interval apart from $\varnothing$ or $\R$, then $\exists x \notin I: d \left({x, I}\right) = 0$.

## Proof

From the definition of distance, $\forall x, y \in \R: d \left({x, y}\right) = \left|{x - y}\right|$.

Thus $d \left({x, S}\right) = \inf_{y \in S} \left({\left|{x - y}\right|}\right)$.

$x \in S \implies d \left({x, S}\right) = 0$:

Consider the set $T = \left\{{\left|{x - y}\right|: y \in S}\right\}$.

This has $0$ as a lower bound as Absolute Value is Bounded Below by Zero.

So:

- $\displaystyle d \left({x, S}\right) = \inf_{y \in S} \left({\left|{x - y}\right|}\right) \ge 0$

If $x \in S$ then:

- $\left|{x - x}\right| = 0 \in T$

and so:

- $0 \le \inf_{y \in S} \left({d \left({x, y}\right)}\right)$

Thus:

- $d \left({x, S}\right) = \inf_{y \in S} \left({d \left({x, y}\right)}\right) = 0$

$\blacksquare$

If $S$ is bounded above and $x = \sup S$, then $d \left({x, S}\right) = 0$:

Let $x = \sup S$.

Then $\forall y \in S: \left|{x - y}\right| = x - y$

So we need to show that no $h > 0$ can be a lower bound for $T = \left\{{\left|{x - y}\right|: y \in S}\right\}$.

Suppose this is false, and $\exists h > 0: \forall y \in S: x - y \ge h$.

But then $\forall y \in S: y \le x - h$ and hence $x - h$ is a lower bound for $T$ smaller than $x = \sup S$ which is supposed to be the supremum, i.e. the *smallest* upper bound.

So there is no such $h > 0$ and so $d \left({x, S}\right) = 0$.

$\blacksquare$

If $S$ is bounded below and $x = \inf S$, then $d \left({x, S}\right) = 0$:

Consider $d \left({-x, S'}\right)$ where $S' = \left\{{-x: x \in S}\right\}$.

By Negative of Infimum is Supremum of Negatives, $x = \inf S \implies-x = \sup S'$.

Thus from the above, $d \left({-x, S'}\right) = 0$ and hence the result.

$\blacksquare$

If $I$ is a closed real interval, then $d \left({x, I}\right) = 0 \implies x \in I$:

Since $I$ is an interval, if $x \notin I$ then $x$ is either an upper bound or a lower bound for $I$.

Suppose $x$ is an upper bound for $I$.

Let $B$ be the supremum of $I$.

Then because $I$ is closed, $B \in I$.

So:

\(\displaystyle \) | \(\displaystyle \forall y \in I:\) | \(\displaystyle \) | \(\displaystyle \left\vert{x - y}\right\vert\) | \(=\) | \(\displaystyle \) | \(\) | \(\displaystyle \) | \(\displaystyle x - y\) | \(\displaystyle \) | \(\displaystyle \) | |||

\(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(=\) | \(\displaystyle \) | \(\) | \(\displaystyle \) | \(\displaystyle x - B + B - y\) | \(\displaystyle \) | \(\displaystyle \) | |||

\(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(=\) | \(\displaystyle \) | \(\) | \(\displaystyle \) | \(\displaystyle x - B + \left\vert{B - y}\right\vert\) | \(\displaystyle \) | \(\displaystyle \) |

Now from Infimum Plus Constant:

- $\inf_{y \in S} \left|{x - y}\right| = x - B + \inf_{y \in S} \left|{B - y}\right|$

But we also have:

- $x - B \ge 0$
- $d \left({B, S}\right) \ge 0$
- $d \left({x, S}\right) = 0$

So it follows that $x = B$ and so $x \in I$.

A similar argument applies if $x$ is a lower bound for $I$.

$\blacksquare$

If $I$ is an open real interval apart from $\varnothing$ or $\R$, then $\exists x \notin I: d \left({x, I}\right) = 0$:

As $I \ne \varnothing$ and $I \ne \R$ it follows that one of the following applies:

- $\exists a, b \in \R: I = \left({a \,.\,.\, b}\right)$
- $\exists a \in \R: I = \left({a\,.\,.\, \infty}\right)$
- $\exists b \in \R: I = \left({-\infty\,.\,.\, b}\right)$

It follows by the definition of open real interval that $I$ has either an infimum $a$, or a supremum $b$, or both.

Thus the required value of $x$, from what has been proved above, is either $a$ or $b$.

$\blacksquare$

## Sources

- K.G. Binmore:
*Mathematical Analysis: A Straightforward Approach*(1977)... (previous)... (next): Exercise $\S 2.13 \ (5)$