Multivariable CalculusOptimization4 of 6
Optimization · 4

Applied Optimization

We know how to find the high and low points of a two-variable function f(x,y)\goal{f(x, y)}. Now we want to maximize or minimize real-world quantities like distance, area, or volume that start with three variables tied together by a constraint equation.

Eliminating a Variable with a Constraint
xx
yy
zz
z=f(x,y)z = \htmlClass{lc-blue}{f(x, y)}
fx=0,fy=0\htmlClass{lc-pink}{f_x} = 0, \quad \htmlClass{lc-pink}{f_y} = 0
1

Closest Point on a Plane to the Origin

We want to find the point (x,y,z)(x, y, z) on the tilted plane z=6−2x−yz = 6 - 2x - y that is as close as possible to the origin (0,0,0)(0, 0, 0).

Closest Point on a Plane to the Origin
xx
yy
zz
(x,y,z)(x, y, z)
z=6−2x−yz = 6 - 2x - y
(0,0,0)(0, 0, 0)
d\htmlClass{lc-blue}{d}
Text solution
Eliminate zz in the squared distanceSince minimizing the distance d=x2+y2+z2\goal{d = \sqrt{x^2 + y^2 + z^2}} happens at the exact same point as minimizing its square, we drop the square root and use the plane equation z=6−2x−yz = 6 - 2x - y to replace zz so only xx and yy remain.
S=x2+y2+z2S(x,y)=x2+y2+(6−2x−y)2\displaystyle \begin{aligned} \goal{S} &= \goal{x^2 + y^2 + z^2} \\ \goal{S(x, y)} &= x^2 + y^2 + (6 - 2x - y)^2 \end{aligned}
Set both partial derivatives to zeroWe take the derivatives with respect to xx and yy using the chain rule on (6−2x−y)2(6 - 2x - y)^2, then set both slopes to zero to find where the surface is flat in both directions.
Sx=2x+2(6−2x−y)(−2)=10x+4y−24=0  ⟹  5x+2y=12Sy=2y+2(6−2x−y)(−1)=4x+4y−12=0  ⟹  2x+2y=6\displaystyle \begin{aligned} \slope{S_x} &= 2x + 2(6 - 2x - y)(-2) \\ &= 10x + 4y - 24 = 0 \\ &\implies 5x + 2y = 12 \\[6pt] \slope{S_y} &= 2y + 2(6 - 2x - y)(-1) \\ &= 4x + 4y - 12 = 0 \\ &\implies 2x + 2y = 6 \end{aligned}
Solve for the critical pointSubtracting 2x+2y=62x + 2y = 6 from 5x+2y=125x + 2y = 12 cancels 2y2y right away, giving the single critical point (2,1)(2, 1) in the xyxy-plane.
(5x+2y)−(2x+2y)=12−63x=6  ⟹  x=22(2)+2y=6  ⟹  y=1\displaystyle \begin{aligned} & (5x + 2y) - (2x + 2y) = 12 - 6 \\ & 3x = 6 \implies x = 2 \\ & 2(2) + 2y = 6 \implies y = 1 \end{aligned}
Confirm the absolute minimum with the Second Derivative TestWe check the discriminant D=SxxSyy−(Sxy)2\bend{D} = \bend{S_{xx}}\bend{S_{yy}} - \bend{(S_{xy})^2} to verify that the surface curves upward rather than forming a saddle or maximum.
Sxx=10,Syy=4,Sxy=4D=(10)(4)−42=24>0andSxx=10>0\displaystyle \begin{aligned} \bend{S_{xx}} &= 10, \quad \bend{S_{yy}} = 4, \quad \bend{S_{xy}} = 4 \\ \bend{D} &= (10)(4) - 4^2 = 24 > 0 \\ & \text{and} \quad \bend{S_{xx}} = 10 > 0 \end{aligned}
Find the height zz on the planeBecause the second derivatives are constant, the surface curves upward everywhere and grows toward infinity in every direction, so (2,1)(2, 1) gives the absolute minimum. Plugging (2,1)(2, 1) back into z=6−2x−yz = 6 - 2x - y gives the closest point on the plane, (2,1,1)(2, 1, 1).
z=6−2(2)−1=1  ⟹  (x,y,z)=(2,1,1)\displaystyle \begin{aligned} z &= 6 - 2(2) - 1 = 1 \\ &\implies (x, y, z) = (2, 1, 1) \end{aligned}

