Lagrange Multipliers
Math 211  Prof. Leise

Email completed labs to tleise@amherst.edu by noon next Wednesday.

Recall that we use the method of Lagrange multipliers to find the extrema (max/min) of a function f(x,y) or f(x,y,z) under a constraint g(x,y)=0 or g(x,y,z)=0.  The idea is to solve the system of equations given by ∇f=λ∇g along with the constraint.  Mathematica can take care of the messy algebra and make this method much easier.

Feel free to use the Solve command, as demonstrated below, to solve a system of equations. Note that it gives you all possible solutions to a system of equations (if they only involve polynomials, as will be the case in these problems).

Solve[{x^2==lambda x,y^2==lambda y,x^2+y^2==1},{x,y,lambda}]

Another advantage of Mathematica is that we can easily graph level curves in order to visualize how the method of Lagrange multipliers works.  For example, the level curves of f(x,y)=x^2+y^2 are circles.  We can plot the level curves f(x,y)=k for k=1,4,9,16 using ContourPlot:

ContourPlot[{x^2+y^2==1,x^2+y^2==4,x^2+y^2==9,x^2+y^2==16},{x,-4,4},{y,-4,4}]

Exercise 1.  Let f(x,y)=x^3+y^3+3 x y.  Plot level curves of f(x,y) for k= -1, 0, 1, 10, and 100.

Exercise 2. Suppose the constraint is (x-3)^2+(y-3)^2==9.  Plot this circle with the level curves of f (add the constraint equation to the list of curves in ContourPlot).  Adjust the x and y intervals to make sure you see the entire circle.

Exercise 3. Add more level curves on the plot until you have found two level curves that appear to be tangent to the circle.  Use this to estimate the maximum and minimum values of f(x,y) where (x,y) is on the constraint circle.

Exercise 4. Set up the Lagrange multiplier equations to find the maximum and minimum values of f(x,y)=x^3+y^3+3 x y for points (x,y) satisfying the constraint (x-3)^2+(y-3)^2==9.  Use the Solve command to solve the resulting three equations.  Ignore any solutions with complex numbers.  What are the maximum and minimum values?  You can use NSolve to get decimal approximations.