Homework, 14.8
MAT329
Andy Long

#3, p. 986

Clear[f,g,h,x,y,lam]
f[x_,y_]:=x^2+y^2
g[x_,y_]:=x y
h[x_,y_,lam_]:=f[x,y]+lam(g[x,y]-1)
Solve[
D[h[x,y,lam],x]==0&&
D[h[x,y,lam],y]==0&&
D[h[x,y,lam],lam]==0,{x,y,lam},Reals]
(* These must be minima, since along the hyperbola xy=1 the value of f can get as large as we'd like. *)

#12, p. 986: Now there’s a whole lotta symmetry goin’ on here....

f[x_,y_,z_]:=x^4+y^4+z^4
g[x_,y_,z_]:=x ^2+y^2+z^2
ContourPlot3D[f[x,y,z],{x,-2,2},{y,-2,2},{z,-2,2}]
p1=SliceContourPlot3D[f[x,y,z],{x,-1,1},{y,-1,1},{z,-1,1}];
p2=ContourPlot3D[g[x,y,z],{x,-2,2},{y,-2,2},{z,-2,2},Contours->{1}];
Show[p1,p2]
h[x_,y_,z,lam_]:=f[x,y,z]+lam(g[x,y,z]-1)
soln=Solve[
D[h[x,y,z,lam],x]==0&&
D[h[x,y,z,lam],y]==0&&
D[h[x,y,z,lam],z]==0&&
D[h[x,y,z,lam],lam]==0,{x,y,z,lam},Reals]
xs=Replace[x,soln];
ys=Replace[y,soln];
zs=Replace[z,soln];
f[xs,ys,zs]
(* f values: There's obviously a lot of symmetry here! 
If 
0) none of the variables is 0, then f=1/3
1) just one of the variables is 0 and the others aren't, f=1/2
2) just two are 0, then the third is 1 in size, and f=1.
max of 1, and min of 1/3 
*)

#27, p. 988

Clear[p]
(* perimeter is fixed, p *)

f[x_,y_]:=x y
g[x_,y_]:=2 (x+y)
h[x_,y_,lam_]:=f[x,y]-lam(g[x,y]-p)
Solve[
D[h[x,y,lam],x]==0&&
D[h[x,y,lam],y]==0&&
D[h[x,y,lam],lam]==0,{x,y,lam},Reals]