For every choice of (x,y)(x, y), the plane fixes the height z=6−2x−yz = 6 - 2x - y, and squaring the distance stretches the surface vertically into a smooth bowl without moving the lowest spot from (2,1)(2, 1).

Every spot on the floor fixes the height on the plane, and squaring the distance from the origin stretches the surface into a steeper bowl without moving its lowest spot.
2

Minimizing the Surface Area of an Open-Top Box

Now let's take a design problem where the constraint multiplies the variables together and the dimensions must be positive. We want to find the width xx, length yy, and height zz of an open-top rectangular box that holds 32 ft332\text{ ft}^3 of volume while using the least possible area of cardboard.

xyxy
xzxz
xzxz
yzyz
yzyz
xx
zz
yy
Minimizing the Surface Area of an Open-Top Box
32 ft332 \text{ ft}^3
xx
yy
zz
Text solution
Eliminate zz using the volume constraintAdding the areas of the bottom panel xyxy and the four side walls 2xz2xz and 2yz2yz gives the total surface area. Solving the volume equation xyz=32xyz = 32 for zz turns the area into a function of xx and yy for x>0,y>0x > 0, y > 0.
A=xy+2xz+2yz,z=32xyA(x,y)=xy+2x(32xy)+2y(32xy)=xy+64y+64x\displaystyle \begin{aligned} \goal{A} &= \goal{xy + 2xz + 2yz}, \\ z &= \frac{32}{xy} \\[6pt] \goal{A(x, y)} &= xy + 2x\left(\frac{32}{xy}\right) \\ &\quad + 2y\left(\frac{32}{xy}\right) \\ &= xy + \frac{64}{y} + \frac{64}{x} \end{aligned}
Set both partial derivatives to zero and clear fractionsWriting 64x=64x−1\frac{64}{x} = 64x^{-1} and 64y=64y−1\frac{64}{y} = 64y^{-1} lets us differentiate with the power rule, and multiplying through by x2x^2 and y2y^2 clears the denominators.
Ax=y−64x2=0  ⟹  x2y=64Ay=x−64y2=0  ⟹  xy2=64\displaystyle \begin{aligned} \slope{A_x} &= y - \frac{64}{x^2} = 0 \implies x^2y = 64 \\ \slope{A_y} &= x - \frac{64}{y^2} = 0 \implies xy^2 = 64 \end{aligned}
Use symmetry to solve for the critical pointSince x2yx^2y and xy2xy^2 both equal 6464 and the box dimensions satisfy x>0x > 0 and y>0y > 0, we can set them equal and divide by xyxy to see that the base must be a square.
x2y=xy2  ⟹  x=yx3=64  ⟹  x=4,y=4\displaystyle \begin{aligned} x^2y &= xy^2 \implies x = y \\ x^3 &= 64 \implies x = 4, \quad y = 4 \end{aligned}
Confirm the absolute minimum with the Second Derivative TestEvaluating the second derivatives at (4,4)(4, 4) shows the surface curves upward at its single critical point, and since A(x,y)→∞\goal{A(x, y)} \to \infty whenever xx or yy approaches 0+0^+ or ∞\infty, this local minimum is the absolute minimum for x>0,y>0x > 0, y > 0.
Axx=128x3,Ayy=128y3,Axy=1Axx(4,4)=2,Ayy(4,4)=2,Axy(4,4)=1D=(2)(2)−12=3>0andAxx(4,4)=2>0\displaystyle \begin{aligned} \bend{A_{xx}} &= \frac{128}{x^3}, \quad \bend{A_{yy}} = \frac{128}{y^3}, \\ \bend{A_{xy}} &= 1 \\[6pt] \bend{A_{xx}(4, 4)} &= 2, \quad \bend{A_{yy}(4, 4)} = 2, \\ \bend{A_{xy}(4, 4)} &= 1 \\[6pt] \bend{D} &= (2)(2) - 1^2 = 3 > 0 \\ & \text{and} \quad \bend{A_{xx}(4, 4)} = 2 > 0 \end{aligned}
Find the height zz from the constraintSubstituting x=4x = 4 and y=4y = 4 back into z=32xyz = \frac{32}{xy} gives a height of 2 ft2\text{ ft}, so the box that uses the least cardboard has dimensions 4 ft×4 ft×2 ft4\text{ ft} \times 4\text{ ft} \times 2\text{ ft}.
z\displaystyle z =324⋅4\displaystyle = \frac{32}{4 \cdot 4} =2\displaystyle = 2

