Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
|
Example 4.9.1
|
|
Find the extreme values of subject to the constraint .
|
|
|
|
Solution
|
|
|
Mathematical Solution
|
|
Figure 4.9.1(a) shows the surface and on it, the "lift" of the constraint curve . From this figure, infer that there are four extrema, two maxima and two minima.
Figure 4.9.1(b) shows the level curves of in black, and the curve defined implicitly by , in red. The points of tangency between the constraint curve and a level curve of defines a stationary point for the constrained optimization problem.
These stationary points occur where the gradients of and are collinear, that is, where is proportional to . The animation in Figure 4.9.1(c) shows these gradients traversing the constraint curve . They become collinear at the four points of tangency that are the stationary points that the Lagrange multiplier method finds.
>
|
use plots in
module()
local p1,p2,p3,a;
a:=1.37;
p1:=plot3d(2*x^2+3*y^2,x=-a..a,y=-a..a,transparency=0,lightmodel=none);
p2:=spacecurve([cos(t),sin(t),2*cos(t)^2+3*sin(t)^2],t=0..2*Pi,color=black,thickness=3);
p3:=display(p1,p2,scaling=constrained,axes=frame,view=0..4,tickmarks=[3,3,5],labels=[x,y,z],orientation=[-35,70,0]);
print(p3);
end module:
end use:
|
|
Figure 4.9.1(a) Constraint curve lifted to the surface
|
|
|
|
>
|
use plots in
E491:=module()
local p1,p2,f,g;
export p3;
f:=2*x^2+3*y^2;
g:=x^2+y^2-1:
p1 := implicitplot(g=0,x=-1..1,y=-1..1, color=red):
p2 := contourplot(f,x=-1.5..1.5,y=-1.2..1.2, contours=[1,2,3,4],color=black):
p3:=display([p1,p2],tickmarks=[[-1,0,1],[-1,0,1]],scaling=constrained):
print(p3);
end module:
end use:
|
|
Figure 4.9.1(b) in black and in red
|
|
|
|
>
|
use Student:-VectorCalculus, plots in
module()
local p1,X;
X:=proc(t)
local Vf,Vg;
Vf:=t->RootedVector(root=[cos(t),sin(t)],.7*<2*cos(t),3*sin(t)>);
Vg:=t->RootedVector(root=[cos(t),sin(t)],<cos(t),sin(t)>);
PlotVector([Vf(t),Vg(t)],color=[black,red]);
end;
p1:=animate(X,[t],t=0..2*Pi,frames=40,background=E491:-p3);
print(p1);
end module:
end use:
|
|
Figure 4.9.1(c) and on
|
|
|
|
|
|
The equations arising from = , and the constraint equation itself, are then
The first equation is satisfied if or . The second equation is satisfied if or .
If , the third equation gives . If , the third equation gives . Consequently, there are four solutions to these equations: , and .
|
|
Maple Solution - Interactive
|
|
Initialize
|
•
|
Tools≻Load Package:
Student Multivariate Calculus
|
|
Loading Student:-MultivariateCalculus
|
•
|
Context Panel: Assign name
|
|
|
•
|
Context Panel: Assign Name
|
|
|
Optimization Assistant
The Optimization Assistant is no longer listed in Tools≻Assistants. It is now found in Tools≻Tutors≻Optimization
|
•
|
A numeric solution and some useful graphics are available via the
, launched from the Context Panel on the sequence .
|
•
|
Each of the four extrema are found separately.
|
•
|
The first extrema, the minimum of 2 at , is obtained by clicking on the Solve button. If the Plot button is next clicked, Figures 4.9.1(e, f) can be obtained. Note the modification of the plotting ranges.
|
•
|
A second minimum can be obtained by adding initial values for the numeric search. Click the Edit button at the right of "Initial Values" and provide for new initial values. The search will now find the minimum 2 at .
|
|
|
Figure 4.9.1(d) Optimization Assistant
|
|
|
|
|
Figure 4.9.1(e) Surface, constraint, & minimum
|
|
|
|
|
Figure 4.9.1(f) Constraint as a surface
|
|
|
|
•
|
The maxima can be found by again adjusting the initial values.
|
|
Implement the Lagrange multiplier method via first principles
|
•
|
Context Panel: Assign Name
|
|
|
•
|
Write and press the Enter key.
|
•
|
Context Panel: Student Multivariate Calculus≻
Differentiate≻Gradient
|
•
|
Context Panel: Conversions≻To List
|
•
|
Context Panel: Solve≻Solve
|
|
|
|
|
The LagrangeMultipliers command in the Student MultivariateCalculus package is captured in the
task template. Its use is illustrated in Table 4.9.1(a).
Tools≻Tasks≻Browse:
Calculus - Multivariate≻Optimization≻Lagrange Multiplier Method
|
Method of Lagrange Multipliers
|
Enter objective function
|
|
Enter constraints entered as functions
|
|
Enter coordinate variables, separated by commas:
|
|
|
|
|
|
|
Table 4.9.1(a) The Lagrange Multiplier Method task template
|
|
|
|
|
Maple Solution - Coded
|
|
Initialize
|
•
|
Install the Student MultivariateCalculus package.
|
|
|
•
|
Define , the objective function.
|
|
|
•
|
Define , the constraint function.
|
|
|
Implement the Lagrange multiplier method
|
|
⇒
|
•
|
Apply the print command and tilde, the element-wise operator, to print the four solutions one under the other.
|
|
|
Implement the Lagrange multiplier method from first principles
|
|
|
•
|
Use the Gradient command to obtain .
|
•
|
Use the Equate command to equate each component of to zero.
|
•
|
Use the solve command to obtain the solutions of the equations in .
|
|
|
|
|
The code in Table 4.9.1(b) will draw Figure 4.9.1(b).
|
Table 4.9.1(b) Code for generating Figure 4.9.1(a)
|
|
|
|
|
|
<< Chapter Overview Section 4.9
Next Example >>
© Maplesoft, a division of Waterloo Maple Inc., 2024. All rights reserved. This product is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation.
For more information on Maplesoft products and services, visit www.maplesoft.com
|