<s>[INST] Based on a coordinate system centered in a sphere where is $M(x, y, z) = 6x - y^2 + xz + 60$ smallest? I am trying to work through a few examples in my workbook, and this one has me completely dumbfounded. 
Suppose I have a sphere of radius 6 metres, based on a coordinate system centred in that sphere, at what point on the sphere will $M(x, y, z) = 6x - y^2 + xz + 60$ be smallest?
I have been racking my brain for ages, but I don't see how best to solve this.
If someone has any ideas, I would greatly appreciate your help.
Cheers
Tim
 [/INST] Using a Lagrange Multiplier
You want to minimize
$$
M(x,y,z) = 6x -y^2 + xz + 60
$$
under the constraint
$$
R(x,y,z) = 6
$$
where
$$
R(x,y,z) = \sqrt{x^2+y^2+z^2}
$$
We define the Lagrange function
$$
\Lambda(x,y,z, \lambda) = M(x,y,z) + \lambda(R(x,y,z)-6)
$$
for some constant $\lambda$ and derive its gradient
$$
\mbox{grad } \Lambda =
(\partial_x \Lambda, \partial_y \Lambda, 
\partial_z \Lambda, \partial_\lambda \Lambda)^\top
$$
with
\begin{align}
\partial_x \Lambda &=
6 + z + \frac{\lambda x}{\sqrt{x^2+y^2+z^2}} \\
\partial_y \Lambda &=
-2y + \frac{\lambda y}{\sqrt{x^2+y^2+z^2}} \\
\partial_z \Lambda &=
x + \frac{\lambda z}{\sqrt{x^2+y^2+z^2}} \\
\partial_\lambda \Lambda &=
\sqrt{x^2+y^2+z^2} - 6
\end{align}
A vanishing gradient leads to the system
$$
\left(
\begin{matrix}
-6 \\
0 \\
0
\end{matrix}
\right)
=
\left(
\begin{matrix}
\lambda/6 & 0 & 1 \\
0 & -2 + \lambda / 6 & 0 \\
1 & 0 & \lambda  / 6
\end{matrix}
\right)
\left(
\begin{matrix}
x \\
y \\
z
\end{matrix}
\right)
$$
and the constraint $R(x,y,z) = 6$.
The second row implies $\lambda/6 = 2$.
Then the third row gives $x = -2z$ and the first row gives 
$2x = -6 - z$ or $6 = 3z$ or $z = 2$ and thus $x = -4$.
To honour the constraint $y$ should be $y = \pm 4$.
So we found the critical points $(-4,\pm 4,2)^\top$ which are on the surface and have the value $M = 12$ (if I made no mistake :-)
Here are some visualizations:


Using Spherical coordinates
Another approach is to move to spherical coordinates
$$
\begin{align}
x &= r \cos \phi \sin \theta \\
y &= r \sin \phi \sin \theta \\
z &= r \cos \theta
\end{align}
$$
This leads to
$$
M(\phi,\theta) =
36 \left(
\cos \phi \sin \theta -
\sin^2 \phi \sin^2 \theta +
\cos \phi \sin \theta \cos \theta
\right) + 60
$$
A vanishing gradients leads to
\begin{align}
0 
&= \partial_\phi M \\
&= - \sin \phi \sin \theta -
2 \sin \phi \cos \phi \sin^2 \theta -
\sin \phi \sin \theta \cos \theta \\
&= -\sin \phi \sin \theta(1 + 2 \cos \phi \sin \theta + \cos \theta) \\
0 
&= \partial_\theta M \\
&= \cos \phi \cos \theta -
2 \sin^2 \phi \sin \theta \cos \theta +
\cos \phi (\cos^2 \theta - \sin^2 \theta) \\
&= \cos \phi \cos \theta - \sin^2 \phi \sin(2 \theta) +
\cos \phi \cos(2 \theta)
\end{align}
Again some visualizations.


Note: The images seem to be upside down. I will replace them later, after checking again.
</s>