Chapter 4: Partial Differentiation
Section 4.9: Constrained Optimization
Example 4.9.3
Find the (shortest) distance from the origin to the plane 3⁢x+2 y−4 z=7.
Solution
Mathematical Solution
The objective function should be x2+y2+z2, but taking fx,y,z=x2+y2+z2 as the objective function leads to much simpler algebra.
The constraint is
gx,y,z≡3⁢x+2 y−4 z− 7=0
In Figure 4.9.3(a), the sphere of radius 7/29, the level surface f=49/29, is tangent to the constraint plane g=0, drawn in red.
To implement the Lagrange multiplier technique, solve ∇f=λ ∇g, and the constraint g=0, for the four unknowns x,y,z,λ.
use plots in module() local p1,p2,p3; p1:=plot3d([7/sqrt(29),t,s],t=0..2*Pi,s=0..Pi,coords=spherical); p2:=plot3d(-7/4+(3/4)*x+(1/2)*y,x=-1..2,y=-1.5..2,color=red); p3:=display(p1,p2,scaling=constrained,labels=[x,y,z],axes=frame,orientation=[-70,75,0],tickmarks=[4,5,5],view=-2..1.5); print(p3); end module: end use:
Figure 4.9.3(a) Level surface of f and g=0
The resulting equations are
−3⁢x−2⁢y+4⁢z+7,−3⁢λ+2⁢x,−2⁢λ+2⁢y,4⁢λ+2⁢z
with solution P:x,y,z=2129,1429,−2829 when λ=1429, so that fP=4929.
The minimum distance from the origin to the plane is therefore 7/29.
Maple Solution - Interactive
Initialize
Tools≻Load Package: Student Multivariate Calculus
Loading Student:-MultivariateCalculus
Context Panel: Assign Name
f=x2+y2+z2→assign
g=3 x+2 y−4 z−7→assign
Apply the LagrangeMultipliers command in the Student MultivariateCalculus package, captured in the task template. See Table 4.9.3(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.3(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+2⁢y−4⁢z−7⁢λ+x2+y2+z2
→gradient
→to list
−3⁢x−2⁢y+4⁢z+7,−3⁢λ+2⁢x,−2⁢λ+2⁢y,4⁢λ+2⁢z
→solve
λ=1429,x=2129,y=1429,z=−2829
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.
Figure 4.9.3(b) shows the Optimization Assistant finding the minimum of 49/29≐1.69 at
2129,1429,−2829
Figure 4.9.3(b) Constrained maximum
Solution via the Lines & Planes tools in the Student MultivariateCalculus package
Write g, the name of the constraint function. Context Panel: Evaluate and Display Inline
Context Panel: Student Multivariate Calculus≻Lines & Planes≻Plane
Context Panel: Assign to a Name≻L
g = 3⁢x+2⁢y−4⁢z−7→make plane<< Plane 1 >>→assign to a nameL
Write a sequence of the origin (as a point) and L, the name of the plane. Context Panel: Evaluate and Display Inline
Context Panel: Student Multivariate Calculus≻Lines & Planes≻Distance
0,0,0,L = 0,0,0,<< Plane 1 >>→distance729⁢29
Maple Solution - Coded
Install the Student MultivariateCalculus package.
withStudent:-MultivariateCalculus:
Define f, the objective function.
f≔x2+y2+z2:
Define g, the constraint function.
g≔3 x+2 y−4 z−7:
Implement the Lagrange multiplier method
Invoke the LagrangeMultipliers command from the Student MultivariateCalculus package.
LagrangeMultipliersf,g,x,y,z
Add the "detailed" option to the LagrangeMultipliers command.
LagrangeMultipliersf,g,x,y,z,output=detailed
x=2129,y=1429,z=−2829,λ1=1429,x2+y2+z2=4929
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,z,λ,0,0,0,0,x,y,z,λ
x=2129,y=1429,z=−2829,λ=1429
Define the plane with the Plane command and obtain the distance with the Distance command.
Distance0,0,0,Planeg = 729⁢29
<< 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