<s>[INST] Let $C$ be the curve of intersection of the plane $x+y-z=0$ with ellipsoid $\frac{x^2}4+\frac{y^2}5+\frac{z^2}{25}=1$. Let $C$ be the curve of intersection of the plane $x+y-z=0$ and the ellipsoid $$\frac{x^2}4+\frac{y^2}5+\frac{z^2}{25}=1$$ Find the points on $C$ which are farthest and nearest from the origin
When dealing with constraints I tried to consider the function $$F(x,y,z)=x^2+y^2+z^2-\lambda(x+y-z)-\mu\left(\frac{x^2}4+\frac{y^2}5+\frac{z^2}{25}-1\right)$$ However, I cannot solve this equation after differentiating respect to $x,y,z$ because it yields three equations with no common solution. 
The system of equations are 
$$2x=\lambda+\frac{\mu x}{2}$$
$$2y=\lambda+\frac{2\mu y}{5}$$
$$2z=-\lambda+\frac{2\mu z}{25}$$
How would I approach this problem, thanks.
 [/INST] Since I am lazy to do it by hands, I give you the sage code.
$###lagrange method
sage:x, y, z, lam , mu= var('x, y, z, lam, mu')  
sage:f=x^2+y^2+z^2  
sage:g1 = x^2/4+y^2/5+z^2/25-1 
sage:g2 = x +y -z  
sage:h = f - g1 * lam -g2 * mu  
sage:gradh = h.gradient([x, y, z, lam, mu])  
sage:critical = solve([gradh[0] == 0, gradh[1] == 0, gradh[2] == 0, gradh[3] == 0, gradh[4] == 0],x, y, z, lam, mu, solution_dict=True)   
sage:for i in range(0,len(critical)):      
   print show(critical[i]),float(f(critical[i][x], critical[i][y], critical[i][z]));

you shall get
$\left\{z : \frac{5}{646} \, \sqrt{2} \sqrt{17} \sqrt{19}, x :
\frac{20}{323} \, \sqrt{2} \sqrt{323}, y : -\frac{35}{646} \, \sqrt{2}
\sqrt{17} \sqrt{19}, \mbox{lam} : \frac{75}{17}, \mu : -\frac{70}{5491}
\, \sqrt{2} \sqrt{17} \sqrt{19}\right\} 4.41176470588$
$
\left\{z : -\frac{5}{646} \, \sqrt{2} \sqrt{17} \sqrt{19}, x :
-\frac{20}{323} \, \sqrt{2} \sqrt{323}, y : \frac{35}{646} \, \sqrt{2}
\sqrt{17} \sqrt{19}, \mbox{lam} : \frac{75}{17}, \mu : \frac{70}{5491}
\, \sqrt{2} \sqrt{17} \sqrt{19}\right\} 4.41176470588$
$\left\{z : \frac{5}{19} \, \sqrt{5} \sqrt{19}, x : \frac{2}{19} \,
\sqrt{5} \sqrt{19}, y : \frac{3}{19} \, \sqrt{5} \sqrt{19}, \mbox{lam} :
10, \mu : -\frac{6}{19} \, \sqrt{5} \sqrt{19}\right\} 10.0$
$\left\{z : -\frac{5}{19} \, \sqrt{5} \sqrt{19}, x : -\frac{2}{19} \,
\sqrt{5} \sqrt{19}, y : -\frac{3}{19} \, \sqrt{5} \sqrt{19}, \mbox{lam}
: 10, \mu : \frac{6}{19} \, \sqrt{5} \sqrt{19}\right\} 10.0
$
So you have two points where f has minimum 4.411 and two points where you have the maximum 10.
</s>