This is not homework. I found a problem in a calculus book (Lial, Calculus with Applications, 11th Ed., p. 373) re maximizing the volume of a package for shipment. I believe I was able to solve it correctly by expressing the volume as a function of a single variable. Now, in order to get some practice with Lagrange multipliers (LM), I am trying to solve the same problem using LM. My answer using the LM is different from my first answer. I assume my mistake is when using the LM.
Here is the problem:
UPS has the following rule regarding package dimensions. The length can be no more than 108 in., and the length plus the girth (twice the sum of the width and the height) can be no more than 130 in. If the width of a package is 4 in. more than its height and it has the maximum length plus girth allowed, find the length that produces maximum volume.
My solution optimizing using a single variable:
The volume of the package (and the function we want to optimize) is $V=lwh$. We were told that $g=2(w+h)$ and that $l+g \le 130$. Therefore, $l+2(h+4+h) \le 130$ and therefore $l+4h+8 \le 130$. We were also told that the package has the maximum length plus girth allowed, so $l+4h+8 = 130$ and therefore $l = 130-4h+-8$ or $l=122-4h$. Finally, we were told that $w=h+4$. Therefore, volume can be expressed as a function of a single variable:
$V = (122-4h)(h+4)h$
$V = -4h^2 + 106h + 488$
Optimize by setting the derivative to zero:
$\frac{dV}{dh} = -8h + 106$
$h = 13.25$
Therefore, the dimensions are $l=69$, $w=17.25$ and $h=13.25$.
Edit: As pointed out by Ares, this answer is incorrect because I failed to multiply through by $h$. The volume equation to be optimized is actually $V = -4h^3 + 106h^2 + 488h$ and $h = 19.728$ (as found below using LM). Ugh! I went over this and over this ASSUMING that my error was in the LM version and not the single variable version!
My solution using the Lagrange Multiplier:
The volume function (substituting $h+4$ for $w$) is
$V = lwh$
$V = l(h+4)h$
$V = lh^2 + 4hl$
My constraint is:
$l+g = 130$
$l + 2(h+4+h) = 130$
$l + 4h = 122$
First, set up my function $F(l,h,\lambda)$:
$F(l,h,\lambda) = lh^2 + 4hl + \lambda(l + 4h - 122)$
Set partial derivatives equal to zero:
$\frac{\partial F}{\partial l} = h^2 + 4h + \lambda = 0$
$\frac{\partial F}{\partial h} = 2hl + 4l + 4\lambda = 0$
$\frac{\partial F}{\partial \lambda} = l + 4h - 122 = 0$
Solve the first two partials for $\lambda$ and set them equal to each other:
$-h^2 -4h = \frac{-2hl-4l}{4}$
Solve for $l$:
$l = \frac{4(-h^2-4h)}{-2h-4}$
Substitute into $\frac{\partial F}{\partial \lambda}$ and solve for $h$:
$\frac{\partial F}{\partial \lambda} = \frac{4(-h^2-4h)}{-2h-4} + 4h = 122$
$h = -2.06$ or $h = 19.728$.
Here my height is $19.728$ whereas above I found the height to be $13.25$.
Where did I go wrong?
Note that $l + 2(h+4+h) = 130$ is the same as $l+4h=122$.
The partial derivative wrt to $h$ should be $$\frac{\partial F}{\partial h}=2hl+4\color{red}l+4\lambda.$$
But I think that's a typo since you correctly found out that $$l=\frac{2(h^2+4h)}{h+2}$$
From your first solution we have $$V=(122-4h)(h+4)h=488 h + 106 h^{2} - 4 h^{3}$$ (You did not multiply by $h$ after expanding the brackets)
Thus $$\frac{dV}{dh}=488 + 212 h - 12 h^2=0$$ which has the same roots as the second solution, i.e $$h=\frac{53-\sqrt{4273}}{6}\approx-2.06136$$ $$\text{and}$$ $$h=\frac{53+\sqrt{4273}}{6}\approx19.72803$$