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 looks at how to use Maple to check your work on those problems.First we look at the slick way that gives an answer, but hides all the details. It uses the solve command to solve the system of equations. Then we step through the work needed to solve the 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 has us producing equations relating the partials 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 partials.solve({g(x,y), L[x], L[y]}, {x, y, lambda});This gives 4 answers 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, y) = 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;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_NiMqJCklIlpHIiIjIiIi) = \302\261NiMtJSVzcXJ0RzYjKiYiIiQiIiIiIiMhIiI=,so the solutions are at (NiUsJiomIiIiRiUiIiMhIiJGJSomRiVGJS0lJXNxcnRHNiMiIidGJ0YnLCZGJEYnRihGJywkRihGJw==) and (NiUsJiomIiIiRiUiIiMhIiJGJSomRiVGJS0lJXNxcnRHNiMiIidGJ0YlLCZGJEYnRihGJUYo). 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 same exercise and break 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 do that substitution to all 5 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 us z = (2*y + 1)/2.for 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)];LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2JVEhRicvJSdpdGFsaWNHUSV0cnVlRicvJSxtYXRodmFyaWFudEdRJ2l0YWxpY0YnRecall that x = y +1 and z = y + 1/2. That gives us the same points as above.