Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
Example 4.9.2
Find the extreme values of fx,y=x y2 subject to the constraint 3 x+4 y=12.
Solution
Mathematical Solution
The black curves in Figure 4.9.2(a) are the level curves of f, whereas the red line is the graph of the constraint g=0. The constraint is tangent to a level curve as a single point, yet there are two extrema.
First, the existence of two extrema has to be detailed, then an explanation has to be forthcoming for why the constraint is tangent to a level curve just once.
With f=x y2 and g=3 x+4 y−12, solve ∇f=λ ∇g, and g=0, for x,y,λ. The equations to be solved are
−3⁢x−4⁢y+12,y2−3⁢λ,2⁢x⁢y−4 λ
use plots in module() local p1,p2,p3; p1:=contourplot(x*y^2,x=-2..4,y=-4..4,contours=[2,4,16/3,8,-2,-4,-6,-8],color=black); p2:=implicitplot(3*x+4*y=12,x=-2..3,y=-4..4,color=red); p3:=display(p1,p2,view=[-2..3,-4..4]); print(p3); end module: end use:
Figure 4.9.2(a) Level curves of f and g=0
and they have the two solutions x,y=4,0 (when λ=0), and x,y=4/3,2 (when λ=4/3). Thus, f4,0=0 is a local minimum, and f4/3,2=16/3 is a local maximum.
The constraint line is tangent to the level curve f=16/3 at x,y=4/3,2. At the local minimum, the Lagrange multiplier is zero, implying that the constraint is inoperative at that point. That point is a critical point for the unconstrained optimization problem because ∇f=0 all along the line y=0.
Maple Solution - Interactive
Initialize
Tools≻Load Package: Student Multivariate Calculus
Loading Student:-MultivariateCalculus
Context Panel: Assign Name
f=x y2→assign
g=3 x+4 y−12→assign
Apply the LagrangeMultipliers command in the Student MultivariateCalculus package, captured in the task template. See Table 4.9.2(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.2(a) The Lagrange Multiplier Method task template
Implement the Lagrange multiplier method via first principles
F=f−λ g→assign
Write F and press the Enter key.
Context Panel: Student Multivariate Calculus≻ Differentiate≻Gradient
Context Panel: Conversions≻To List
Context Panel: Solve≻Solve
F
−3⁢x+4⁢y−12⁢λ+x⁢y2
→gradient
→to list
−3⁢x−4⁢y+12,y2−3⁢λ,2⁢x⁢y−4⁢λ
→solve
λ=0,x=4,y=0,λ=43,x=43,y=2
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 f,g=0.
Figures 4.9.2(b, c) respectively show the Optimization Assistant finding the minimum of zero at 4,0, and the maximum of 16/3 at 4/3,2.
Figure 4.9.2(b) Constrained minimum
Figure 4.9.2(c) Constrained maximum
Figures 4.9.2(d, e) are generated with the Plot option in the Optimization Assistant. In Figure 4.9.2(c), the constraint line is lifted to the surface, whereas in Figure 4.9.2(e), the constraint is represented as a cutting plane (gray) intersecting the surface generated by the objective function.
Figure 4.9.2(d) Constraint lifted to surface
Figure 4.9.2(e) Constraint as cutting plane
Maple Solution - Coded
Install the Student MultivariateCalculus package.
withStudent:-MultivariateCalculus:
Define f, the objective function.
f≔x y2:
Define g, the constraint function.
g≔3 x+4 y−12:
Implement the Lagrange multiplier method
Invoke the LagrangeMultipliers command from the Student MultivariateCalculus package.
LagrangeMultipliersf,g,x,y
4,0,43,2
Add the "detailed" option to the LagrangeMultipliers command.
LagrangeMultipliersf,g,x,y,output=detailed
x=4,y=0,λ1=0,x⁢y2=0,x=43,y=2,λ1=43,x⁢y2=163
Implement the Lagrange multiplier method from first principles
Define F.
F≔f− λ g:
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 solutions of the equations in ∇f−λ ∇g=0.
solveEquateGradientF,x,y,λ,0,0,0,x,y,λ
x=4,y=0,λ=0,x=43,y=2,λ=43
<< Previous Example 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
Download Help Document