Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
Find the point on the curve x2y−4=1 that is closest to the point 4,5.
The distance from the point 4,5 to the graph of x2y−4=1 is given by d=x−42+1−1/x22, after solving the constraint for y=yx.
The objective function will be taken as fx,y=x−42+y−52, the square of the distance from the point 4,5 to the constraint curve defined by gx,y=x2y−4−1=0.
The vertical line x=0 (i.e., the y-axis) is a vertical asymptote for the constraint curve. Maple will find the shortest distance from 4,5 to either branch of this curve, but it suffices to find the minimum on the branch in the first quadrant.
Figure 4.9.6(a) shows level curves of f in black, and the graph of g=0, in red.
The point where the red curve is tangent to a circle minimizes f at 0.8780294598, so d≐0.937.
The slider in Figure 4.9.6(b) controls the value of the x-coordinate so that under the slider, the companion value of d appears.
The green line-segment connects 4,5 to the selected point on the constraint curve.
use plots in
Figure 4.9.6(a) Level curves of f and g=0
Figure 4.9.6(b) Slider-controlled x and dx
The Lagrange multiplier method finds extrema by determining points of tangency between the constraint curve and the level curves of the objective function f by finding points where the gradients ∇f and ∇g are collinear. This is done by solving the equations ∇f=λ ∇g and g=0 for x,y,λ. The resulting equations are
An exact solution of these equations is not possible, so numeric algorithms give the two solutions
x,y≐3.97,4.06, with λ≐−0.119, f≐0.878, and d≐0.937
x,y≐−0.725,5.90, with λ≐3.43, f≐23.14, and d≐4.81
Maple Solution - Interactive
Tools≻Load Package: Student Multivariate Calculus
Context Panel: Assign Name
Apply the LagrangeMultipliers command in the Student MultivariateCalculus package, captured in the
task template. See Table 4.9.6(a).
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.6(a) The Lagrange Multiplier Method task template
Two local minima have been found, one on the branch of g=0 in the first quadrant, and one on the branch in the second quadrant.
Clearly, the local minimum on the branch in the first quadrant is closer to 4,5, so d=0.8780294598≐0.937 is also the global minimum, occurring at approximately 3.97,4.06.
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.
Figure 4.9.6(b) shows the Optimization Assistant finding the minimum of 0.878 at 3.97,4.06.
Figure 4.9.6(c) Constrained maximum
Implement the Lagrange multiplier method via first principles
Write F and press the Enter key.
Context Panel: Student Multivariate Calculus≻Differentiate≻Gradient
Context Panel: Conversions≻To List
Context Panel: Solve≻Numerically Solve
Maple Solution - Coded
Install the Student MultivariateCalculus package.
Define f, the objective function.
Define g, the constraint function.
Implement the Lagrange multiplier method
Invoke the LagrangeMultipliers command from the Student MultivariateCalculus package.
Maple returns multiple solutions, some of which are complex; apply the remove and has commands to discard the complex solutions.
Add the "detailed" option to the LagrangeMultipliers command.
Use the print command and the tilde operator to display the solutions one above the other.
Implement the Lagrange multiplier method from first principles
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 fsolve command to obtain a numeric solution of the equations in ∇f−λ ∇g=0.
The fsolve command solves equations numerically. Here, it has found the solution in the first quadrant. To find the other real solution, the command requires additional information. For example, to find the solution in the second quadrant, use the following version of the command.
<< Previous Example Section 4.9
Next Example >>
© Maplesoft, a division of Waterloo Maple Inc., 2023. 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