Showing the continuity of $d(x,f(x))$

Assume that $(X,d)$ is compact, and that $f: X \to X$ is continuous. Show that the function $g(x) = d(x,f(x))$ is continuous and has a minimum point.

Consider the function $g(x) = d(x,f(x))$. If $g$ is continuous, then $\forall \epsilon >0 \ \exists \delta > 0$ such that $$d(x,y) < \delta \implies d(g(x), g(y)) < \epsilon.$$ Since $f$ is continuous and that $X$ is compact, we have that $f: X \to X$ is uniformly continuous. Therefore, $\forall \epsilon > 0 \ \exists \delta > 0 \ \text{such that} \ d(x,y) < \delta \implies d(f(x),f(y))< \epsilon.$

But how do we go on from here, considering $d(g(x),g(y)) = d(d(x,f(x)),d(y,f(y)))$ gets quite messy?

Solutions Collecting From Web of "Showing the continuity of $d(x,f(x))$"

As noted in the comments, $g: X \rightarrow \mathbb R$. Drawing a picture can be helpful. Since $f$ is continuous, when $x$ and $y$ are close to eachother $f(x)$ and $f(y)$ are close to each other, so $d(x, f(x))$ and $d(y,f(y))$ cannot differ by a large amount. We can formalize an argument as follows, using the triangle inequality, naturally:

$d(x,f(x)) \leq d(f(x), f(y)) + d(x,f(y)) \leq d(f(x), f(y)) + d(x,y) + d(y,f(y)).$

Similarly,

$d(y,f(y))) \leq d(f(x), f(y)) + d(x,y) + d(x,f(x)).$

It follows that

$|d(x,f(x)) – d(y,f(y))| \leq d(f(x), f(y)) + d(x,y).$

Now take $\min(\epsilon, \delta)$ as your $\delta$ (the $\delta$ comes from the uniform continuity of $f$). So $g$ is continuous. Since $X$ is compact, it attains a minimum.

You could also do this in steps:

  • First you could show that the map $$(x,x)\mapsto (x,f(x))$$ is a continuous function from $X\times X$ to $X\times X$.
  • Then you could show that $$(x,y)\mapsto d(x,y)$$ is a continuous function from $X\times X$ to $\mathbb R$.
  • Your function $g$ is the composition of the above two functions. Composition of continuous function is continuous.

Remark: If this is your first encounter with metric spaces, then you are probably expected to use $\epsilon$-$\delta$ definition and work directly with the map $g(x)$. Later, as you learn more about topological space (in particular, when you learn about products spaces) this approach will seem more natural to you.

The claim from the first bullet point can be generalized: Show that if $f,g$ are continuous then so is $f\times g$.

The claim from the second bullet point was discussed in several posts here on math.SE. For example, Metric is continuous function.