Matthew Ebert
Mat 329 14.8 Problems
Problem #3
This file is to supplement my paper homework, these are to show the additional checks and work completed to figure out the Maximum and Minimums using Lagrange Multipliers.

Clear[f,g,fx,fy,gx,gy,x,y,z,a]
f[x_, y_] := x^2 + y^2
g[x_, y_] := x*y
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]
p1 = ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, Contours -> 10]; 
p2=Plot[{1/x},{x,-2,2},PlotStyle->Red];
Show[p1, p2, Graphics[{PointSize[0.025], Point[{1, 1}]}], Graphics[{PointSize[0.025], Point[{-1, -1}]}]]
fx[x_,y_]=D[f[x,y],x]
fy[x_,y_]=D[f[x,y],y]
gx[x_,y_]=D[g[x,y],x]
gy[x_,y_]=D[g[x,y],y]
Solve[g[x,y]==1&&fx[x,y]==a*gx[x,y]&&fx[x,y]==a*gx[x,y],{x,y,a},Reals]
FindMinimum[{f[x, y], x*y == 1}, {x, y}]
FindMaximum[{f[x, y], x*y == 1}, {x, y}]

Based upon this result, we can conclude that there is just a maximum at f(1,1) and f(-1,-1). At these points f equals 2.

Problem #6

Clear[f,g,fx,fy,gx,gy,x,y,z,a]
f[x_,y_]:=E^(x*y)
g[x_,y_]:=x^3+y^3
Plot3D[f[x,y],{x,-4,4},{y,-4,4}]
p1=ContourPlot[f[x,y],{x,-3,3},{y,-3,3},Contours->10];
p2=Plot[{CubeRoot[16-x^3]},{x,-4,4},PlotStyle->Red];
Show[p1,p2,Graphics[{PointSize[0.025],Point[{2,2}]}]]
fx[x_,y_]=D[f[x,y],x]
fy[x_,y_]=D[f[x,y],y]
gx[x_,y_]=D[g[x,y],x]
gy[x_,y_]=D[g[x,y],y]
Solve[g[x,y]==16&&fx[x,y]==a*gx[x,y]&&fx[x,y]==a*gx[x,y],{x,y,a},Reals]
FindMaximum[{E^(x*y),x^3+y^3==16},{x,y}]

Looking at these results, we can conclude that there is a maximum at f(2,2) and an infinite amount of minima. The value at this point is e^4 or 54.5982.

Problem #12

Clear [f,g,fx,fy,gx,gy,gz,fz,x,y,z,a]
g[x_,y_,z_]:=x^2+y^2+z^2
f[x_,y_,z_]:=x^4+y^4+z^4
ContourPlot3D[{x^4+y^4+z^4==1,x^4+y^4+z^4==1/3,x^2+y^2+z^2==1},{x,-1,1},{y,-1,1},{z,-1,1},Mesh-> None,ContourStyle->Opacity[0.5]]

fx[x_,y_,z_]=D[f[x,y,z],x]
fy[x_,y_,z_]=D[f[x,y,z],y]
fz[x_,y_,z_]=D[f[x,y,z],z]
gx[x_,y_,z_]=D[g[x,y,z],x]
gy[x_,y_,z_]=D[g[x,y,z],y]
gz[x_,y_,z_]=D[g[x,y,z],z]
Solve[{fx[x,y,z]==a*gx[x,y,z]&&fy[x,y,z]==a*gy[x,y,z]&&fz[x,y,z]==a*gz[x,y,z]&&g[x,y,z]==1},{x,y,z,a},Reals]
FindMaximum[{x^4+y^4+z^4,x^2+y^2+z^2==1},{x,y,z}]
FindMinimum[{x^4+y^4+z^4,x^2+y^2+z^2==1},{x,y,z}]

ael: I couldn’t resist adding a manipulate command.... Sorry Matthew!

Manipulate[
ContourPlot3D[{x^4+y^4+z^4==1,x^4+y^4+z^4==1/3,x^4+y^4+z^4==c,x^2+y^2+z^2==1},{x,-1,1},{y,-1,1},{z,-1,1},Mesh-> None,ContourStyle->Opacity[0.5]],
{c,1/3,1}]

Using basic intuition here we can see that when Lambda = 2/3 we have minima because f at these points equals 1/3, there are 6 minima which would be expected if you look at the cube in the graph, one minimum for each surface of the cube. If we check the origins we see that setting two varibles to zero gives us a value of 1 for f. This happens to be when lambda is equal to 2 and therefore our maximum, and there are 6 of these as well, they are at (+/-1,0,0), (0,+/-1,0), and (0,0,+/-1). There’s also another 12 maxima at the points where lamda is equal to 1, these points are (0, +/- 1/sqrt(2), +/- 1/sqrt(2)) (+/- 1/sqrt(2), 0, +/- 1/sqrt(2)) and (+/- 1/sqrt(2), +/- 1/sqrt(2), 0). This is a very fun function to use Lagrange on, because otherwise we’d find aliens before we found all the maxima and minima.

Problem #21

Clear[f,g,fx,fy,gx,gy,x,y,a]
f[x_,y_]:=E^-(x*y) 
g[x_,y_]:=x^2+4y^2
Plot3D[f[x,y],{x,-1,1},{y,-1,1}]
p1=ContourPlot[f[x,y],{x,-1,1},{y,-1,1},Contours->10];
p2=Plot[{Sqrt[(1-x^2)/4],-Sqrt[(1-x^2)/4]},{x,-1,1},PlotStyle->Red];
Show[p1,p2,Graphics[{PointSize[0.025],Point[{0.7071067620693885,0.35355338103465866}]}],Graphics[{PointSize[0.025],Point[{-0.7071067620693885,0.35355338103465866}]}],Graphics[{PointSize[0.025],Point[{0.7071067620693885,-0.35355338103465866}]}],Graphics[{PointSize[0.025],Point[{-0.7071067620693885,-0.35355338103465866}]}]]
fx[x_,y_]=D[f[x,y],x]
fy[x_,y_]=D[f[x,y],y]
gx[x_,y_]=D[g[x,y],x]
gy[x_,y_]=D[g[x,y],y]
Solve[g[x,y]<=1&&fx[x,y]==a*gx[x,y]&&fx[x,y]==a*gx[x,y],{x,y,a},Reals]
FindMinimum[{f[x,y],g[x,y]<=1},{x,y}]
FindMaximum[{f[x,y],g[x,y]<=1},{x,y}]
f[0,0]

The solve function here doesn’t seem to be helping us, I solved this on my paper and got 2 minimums and 2 maximums. I checked the function at (0,0) because fx and fy are zero at this point, but it turns out to just be a saddle point.