Q:

Maximize, minimize interpretation problem

I have this:
$$
f(x,y,z)=x+y+z
$$
Decide the maximum and minimum value on the intersecting curve:
$$
h(x,y,z)= x^2+y^2+z^2-2=0
$$
$$
g(x,y,z)= x^2+y^2-z=0
$$
Given this, we know that the gradients give us a plane where the maximum/minimum is when the determinant of these gradients equal zero.
After calculating the determinant I end up with:
$$
2y(z+1)=2x(z+1)
$$
And after solving, substituting I have the correct maximum and minimum according to Wolfram Alpha.
The only problem, I have not examined when z=-1, and here I'm confused, because z=-1 give us that x and y can be whatever they want, and the function does not have max or min.
Am I misinterpreting something here?

A:

Take it as a regular optimization problem and construct the Lagrangian such as
$$L=x+y+z+\lambda_1(x^2+y^2+z^2-2)+\lambda_2(x^2+y^2-z)$$
The first order conditions are
$$\frac{\partial L}{\partial x}=1+2x\lambda_1+2x\lambda_2=0$$
$$\frac{\partial L}{\partial y}=1+2y\lambda_1+2y\lambda_2=0$$
$$\frac{\partial L}{\partial z}=1+2z\lambda_1-\lambda_2=0$$
$$\frac{\partial L}{\partial \lambda_1}=x^2+y^2+z^2-2=0$$
$$\frac{\partial L}{\partial \lambda_2}=x^2+y^2-z=0$$
If you solve the system (it takes some time) feasible sets are (ignoring imaginary ones)
$$x=\frac{1}{\sqrt{2}}\quad y=\frac{1}{\sqrt{2}}\quad z=1\quad \lambda_1=\frac{\sqrt{2}-2}{6}\quad \lambda_1=\frac{1+\sqrt{2}}{3}$$
$$x=-\frac{1}{\sqrt{2}}\quad y=-\frac{1}{\sqrt{2}}\quad z=1\quad \lambda_1=\frac{-\sqrt{2}-2}{6}\quad \lambda_1=\frac{1-\sqrt{2}}{3}$$

