# Spivak's calculus: Chapter 7 problem 18 d)

In cases (a) and (c) [where it was proven that such a number exists for a continous $f$ on $\textbf{R}$], let $g(x)$ be the minimum distance from $(x,0)$ to a point on the graph $f$. Prove that $g(y)\leq g(x)+|x-y|$, and conclude that $g$ is continous.

By definition, $g(x) = \sqrt{(f(z))^2+(z-x)^2}$ for some $z$ in $[a,b]$. Now $\sqrt{(f(z))^2+(z-y)^2} \leq \sqrt{(f(z))^2+(z-x)^2}+|z-y|$ for all $z$. So $g(y)$, the minimum of all $\sqrt{(f(z))^2+(z-y)^2}$, is less than or equal to $|z-y|+$ the minimum of all $\sqrt{(f(z))^2+(z-x)^2}$, which is $g(x)+|x-y|$. Since $|g(y)-g(x)|<|y-x|$ it follows that $g$ is continous (given $\varepsilon>0$, let $\delta = \varepsilon$).

I understand why $\sqrt{(f(z))^2+(z-y)^2} \leq \sqrt{(f(z))^2+(z-x)^2}+|z-y|$ for all $z$ and I see how the continuity of $g$ would follow from the conclusion. But I don't get why

the minimum of all $\sqrt{(f(z))^2+(z-y)^2}$, is less than or equal to $|z-y|+$ the minimum of all $\sqrt{(f(z))^2+(z-x)^2}$

and why this is supposed to be $g(x)+|x-y|$.

Can someone help me here?

Edit: I've now figured out the following things: if for some $z_0$ we have a minimum of $\sqrt{(f(z))^2+(z-y)^2}$, this means that $$g(y) \leq \sqrt{(f(z))^2+(z-y)^2} \leq \sqrt{(f(z))^2+(z-x)^2} +|y-z|$$ for all $z$. So we can simply pick a $z=u$ such that $\sqrt{(f(u))^2+(u-x)^2} = g(x)$, so then we have $$g(y) \leq g(x)+|u-y|$$ Does anyone now know how to turn that $|u-y|$ into $|x-y|$?

We see that the points $$(x,0)$$, $$(y,0)$$ and $$(z, f(z))$$ represent a triangle. And according to the triangle inequality we have, for every $$z$$ $$\sqrt{(f(z))^2+(y-z)^2} \leq \sqrt{(f(z))^2+(x-z)^2}+|x-y|.$$
Now for some $$z_0$$ we have $$g(y) = \sqrt{(f(z_0))^2+(y-z_0)^2} \leq \sqrt{(f(z))^2+(y-z)^2}$$ for all $$z$$. This means that for all $$z$$ $$g(y) \leq \sqrt{(f(z))^2+(x-z)^2} + |x-y|.$$ Now we simply choose a number $$u$$ such that $$g(x) = \sqrt{(f(u))^2+(x-u)^2}$$ So we have $$g(y) \leq g(x) + |x-y|$$.