Let $\displaystyle (M, d)$ be a metric space. Let $\displaystyle f:M\longrightarrow M$ be a continuous function. Let $\displaystyle g:M\longrightarrow\mathbb{R}$ be defined by $\displaystyle x\longmapsto d(x,f(x))$. Show that $\displaystyle g$ is continuous.

So what we know is that $\displaystyle f$ is continuous, so for any $\displaystyle \eta>0$, there exists $\displaystyle \mu>0$ such that:

$\displaystyle d(x,y)<\mu \Rightarrow d(f(x),f(y))<\eta$

But what we want to do for any $\displaystyle \epsilon>0$ is to produce $\displaystyle \delta>0$ such that:

$\displaystyle d(x,y)<\delta \Rightarrow |g(x)-g(y)|=|d(x,f(x))-d(y,f(y))|<\epsilon$

I have a feeling we'll want to produce $\displaystyle \delta$ in terms of $\displaystyle \epsilon, \eta, \mu$. I was thinking breaking something up using a triangle inequality, but I've tried a few different ways that have all led to dead ends.