Section 14.7: We need the package "vect"

load(vect);

Exercise 6: Find the local minimum and maximum and saddle points
for f(x,y) = x^3*y + 12*x^2 - 8*y

f: x^3*y + 12*x^2 - 8*y;

draw3d(enhanced3d=true, view=[60,30],
       explicit(f,x,-8,8,y,-8,8),
       xlabel="x", ylabel="y");

wxdraw3d(color=red, contour=map, contour_levels={-100,-50,3,5,50,100,150,200,250,300},
       explicit(f,x,-8,8,y,-8,8),
       user_preamble="unset clabel", xlabel="x", ylabel="y");

del_f: ev(express(grad(f)),diff);

realonly: true;

sol: solve([del_f[1]=0, del_f[2]=0]);

f_xx: diff(f,x,2);

D: diff(f,x,2)*diff(f,y,2) - diff(f,x,1,y,1)^2;

D, sol[1]; f_xx, sol[1];

Exercise 10: Find the local minimum and maximum and saddle points
for f(x,y) = 2*x^3 + x*y^2 + 5*x^2 + y^2

f: 2*x^3 + x*y^2 + 5*x^2 + y^2;

draw3d(enhanced3d=true, view=[60,30],
       explicit(f,x,-6,6,y,-6,6),
       xlabel="x", ylabel="y");

wxdraw3d(color=red, contour=map, contour_levels={-100,-50,-1,2,4,50,100,150,200,250,300},
       explicit(f,x,-6,6,y,-6,6),
       user_preamble="unset clabel", xlabel="x", ylabel="y");

del_f: ev(express(grad(f)),diff);

sol: solve([del_f[1]=0, del_f[2]=0]);

f_xx: diff(f,x,2);

D: diff(f,x,2)*diff(f,y,2) - diff(f,x,1,y,1)^2;

D, sol[1]; f_xx, sol[1];

D, sol[2]; f_xx, sol[2];

D, sol[3]; f_xx, sol[3];

D, sol[4]; f_xx, sol[4];

Section 14.8: Exercise 6: Apply Lagrange multipliers to find the minimum and maximum
for f(x,y) = exp(x*y) subject to g(x,y) = x^3+y^3 = 16

f: exp(x*y);

g: x^3+y^3;

del_f: ev(express(grad(f)),diff);

del_g: ev(express(grad(g)),diff);

Here we only need real-valued solutons to the equations.

realonly: true;

sol: solve([del_f[1]=lmd*del_g[1], del_f[2]=lmd*del_g[2],g=16]);

f, sol[1];

Section 14.8: Exercise 8: Apply Lagrange multipliers to find the minimum and maximum
for f(x,y,z) = 8*x - 4*z subject to g(x,y,z) = x^2 + 10*y^2 + z^2 = 5

f: 8*x - 4*z;

g: x^2 + 10*y^2 + z^2;

del_f: ev(express(grad(f)),diff);

del_g: ev(express(grad(g)),diff);

sol: solve([del_f[1]=lmd*del_g[1], del_f[2]=lmd*del_g[2], del_f[3]=lmd*del_g[3], g=5]);

f, sol[1];

f, sol[2];