This question is from Spivak's Calculus (3rd ed) Chapter 8 on Least upper bounds.
Let $f$ be a continuous function on $[a,b]$ with $f(a)<0<f(b)$. Show that there is a largest $x$ in $[a,b]$ with $f(x)=0$.
Before the actual question there is a reference to Theorem 1 which proves there exists a smallest $x$ in $[a,b]$ with $f(x)=0$. This seems to be used in the following answer given in the solutions manual:
Since $b-a+x$ varies between $b$ and $a$ as $x$ varies between $a$ and $b$, the function $g(x)=f(b-a+x)$ satisfies $g(a)=f(b)>0$ and $g(b)=f(a)<0$. So there is a smallest $y$ with $g(y)=0$. Then $x=b-a+y$ is the largest $x$ with $f(x)=0$.
I don't understand the proof. I don't see why "$b-a+x$ varies between $b$ and $a$ as $x$ varies between $a$ and $b$" and that $g(x)$ satisfies those conditions. Nor can't I see clearly how smallest $y$ for which $g(y)=0$ produces the largest $x$ with $f(x)=0$. I can only guess that it has something to do with the ends points being switched around. Can anyone give a clearer write up of what the solution is trying to do.