With the volume locked at 32 ft332\text{ ft}^3, stretching the base wide makes the bottom panel xyxy grow toward infinity, while squeezing either side toward zero forces tall walls 64x\frac{64}{x} and 64y\frac{64}{y} whose areas also grow toward infinity, leaving a single lowest spot on the area surface at (4,4)(4, 4).

With the volume fixed, wide trays and tall towers both waste cardboard, leaving one sweet spot in between that uses the least.
3

When Substitution Works and What Comes Next

Both problems worked the same way because we could solve for zz cleanly, which raises the question of what we do when the constraint equation mixes xx, yy, and zz together so we can't solve for one variable.

When Substitution Works and What Comes Next
xx
yy
zz
z=6−2x−yz = 6 - 2x - y
xyz=32xyz = 32

Summary

When an optimization problem gives you three variables tied together by a constraint equation, use the constraint to eliminate one variable first:

Linear constraint

(like z=6−2x−yz = 6 - 2x - y): substitute 6−2x−y6 - 2x - y for zz directly into the formula you are optimizing.

Product constraint

(like xyz=32xyz = 32 on x>0,y>0x > 0, y > 0): divide to get z=32xyz = \frac{32}{xy}, substitute, and cancel before taking derivatives.

Distance from the origin

minimize the squared distance S=x2+y2+z2\goal{S = x^2 + y^2 + z^2} instead of d=x2+y2+z2\goal{d = \sqrt{x^2 + y^2 + z^2}} so you don't differentiate a square root; if a problem asks for the minimum distance itself, take S\sqrt{\goal{S}} at the very end.

Confirming the absolute minimum or maximum

solve fx=0\slope{f_x} = 0 and fy=0\slope{f_y} = 0, then check D=fxxfyy−(fxy)2>0\bend{D} = \bend{f_{xx}}\bend{f_{yy}} - \bend{(f_{xy})^2} > 0 (fxx>0\bend{f_{xx}} > 0 for a minimum, fxx<0\bend{f_{xx}} < 0 for a maximum) together with what the function does at the edges of the domain.

When not to solve for zz

if the formula you are optimizing already has the exact term from the constraint (such as substituting z2=xy+4z^2 = xy + 4 directly into S=x2+y2+z2\goal{S = x^2 + y^2 + z^2}), replace z2z^2 in one piece without taking a square root; if the constraint mixes xx, yy, and zz so you cannot solve for a variable at all, use Lagrange Multipliers instead.

4

Practice

1

Find the point on the plane z=14−2x−3yz = 14 - 2x - 3y that is closest to the origin (0,0,0)(0, 0, 0), and find the minimum distance.

Drop the square root to minimize S=x2+y2+z2\goal{S = x^2 + y^2 + z^2}, and use the plane equation to replace zz.

