Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
Example 4.9.10
Find the extrema of fx,y,z=2 x+3 y−5 z subject to the constraints 3 x2+2 y2=4 and 4 x+3 z=1.
Solution
Mathematical Solution
Figure 4.9.10(a) shows the constraint g=0 as the red cylinder, the constraint h=0 as the green plane, and the curve of intersection in black.
The constrained optimization problem consists in finding the extreme values of the function f along the black curve of intersection of the constraints.
Figure 4.9.10(b) shows the level surfaces of f at the two extrema on the intersection of the constraints. At each extrema, ∇f is drawn in black, ∇g, in red, and ∇h, in green.
At each extrema, ∇f lies in the plane determined by the vectors ∇g and ∇h.
use plots, Student:-VectorCalculus in module() local p1,p2,p3,p4,g,h; g:=3*x^2+2*y^2=4; h:=4*x+3*z = 1; p2:=implicitplot3d([g,h],x=-2..3,y=-2..2,z=-3..3,style=surface,color=[red,green],transparency=[0,.3]); p3:=intersectplot(g,h,x=-2..2,y=-2..2,z=-3..3,color=black,thickness=3); p4:=display(p2,p3,scaling=constrained,axes=frame,labels=[x,y,z],view=[-2..3,-2..2,-3..3],tickmarks=[5,7,9],orientation=[55,80,0]); print(p4); end module: end use:
Figure 4.9.10(a) Constraints g=0 and h=0
use plots, Student:-VectorCalculus in module() local p1,p2,p3,p4,g,h,M,GfM,GgM,GhM,m,Gfm,Ggm,Ghm,fM,fm,f,p1M,p1m; g:=3*x^2+2*y^2=4; h:=4*x+3*z = 1; f:=2*x+3*y-5*z; fM:=1/9*sqrt(9570)-5/3; fm:=-1/9*sqrt(9570)-5/3; M:=[52/4785*sqrt(9570),9/1595*sqrt(9570),-208/14355*sqrt(9570)+1/3]; m:=[-52/4785*sqrt(9570),-9/1595*sqrt(9570),208/14355*sqrt(9570)+1/3]; GfM:=RootedVector(root=M,<2,3,-5>); GgM:=RootedVector(root=M,<104/1595*sqrt(9570),36/1595*sqrt(9570),0>); GhM:=RootedVector(root=M,<4,0,3>); Gfm:=RootedVector(root=m,<2,3,-5>); Ggm:=RootedVector(root=m,<-104/1595*sqrt(9570),-36/1595*sqrt(9570),0>); Ghm:=RootedVector(root=m,<4,0,3>); p1M:=PlotVector([GfM,GgM,GhM],color=[black,red,green],width=.2); p1m:=PlotVector([Gfm,Ggm,Ghm],color=[black,red,green],width=.2); p2:=intersectplot(g,h,x=-2..2,y=-2..2,z=-3..3,color=black,thickness=3); p3:=implicitplot3d([f=fM,f=fm],x=-4..4,y=-3..3,z=-4..4,style=surface,transparency=.3); p4:=display(p1M,p1m,p2,p3,scaling=constrained,axes=frame,labels=[x,y,z],view=[-8..7,-3..4,-6..6],tickmarks=[8,7,9],orientation=[56,63,-1]); print(p4); end module: end use:
Figure 4.9.10(b) Gradients of f,g,h
The Lagrange multiplier method finds the point of tangency of the level surfaces of f with the set of points common to the two constraints. The constraints intersect in a closed curve. Along this curve, the extrema of f occur when such a plane is tangent to the curve. Such points of tangency are found by making ∇f a linear combination of the gradients of the two constraints, that is, by solving the equations in ∇f=λ ∇g+μ ∇h, along with the two constraint equations g=h=0. This is the set of five equations
−3⁢x2−2⁢y2+4
= 0
−4 x−3 z+1
−6 λ x−4 μ+2
−4 λ y+3
−3 μ−5
in the five unknowns x,y,z,λ,μ. The solutions of these equations are then
λ=172⁢9570,μ=−53,x=524785⁢9570,y=91595⁢9570,z=−20814355⁢9570+13
and
λ=−172⁢9570,μ=−53,x=−524785⁢9570,y=−91595⁢9570,z=20814355⁢9570+13
Maple Solution - Interactive
Initialize
Tools≻Load Package: Student Multivariate Calculus
Loading Student:-MultivariateCalculus
Context Panel: Assign Name
f=2 x+3 y−5 z→assign
g=3 x2+2 y2−4→assign
Context Panel: Assign name
h=4 x+3 z−1→assign
Apply the LagrangeMultipliers command in the Student MultivariateCalculus package, captured in the task template. See Table 4.9.10(a).
Tools≻Tasks≻Browse:
Calculus - Multivariate≻Optimization≻Lagrange Multiplier Method
Method of Lagrange Multipliers
Enter objective function f
Enter constraints gk=0,k=1,…,entered as functions g1,g2,…
Enter coordinate variables, separated by commas:
Table 4.9.10(a) The Lagrange Multiplier Method task template
Converting the more cumbersome exact values in Table 4.9.10(a) to floating-point numbers results in the display to the right.
Obviously, one extrema is a maximum, and the other, a minimum.
x1.063-1.063y.5521-.5521z-1.0851.751λ11.359-1.359λ2-1.667-1.667f9.203-12.54
Optimization Assistant
The Optimization Assistant is no longer listed in Tools≻Assistants. It is now found in Tools≻Tutors≻Optimization
A numeric solution is available via the , launched from the Context Panel on the sequence f,g=0,h=0.
Figure 4.9.10(c) shows the Optimization Assistant finding the maximum of 9.2 at approximately 1.06,0.552,−1.084.
Figure 4.9.10(d) shows the Optimization Assistant finding the minimum of -12.54 at approximately −1.063,−0.552,1.751.
Figure 4.9.10(c) Constrained maximum
Figure 4.9.10(d) Constrained minimum
Implement the Lagrange multiplier method via first principles
F=f−λ g−μ h→assign
Write F and press the Enter key.
Context Panel: Student Multivariate Calculus≻Differentiate≻Gradient
Context Panel: Conversions≻To List
Context Panel: Solve≻Solve (explicit)
F
−3⁢x2+2⁢y2−4⁢λ−4⁢x+3⁢z−1⁢μ+2⁢x+3⁢y−5⁢z
→gradient
→to list
−3⁢x2−2⁢y2+4,−4⁢x−3⁢z+1,−6⁢λ⁢x−4⁢μ+2,−4⁢λ⁢y+3,−3⁢μ−5
→solve
λ=172⁢9570,μ=−53,x=524785⁢9570,y=91595⁢9570,z=−20814355⁢9570+13,λ=−172⁢9570,μ=−53,x=−524785⁢9570,y=−91595⁢9570,z=20814355⁢9570+13
Maple Solution - Coded
Install the Student MultivariateCalculus package.
withStudent:-MultivariateCalculus:
Define f, the objective function.
f≔2 x+3 y−5 z:
Define g, the first constraint function.
g≔3 x2+2 y2−4:
Define h, the second constraint function.
h≔4 x+3 z−1:
Implement the Lagrange multiplier method
Invoke the LagrangeMultipliers command from the Student MultivariateCalculus package. Use the print command and the tilde operator to list the solutions one beneath the other.
S≔LagrangeMultipliersf,g,h,x,y,z: print~S
524785⁢9570,91595⁢9570,−20814355⁢9570+13
Add the "detailed" option to the LagrangeMultipliers command. Use the print command and the tilde operator to list the solutions one beneath the other.
Q≔LagrangeMultipliersf,g,h,x,y,z,output=detailed: print~Q
x=524785⁢9570,y=91595⁢9570,z=−20814355⁢9570+13,λ1=172⁢9570,λ2=−53,2⁢x+3⁢y−5⁢z=19⁢9570−53
Implement the Lagrange multiplier method from first principles
Define F.
F≔f− λ g−μ h:
Use the Gradient command to obtain ∇f−λ ∇g.
Use the Equate command to equate each component of ∇f−λ ∇g to zero.
Use the solve command to obtain the real solution of the equations in ∇f−λ ∇g=0. Use the print command and the tilde operator to list the solutions one beneath the other.
R≔solveEquateGradientF,x,y,z,λ,μ,0,0,0,0,0,x,y,z,λ,μ,explicit: print~R
λ=172⁢9570,μ=−53,x=524785⁢9570,y=91595⁢9570,z=−20814355⁢9570+13
<< Previous Example Section 4.9 Next Section >>
© 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
Download Help Document