Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
|
Example 4.9.6
|
|
Find the point on the curve that is closest to the point .
|
|
|
|
Solution
|
|
|
Mathematical Solution
|
|
•
|
The distance from the point to the graph of is given by , after solving the constraint for .
|
•
|
The objective function will be taken as , the square of the distance from the point to the constraint curve defined by .
|
•
|
The vertical line (i.e., the -axis) is a vertical asymptote for the constraint curve. Maple will find the shortest distance from 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 in black, and the graph of , in red.
|
•
|
The point where the red curve is tangent to a circle minimizes at , so .
|
|
•
|
The slider in Figure 4.9.6(b) controls the value of the -coordinate so that under the slider, the companion value of appears.
|
•
|
The green line-segment connects to the selected point on the constraint curve.
|
|
>
|
use plots in
module()
local p1,p2,p3;
p1:=contourplot((x-4)^2+(y-5)^2,x=2..6,y=3..7,color=black,contours=[.5,0.8780294598,1.5,2,3,4]);
p2:=plot(4+1/x^2,x=2..6,color=red);
p3:=display(p1,p2,scaling=constrained);
print(p3);
end module:
end use:
|
|
Figure 4.9.6(a) Level curves of and
|
|
|
|
=
|
Figure 4.9.6(b) Slider-controlled and
|
|
|
|
|
|
The Lagrange multiplier method finds extrema by determining points of tangency between the constraint curve and the level curves of the objective function by finding points where the gradients and are collinear. This is done by solving the equations and for . The resulting equations are
An exact solution of these equations is not possible, so numeric algorithms give the two solutions
, with , , and
and
, with , , and
|
|
Maple Solution - Interactive
|
|
Initialize
|
•
|
Tools≻Load Package: Student Multivariate Calculus
|
|
Loading Student:-MultivariateCalculus
|
•
|
Context Panel: Assign Name
|
|
|
•
|
Context Panel: Assign Name
|
|
|
•
|
Apply the LagrangeMultipliers command in the Student MultivariateCalculus package, captured in the
task template. See Table 4.9.6(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.6(a) The Lagrange Multiplier Method task template
|
|
|
Two local minima have been found, one on the branch of 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 , so is also the global minimum, occurring at approximately .
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 .
|
•
|
Figure 4.9.6(b) shows the Optimization Assistant finding the minimum of at .
|
|
|
Figure 4.9.6(c) Constrained maximum
|
|
|
|
|
|
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≻Numerically Solve
|
|
|
|
|
|
|
Maple Solution - Coded
|
|
Initialize
|
•
|
Install the Student MultivariateCalculus package.
|
|
|
•
|
Define , the objective function.
|
|
|
•
|
Define , 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
|
|
|
•
|
Use the Gradient command to obtain .
|
•
|
Use the Equate command to equate each component of to zero.
|
•
|
Use the fsolve command to obtain a numeric solution of the equations in .
|
|
|
|
|
•
|
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., 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
|