Substitute z=14−2x−3yz = 14 - 2x - 3y into the squared distance S=x2+y2+z2\goal{S = x^2 + y^2 + z^2}:
S(x,y)\displaystyle \goal{S(x, y)} =x2+y2+(14−2x−3y)2\displaystyle = x^2 + y^2 + (14 - 2x - 3y)^2
Set both partial derivatives equal to zero (remembering to multiply by the inside derivatives −2-2 and −3-3 from the chain rule):
Sx=2x+2(14−2x−3y)(−2)=10x+12y−56=0  ⟹  5x+6y=28Sy=2y+2(14−2x−3y)(−3)=12x+20y−84=0  ⟹  3x+5y=21\displaystyle \begin{aligned} \slope{S_x} &= 2x + 2(14 - 2x - 3y)(-2) \\ &= 10x + 12y - 56 = 0 \\ &\implies 5x + 6y = 28 \\[6pt] \slope{S_y} &= 2y + 2(14 - 2x - 3y)(-3) \\ &= 12x + 20y - 84 = 0 \\ &\implies 3x + 5y = 21 \end{aligned}
Solve the system of equations for (x,y)(x, y):
5(5x+6y)−6(3x+5y)=5(28)−6(21)7x=14  ⟹  x=23(2)+5y=21  ⟹  y=3\displaystyle \begin{aligned} & 5(5x + 6y) - 6(3x + 5y) \\ & \qquad = 5(28) - 6(21) \\ & 7x = 14 \implies x = 2 \\ & 3(2) + 5y = 21 \implies y = 3 \end{aligned}
Check the Second Derivative Test:
Sxx=10,Syy=20,Sxy=12D=(10)(20)−122=56>0andSxx=10>0\displaystyle \begin{aligned} \bend{S_{xx}} &= 10, \quad \bend{S_{yy}} = 20, \quad \bend{S_{xy}} = 12 \\ \bend{D} &= (10)(20) - 12^2 = 56 > 0 \\ & \text{and} \quad \bend{S_{xx}} = 10 > 0 \end{aligned}
Since D>0\bend{D} > 0 and Sxx>0\bend{S_{xx}} > 0 everywhere, (2,3)(2, 3) gives the absolute minimum.
Substitute (2,3)(2, 3) back into z=14−2x−3yz = 14 - 2x - 3y to find zz, then take the square root of S\goal{S} for the distance (stopping at S=14\goal{S} = 14 without taking the square root is the most common mistake, which gives the squared distance 1414 instead of the distance 14\sqrt{14}):
z=14−2(2)−3(3)=1  ⟹  closest point (2,3,1)d=22+32+12=14\displaystyle \begin{aligned} z &= 14 - 2(2) - 3(3) = 1 \\ &\implies \text{closest point } (2, 3, 1) \\ \goal{d} &= \sqrt{2^2 + 3^2 + 1^2} = \sqrt{14} \end{aligned}
2

Find all points on the curved surface z2=xy+4z^2 = xy + 4 that are closest to the origin (0,0,0)(0, 0, 0).

Look at how zz appears in S=x2+y2+z2\goal{S = x^2 + y^2 + z^2} before trying to take a square root of z2=xy+4z^2 = xy + 4.

Substitute z2=xy+4z^2 = xy + 4 directly into the squared distance S=x2+y2+z2\goal{S = x^2 + y^2 + z^2}:
S(x,y)\displaystyle \goal{S(x, y)} =x2+y2+xy+4\displaystyle = x^2 + y^2 + xy + 4
Set both partial derivatives to zero and solve for the critical point:
Sx=2x+y=0  ⟹  y=−2xSy=x+2y=0  ⟹  x+2(−2x)=−3x=0(x,y)=(0,0)\displaystyle \begin{aligned} \slope{S_x} &= 2x + y = 0 \implies y = -2x \\ \slope{S_y} &= x + 2y = 0 \\ &\implies x + 2(-2x) = -3x = 0 \\ (x, y) &= (0, 0) \end{aligned}
Verify the absolute minimum with the Second Derivative Test:
Sxx=2,Syy=2,Sxy=1D=(2)(2)−12=3>0andSxx=2>0\displaystyle \begin{aligned} \bend{S_{xx}} &= 2, \quad \bend{S_{yy}} = 2, \quad \bend{S_{xy}} = 1 \\ \bend{D} &= (2)(2) - 1^2 = 3 > 0 \\ & \text{and} \quad \bend{S_{xx}} = 2 > 0 \end{aligned}
Substitute (x,y)=(0,0)(x, y) = (0, 0) back into z2=xy+4z^2 = xy + 4 to find zz (taking only the positive root z=2z = 2 and forgetting z=−2z = -2 is the likeliest mistake here, which misses the second point (0,0,−2)(0, 0, -2)):
z2=(0)(0)+4=4  ⟹  z=±2(x,y,z)=(0,0,2) and (0,0,−2)\displaystyle \begin{aligned} z^2 &= (0)(0) + 4 = 4 \\ &\implies z = \pm 2 \\ (x, y, z) &= (0, 0, 2) \text{ and } (0, 0, -2) \end{aligned}
3

