Spivak Calculus on Manifolds, Problem 2-27 In the section on Partial Derivatives of Chapter 2, Calculus on Manifolds by Spivak, he mentions that the boundary of $A$ could be all of $A$ and Problem 2-27 shows one way of tackling this problem.

While it is not hard to prove 2-27, I don't think that I fully understand the advantage of doing this. Can anyone give a concrete example of using this method to solve certain optimization problems? Also, is $f$ required to be continuous in this question?
 A: Just to try to make some sense out of this. Let's solve a really simple problem of finding the maximum of $f(x,y,z) = x^2 + 2y^2 - z^2$ on the sphere. (You can use Lagrange multiplier, but that would require the function $f(x,y,z)$ is defined over a neighborhood of the sphere. Let's assume the function $f(x,y,z)$ is only defined on the sphere (abstractly, this is all we have when we don't have an explicit expression of $f$), and isn't extended to $\mathbb R^3$, so we have to solve the problem without going out of the sphere, which is in the spirit of intrinsic differential geometry.)
Then $f\circ g = 2x^2 + 3y^2 - 1$, with partial derivatives being $4x, 6y$. So the only critical point is $(0, 0)$, where $f\circ g = -1$. similarly $f\circ h$ has a unique critical point at $(0, 0)$ as well where $f\circ h = -1$. (This is indeed where the function achieves its minimum, not the maximum. So the maximum is actually achieved on the boundary. Similarly $f\circ h$ will not tell us about the maximum either, unless we are willing to work on the boundary, which will be a constrained optimization problem, much harder.)
We can also reparametrize (part of) the sphere using $(y,z)$ and the chart map $G(y,z) = (\sqrt{1-y^2-z^2}, y, z)$, then $f\circ G = y^2 - 2z^2 + 1$, and the only critical point is $y=z=0$ where $f\circ G=1$. Then consider the chart $H(x,z) = (x, \sqrt{1-x^2-y^2}, z)$, and $f\circ H = 2 - 2x^2 - 3z^2$ where the critical point is achieved at $x=z=0$, and $f\circ H = 2$ at this point.
This doesn't seem to do anything, but now we're confident that the maximum of $f$ must be among $-1, 1, 2$. Why? Because put all the charts we have used together, every point on the manifold must be in the interior of one of the charts, and $f\circ T$ has a maximum at an interior point, then the point has to be critical. This shows us how to use different charts to solve a problem (without ever worrying about the boundary or going beyond the manifold itself), so the idea of (sub)manifold, charts, etc are useful (if not natural yet).
