Mathematics 263                                  Laboratory 7                                      October 27, 1993
	  
Name: _____________________________   Lab Partner: ___________________________
	  
Consulted with:  ____________________________________________________________

The Lagrange Multiplier Method

In this lab we introduce a technique for finding the extreme values of  a function f (x, y) when the  points (x, y) must fall on a curve C in the plane.  Enter the following command to define the ListPlotVectorField command we will use in this lab.

<<Graphics`PlotField`

Part 1:  A Simple Geometric Example

We begin by finding the minimum and maximum values of a function on the unit circle.  That is, we wish to find the extreme values of f (x, y) given that (x, y) is a point on the circle where x2 + y2 = 1.  Consider the function f (x, y) = x2.  Recall that minimum values of f (x, y) occur at critical points of the function (Lab 5 and yesterday's lecture); describe the set of all the critical points of f  (in the xy-plane) below.

Describe the intersection of the set of critical points of f  with the unit circle  x2 + y2 = 1.  Explain why this intersection must contain all points where f (x, y) attains its minimum on the circle.

Finally, before turning to Mathematica, where does the function f (x, y) = x2 attain its maximum on the unit circle?  Explain (in one sentence) how you know.

Here is the problem:  Checking for critical points found some of the extreme values, but not all of them, we need to find all the extreme values of a function f on a curve C.  The next commands plot the unit circle as a parametric curve.  Explain briefly below why the parametric equations x(t) = cos t, y(t) = sin t for 0 ≤ t ≤ 2π describes the unit circle.

x[t_] := Cos[t];
y[t_] := Sin[t];
unitcirc = ParametricPlot[{x[t],y[t]}, {t,0,2Pi},
           AspectRatio->Automatic]

The tool we will use in our search for extreme values is the gradient. Compute the gradient vector ∇f  for the function  f (x, y) = x2, type it into the command below, and enter the command.  Then enter the ListPlotVectorField command to get a plot of the gradient vectors of f  around the unit circle.

gradf[x_,y_] := {your gradient here}

fgradplot = ListPlotVectorField[
          Table[{{x[t],y[t]},gradf[x[t],y[t]]},
                {t,0,2Pi,Pi/12}],
          HeadScaling->Relative]

The command below plots the unit circle and the gradient vectors together, but without the coordinate axes.  Print a copy of the plot and draw in the points on the circle where f  attains its maximum value.  On the bottom out the printout:  Explain the relationship between the unit circle and the gradient vectors at these points.  What would the rate of change of f  be as we leave one of these points in a direction tangential to the circle?  (Think about the directional derivative.)  Explain why the statement "This is a critical point of the function f  restricted to the circle." is reasonable.

Show[fgradplot, unitcirc]

We have drawn the unit circle parametrically, but it is also a level curve of a function.  There are many functions that have the unit circle as a level curve, but one of the simplest is
g(x, y) = (x2 + y2)/2.  Compute the gradient of g, type it into the first command below, and enter the command.  Enter the next command to get a plot of the gradient vectors of r around the unit circle.  The last command plots the unit circle and gradient vectors together.  What basic relationship do the level curves of a function and the gradient vectors of that function have?  Does your plot demonstrate this relationship?

gradg[x_,y_] := {your gradient here}

ggradplot = ListPlotVectorField[
          Table[{{x[t],y[t]},gradr[x[t],y[t]]},
                {t,0,2Pi,Pi/12}],
          HeadScaling->Relative]

Show[ggradplot,unitcirc]

From your answers to to the questions above, it should be clear that the maximum values of f on the unit circle are attained when ∇f  and ∇g  point in the same direction (or in opposite directions).  Use a Show command to create a plot of the unit circle with gradient vectors of both functions.  Print a copy and circle the points where the gradients ∇f  and ∇g  point in the same direction.  Are these the same points you circled on your first printout?

Part 2: The Multiplier in the Method

Two vectors point in the same direction when one is a nonzero scalar multiple of the other. That is, ∇f  and ∇g point in the same direction when there is a nonzero number λ so that ∇f  = λ∇g.  The number λ is called the Lagrange multiplier (λ is the Greek letter "l").  Below explain (in a sentence or two) why, if we are hunting for places where f takes on its extreme values, we should look at places where ∇f  = 0∇g as well.  That is, λ = 0 still gives a place where f might take on an extreme value.

Let's try to tackle a problem where we don't already know the answer.  We will find the extreme values of F (x, y) = xy on the circle where x2 + y2 = 2.  This circle is also a level curve of the function g introduced in Part 1, so we can use it again here.  Our goal is to find all the points where ∇F  = λ∇g for some number λ.  This is really shorthand for two equations: Fx = λgx and Fy = λgy.  We begin by defining F and its partial derivatives.  Enter the commands below.

F[x_,y_] := x y

Fx[x_,y_] = D[F[x,y],x]

Fy[x_,y_] = D[F[x,y],y]

Using ∇g(x, y) = <x, y> (you computed this in Part 1), this gives us the first two equations in the Solve command below.  The third equation makes sure we stay on the correct level curve of g.  Enter this command to request that Mathematica find the solutions

Solve[{Fx[x,y] == L x, Fy[x,y] == L y,
       x^2 + y^2 == 2},{x,y,L}]

Solve this system of three equations by hand in the space below; make sure that Mathematica has found all possible solutions, and has not given any "extraneous solutions" (incorrect answers).

In order to get a feeling for which  points will give the maximum value and which will give the minimum, let's examine a contour plot of F superimposed on the circle.  The following three commands will generate this plot.

lcF = ContourPlot[F[x,y],{x,-2,2},{y,-2,2},
      Contours->20]

newcirc = ParametricPlot[{Sqrt[2]Cos[t],Sqrt[2]Sin[t]},
                     {t, 0, 2Pi},AspectRatio->Automatic]

Show[lcF, newcirc]

Print a copy of this plot and circle the points that correspond to solutions of the multiplier problem.   On the bottom of the sheet, explain why the level curves of F are tangent to the circle at these points. Based on this plot, which solutions to the multiplier problem do you expect to give a maximum value?  Which  do you expect will give a minimum?  (Remember, darker shading corresponds to lower function values, lighter shading to higher function values.)

Check your answer by substituting the x and y values of your solutions into F(x, y).  For instance, one solution is {L -> 1, x -> 1, y -> 1}, so we enter the following command to find the corresponding function value:

F[1, 1]

What are the maximum and minimum values of the function F on the circle  x2 + y2 = 2?

Part 3: Homework

Use Mathematica to solve some of the homework on the Lagrange multiplier method in the book.  In particular try problems 1 and 5.

In problem 5, explain what the problem means geometrically; consider the following questions.