An open-top rectangular box must hold a volume of 24 ft324\text{ ft}^3. Material for the bottom costs $4 per ft2\$4\text{ per ft}^2, material for the front and back walls (width xx, height zz) costs $4 per ft2\$4\text{ per ft}^2, and material for the left and right walls (length yy, height zz) costs $3 per ft2\$3\text{ per ft}^2. Find the dimensions (x,y,z)(x, y, z) that minimize the total cost of the box, and find the minimum cost.

Multiply each panel's area by its price per square foot to write the total cost C\goal{C}, then use the volume xyz=24xyz = 24 to replace zz.

Multiply the bottom area xyxy by $4\$4, the two front/back walls 2xz2xz by $4\$4, and the two left/right walls 2yz2yz by $3\$3, then substitute z=24xyz = \frac{24}{xy} for x>0,y>0x > 0, y > 0 (watch which variable cancels in each fraction: leaving xx under 192192 and yy under 144144 swaps the width and length to give (4,3,2)(4, 3, 2) instead of (3,4,2)(3, 4, 2)):
C=4xy+4(2xz)+3(2yz)=4xy+8xz+6yzC(x,y)=4xy+8x(24xy)+6y(24xy)=4xy+192y+144x\displaystyle \begin{aligned} \goal{C} &= \goal{4xy + 4(2xz) + 3(2yz)} \\ &= \goal{4xy + 8xz + 6yz} \\[6pt] \goal{C(x, y)} &= 4xy + 8x\left(\frac{24}{xy}\right) \\ &\quad + 6y\left(\frac{24}{xy}\right) \\ &= 4xy + \frac{192}{y} + \frac{144}{x} \end{aligned}
Set both partial derivatives to zero and clear the fractions:
Cx=4y−144x2=0  ⟹  x2y=36Cy=4x−192y2=0  ⟹  xy2=48\displaystyle \begin{aligned} \slope{C_x} &= 4y - \frac{144}{x^2} = 0 \implies x^2y = 36 \\ \slope{C_y} &= 4x - \frac{192}{y^2} = 0 \implies xy^2 = 48 \end{aligned}
Divide xy2=48xy^2 = 48 by x2y=36x^2y = 36 to write yy in terms of xx, then solve:
xy2x2y=4836  ⟹  yx=43  ⟹  y=43xx2(43x)=36  ⟹  x3=27  ⟹  x=3 fty=43(3)=4 ft,z=243⋅4=2 ft\displaystyle \begin{aligned} \frac{xy^2}{x^2y} &= \frac{48}{36} \implies \frac{y}{x} = \frac{4}{3} \\ &\implies y = \frac{4}{3}x \\ x^2\left(\frac{4}{3}x\right) &= 36 \implies x^3 = 27 \\ &\implies x = 3\text{ ft} \\ y &= \frac{4}{3}(3) = 4\text{ ft}, \\ z &= \frac{24}{3 \cdot 4} = 2\text{ ft} \end{aligned}
Check the Second Derivative Test at (3,4)(3, 4):
Cxx(3,4)=28833=323>0,Cyy(3,4)=38443=6,Cxy(3,4)=4D=(323)(6)−42=64−16=48>0\displaystyle \begin{aligned} \bend{C_{xx}(3, 4)} &= \frac{288}{3^3} = \frac{32}{3} > 0, \\ \bend{C_{yy}(3, 4)} &= \frac{384}{4^3} = 6, \\ \bend{C_{xy}(3, 4)} &= 4 \\[6pt] \bend{D} &= \left(\frac{32}{3}\right)(6) - 4^2 \\ &= 64 - 16 = 48 > 0 \end{aligned}
Evaluate C(3,4)\goal{C(3, 4)} to find the minimum cost for the 3 ft×4 ft×2 ft3\text{ ft} \times 4\text{ ft} \times 2\text{ ft} box:
C(3,4)\displaystyle \goal{C(3, 4)} =4(3)(4)+1924+1443\displaystyle = 4(3)(4) + \frac{192}{4} + \frac{144}{3} =48+48+48\displaystyle = 48 + 48 + 48 =$144\displaystyle = \$144
4

