I was helping a friend plan a move where she wanted to transport her belongings across the country as cheaply as possible. It turns out that it is cheapest to take as many belongings along with you as possible on the plane flight over. The rate of $\$$25 and $\$$35 for the first and second 50 lb checked-in suitcases is cheaper than the USPS or any parcel service.

The interesting part is that the airline regulation is that the box you use must have the total of length plus width plus height be less than or equal to 60 inches. Under this odd constraint, we would like to transport the largest volume possible, so what are the optimal dimensions? Intuitively, the answer is fairly obvious that we want a cube that is 20 inches on a side. She asked why, but I didn't have a glib response at the time, so here is my derivation and answer.

The 2D solution is easier and illustrates how to solve the 3D problem, so I will do that first. We can phrase the problem to ask, if we have a rectangle of dimension $x$ by $y$, what $x$ and $y$ maximize the area $$a = xy$$ under the constraint $$x + y = L?$$

Rewriting the constraint as $y = L - x$, we can substitute $y$ into the area so that $a = x(L-x) = Lx - x^2$. The maximum area is where the derivative of area is equal to zero $$ \frac {da} {dx} = L - 2x = 0. $$ We now have two linear equations and two unknowns. From the derivative we get that $x = \frac L 2$. Substituting into the constraint, we further get that $y = \frac L 2$. $$ \therefore x = y = \frac L 2 $$

We will use the same approach in 3D. It's actually a bit surprising how well it works but we luck out a bit with the math. Unlike a quadratic equation, a cubic is not guaranteed a minimum or maximum, but this particular problem simplifies. The setup is similar in that we have a volume $$v = xyz$$ under the constraint $$x + y + z = L.$$

Rewriting the constraint $z = L - x - y$, and substituting into volume we get $v = xy(L-x-y) = Lxy - x^2y - xy^2$. Like in a 1D function, the maximum of a higher dimensional function, if it exists, is where the gradient is equal to zero. $$ \frac {\partial v}{\partial x} = Ly - 2xy - y^2 = 0 $$ $$ \frac {\partial v}{\partial y} = Lx - x^2 - 2xy = 0 $$

We are fortunate that $\frac {\partial v}{\partial x}$ can be divided by $y$ and that $\frac {\partial v}{\partial y}$ can be divided by $x$. Combined with our constraint, we have three linear equations and three unknows, which are easy to solve. Namely, $$L - 2x - y = 0$$ $$L - x - 2y = 0$$ $$z = L - x - y.$$

For completion's sake, the remaining steps could be: using the first equation $y = L - 2x$, substitute into the second to get $L - x - 2(L - 2x) = -L - 3x = 0 \rightarrow x = \frac L 3$. Substituting back into $y = L - 2x = L - 2(\frac L 3) = \frac L 3$. Finally, substitute $x$ and $y$ into the third equation $z = L - \frac L 3 - \frac L 3 = \frac L 3$. $$ \therefore x = y = z = \frac L 3 $$