Lagrange Problems\302\251 2006 by Mike May, S.J.- maymk@slu.eduwith an aside on solving systems of equations(Section 15.3)In prior semesters, students commented that they were having trouble with the homework from the section on Lagrange multipliers. This worksheet shows how to use Maple to check your work on those problems.First we look at the slick way that Maple gives an answer, but hides all the details. It uses the solve command to solve a system of equations. Then we step through the work needed to solve a system by hand.Finding constrained extrema of a function in two variables.Problem #6) Find the extrema of f(x,y) = x*y subject to the constraint that g(x, y) = 4*x^2 +y^2 - 8 = 0.f := (x, y) -> x*y;
g := (x, y) -> 4*x^2 + y^2 - 8;The method we have been studying produces equations relating the partial derivatives of f and g with respect to x and with respect to y.L[x] := diff(f(x,y),x) - lambda*diff(g(x,y),x);
L[y] := diff(f(x,y),y) - lambda*diff(g(x,y),y);We now solve the system of equations made up of the constraint and the relations on the partial derivatives.solve({g(x,y), L[x], L[y]}, {x, y, lambda});This gives four solutions that we can plug in to find which is a maximum and which is a minimum.'f(1,2)' = f(1,2);
'f(1,-2)' = f(1,-2);
'f(-1,2)' = f(-1,2);
'f(-1,-2)' = f(-1,-2);Thus we have maxima at (1,2) and (-1, -2) and minima at (1,-2) and(-1,2).Finding constrained extrema of a function in three variables.This technique easily extends to problems in more variables and with more constraints.Problem # 11) Find the extrema of f(x, y, z) = x + y + z, subject to the constraintsx^2 + y^2 + z^2 = 1 and x = y +1.f := (x, y, z) -> x + y + z;
g := (x, y, z) -> x^2 + y^2 + z^2 - 1;
h := (x, y, z) -> x - y - 1;Note that since there are two constraints in this problem, we have two lambda variables in the system of equations, so that we have a system of five equations in five variables.L[x] := diff(f(x,y,z),x) + lambda[1]*diff(g(x,y,z),x) +
lambda[2]*diff(h(x,y,z),x);
L[y] := diff(f(x,y,z),y) + lambda[1]*diff(g(x,y,z),y) +
lambda[2]*diff(h(x,y,z),y);
L[z] := diff(f(x,y,z),z) + lambda[1]*diff(g(x,y,z),z) +
lambda[2]*diff(h(x,y,z),z);solve({g(x,y,z), h(x,y,z), L[x], L[y], L[z]},
{x,y,z,lambda[1], lambda[2]});Note that RootOf(-3 + 2_LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYnLUkjbWlHRiQ2I1EhRictRiM2JS1JJW1zdXBHRiQ2JS1GLDYlUSJaRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnLUkjbW5HRiQ2JFEiMkYnL0Y7USdub3JtYWxGJy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRicvJStiYWNrZ3JvdW5kR1EuWzI1NSwyNTUsMjU1XUYnRkFGK0ZGRkE=) = \302\261LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYlLUkmbXNxcnRHRiQ2Iy1JJm1mcmFjR0YkNigtRiM2JS1JI21uR0YkNiRRIjNGJy8lLG1hdGh2YXJpYW50R1Enbm9ybWFsRicvJStiYWNrZ3JvdW5kR1EuWzI1NSwyNTUsMjU1XUYnRjctRiM2JS1GNDYkUSIyRidGN0Y6RjcvJS5saW5ldGhpY2tuZXNzR1EiMUYnLyUrZGVub21hbGlnbkdRJ2NlbnRlckYnLyUpbnVtYWxpZ25HRkcvJSliZXZlbGxlZEdRJmZhbHNlRidGOkY3, since the expression RootOf(-3 + 2_LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYmLUkjbWlHRiQ2I1EhRictRiM2JC1JJW1zdXBHRiQ2JS1GLDYlUSJaRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnLUkjbW5HRiQ2JFEiMkYnL0Y7USdub3JtYWxGJy8lMXN1cGVyc2NyaXB0c2hpZnRHUSIwRidGQUYrRkE=) literally means the solutions of the equation -3 + 2z^2 = 0, or 2z^2 = 3. Therefore the solutions of the system of equations are (LUklbXJvd0c2Iy9JK21vZH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NzYkUSIyRidGOkY9RjovJS5saW5ldGhpY2tuZXNzR1EiMUYnLyUrZGVub21hbGlnbkdRJ2NlbnRlckYnLyUpbnVtYWxpZ25HRkovJSliZXZlbGxlZEdRJmZhbHNlRictSSNtb0dGJDYtUSIrRidGOi8lJmZlbmNlR0ZPLyUqc2VwYXJhdG9yR0ZPLyUpc3RyZXRjaHlHRk8vJSpzeW1tZXRyaWNHRk8vJShsYXJnZW9wR0ZPLyUubW92YWJsZWxpbWl0c0dGTy8lJ2FjY2VudEdGTy8lJ2xzcGFjZUdRLDAuMjIyMjIyMmVtRicvJSdyc3BhY2VHRl5vLUYyNihGNC1GIzYlLUkmbXNxcnRHRiQ2Iy1GNzYkUSI2RidGOkY9RjpGRUZIRktGTUY9RjotRlE2LVEiLEYnRjpGVC9GV1EldHJ1ZUYnRlhGWkZmbkZobkZqbi9GXW9RJjAuMGVtRicvRmBvUSwwLjMzMzMzMzNlbUYnLUYjNigtRlE2LVEqJnVtaW51czA7RidGOkZURlZGWEZaRmZuRmhuRmpuRlxvRl9vRjFGUEZhb0Y9RjpGW3BGYW9GPUY6). The first is a minimum, and the second is a maximum.'f(1/2+1/sqrt(6), -1/2+1/sqrt(6), 1/sqrt(6))' =
f(1/2+1/sqrt(6), -1/2+1/sqrt(6), 1/sqrt(6));
'f(1/2-1/sqrt(6), -1/2-1/sqrt(6), -1/sqrt(6))' =
f(1/2-1/sqrt(6), -1/2-1/sqrt(6), -1/sqrt(6));Solving systems of equations by eliminating variables.As stated above, this method gives answers but does not show how to solve the system of equations. We now look at the second example again, this time breaking down the problem of solving the system of equations into steps that could be reproduced by hand. We solve the system by repeatedly solving an equation for a variable and using the subs (for substitute) command to eliminate that variable.Start by collecting the system of equations to be solved.eq[1] := 0 = g(x,y,z); eq[2] := 0 = h(x,y,z);
eq[3] := 0 = L[x]; eq[4] := 0 = L[y]; eq[5] := 0 = L[z]; The first substitution we see comes from equation 2, where we see that x = y + 1. We make that substitution in all five equations.for i from 1 to 5 do
eq[i] := subs(x = y+1, eq[i]);
od;Notice that the substitution wipes out the equation that it came from. The next substitution comes from equation 5, with lambda[1] = -1/(2*z).for i from 1 to 5 do
eq[i] := subs(lambda[1] = -1/(2*z), eq[i]);
od;Now we use equation 4 to eliminate lambda[2].for i from 1 to 5 do
eq[i] := subs(lambda[2] = 1 - y/z, eq[i]);
od;Solving equation 3 for z gives z = (2*y + 1)/2.solve(eq[3],z);Substitute z = (2*y + 1)/2 into each equationfor i from 1 to 5 do
eq[i] := simplify(subs(z = (2*y+1)/2, eq[i]));
od;We are now ready to solve for y.ansy := [solve(eq[1],y)];LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Recall that x = y +1 and z = y + 1/2. That gives us the same points as we obtained above.ExercisesUse Maple to solve the following problems. On at least one of the problems solve the system of equations both ways as shown above. Be sure to label your answers. Note that the last two problems require that you also check the interior of a region for extrema since they involve inequality constraints.1) Find the extrema of f(x, y) = x^2 + y, subject to the constraint x^2 - y^2 = 1.2) Find the extrema of f(x, y, z) = x + 3*y +5*z, subject to the constraint x^2 + y^2 + z^2 = 1.3) Find the extrema of f(x, y) = xy, subject to the constraint x^2 + 2y^2 <= 1.4) Find the extrema of f(x, y) = x^3 - y^2, subject to the constraint x^2 + y^2 <= 1