A rectangular box sits in the first octant with three of its faces on the coordinate planes and its opposite vertex (x,y,z)(x, y, z) on the tilted plane z=18−3x−2yz = 18 - 3x - 2y. Find the dimensions (x,y,z)(x, y, z) that maximize the volume of the box, and find the maximum volume.

The box runs from the origin to (x,y,z)(x, y, z), so its volume is V=xyz\goal{V = xyz}; substitute z=18−3x−2yz = 18 - 3x - 2y rather than dividing.

Substitute z=18−3x−2yz = 18 - 3x - 2y into V=xyz\goal{V = xyz} on the open domain x>0,y>0,3x+2y<18x > 0, y > 0, 3x + 2y < 18 (where V=0\goal{V} = 0 on all boundaries):
V(x,y)\displaystyle \goal{V(x, y)} =xy(18−3x−2y)\displaystyle = xy(18 - 3x - 2y) =18xy−3x2y−2xy2\displaystyle = 18xy - 3x^2y - 2xy^2
Set both partial derivatives to zero and factor out y>0y > 0 and x>0x > 0 (setting x=0x = 0 or y=0y = 0 collapses the box onto the boundary with volume 00):
Vx=18y−6xy−2y2=y(18−6x−2y)=0  ⟹  3x+y=9Vy=18x−3x2−4xy=x(18−3x−4y)=0  ⟹  3x+4y=18\displaystyle \begin{aligned} \slope{V_x} &= 18y - 6xy - 2y^2 \\ &= y(18 - 6x - 2y) = 0 \\ &\implies 3x + y = 9 \\[6pt] \slope{V_y} &= 18x - 3x^2 - 4xy \\ &= x(18 - 3x - 4y) = 0 \\ &\implies 3x + 4y = 18 \end{aligned}
Subtract 3x+y=93x + y = 9 from 3x+4y=183x + 4y = 18 to solve for (x,y)(x, y):
(3x+4y)−(3x+y)=18−93y=9  ⟹  y=33x+3=9  ⟹  x=2\displaystyle \begin{aligned} (3x + 4y) - (3x + y) &= 18 - 9 \\ 3y &= 9 \implies y = 3 \\ 3x + 3 &= 9 \implies x = 2 \end{aligned}
Confirm the absolute maximum at (2,3)(2, 3) with the Second Derivative Test:
Vxx=−6y=−18<0,Vyy=−4x=−8,Vxy=18−6x−4y=−6D=(−18)(−8)−(−6)2=144−36=108>0\displaystyle \begin{aligned} \bend{V_{xx}} &= -6y = -18 < 0, \\ \bend{V_{yy}} &= -4x = -8, \\ \bend{V_{xy}} &= 18 - 6x - 4y = -6 \\[6pt] \bend{D} &= (-18)(-8) - (-6)^2 \\ &= 144 - 36 = 108 > 0 \end{aligned}
Substitute (x,y)=(2,3)(x, y) = (2, 3) into z=18−3x−2yz = 18 - 3x - 2y to find zz and multiply for the volume (swapping x=2x = 2 and y=3y = 3 in z=18−3x−2yz = 18 - 3x - 2y gives z=5z = 5 and a wrong volume of 3030):
z=18−3(2)−2(3)=6  ⟹  (x,y,z)=(2,3,6)V=(2)(3)(6)=36\displaystyle \begin{aligned} z &= 18 - 3(2) - 2(3) = 6 \\ &\implies (x, y, z) = (2, 3, 6) \\ \goal{V} &= (2)(3)(6) = 36 \end{aligned}