# Differentiate then solve or vice versa. Why is there a difference?

The other day I stumbled upon the following problem.

Start with a rectangular piece of card an integer number wide, by an integer number long, with one of those values being prime. Then cut four identical squares from each corner of the card. Fold up the four "flaps" to create an open topped box, where the corners have been cut in such a way to allow the maximum volume possible for the box. Once the box is made, it turns out that the base length is 4 times larger than the base width.

What are the dimensions of the original card?

I did solve the problem. But I still have a question. Let $L$ and $W$ be the length and width of the original paper and $x$ the length of the cut-off square. The volume of the box is a function $V(L, W, x)$.

$$V(L,W,x) = x(L-2x)(W-2x)\tag{1}$$

We also have that

$$L-2x = 4(W-2x)\tag{2}$$

I solved the problem by first finding the derivative of $V(L,W,x)$ with respect to $x$ and then making use of the second formula, finding a relationship between $W$ and $L$, and considering they're both whole and one of them is prime, I got the correct answers for $W$ and $L$ ($W = 3$, $L = 8$).

However, if I first substituted the second formula into $V(L,W,x)$ and then differentiate, I arrived at wrong results. I mean, if I first rewrite $V$ as

$$V(W,x) = 4x(W-2x)^2$$

Differentiate, find $x$ expressed with $W$, and substitute in $(2)$, I get wrong results. Why?

-
you use very strange notation – Adi Dani Nov 17 '12 at 14:28
@AdiDani: I'm new to this SE. I'll improve over time :) – Armen Tsirunyan Nov 17 '12 at 14:29
This is a good question. It would have been nice to explicitly show your results for each calculation so others don't have to reproduce the work. – Ross Millikan Nov 17 '12 at 16:02

## 1 Answer

The difference comes because in the first method, you are considering $L$ and $W$ to be fixed, then finding $x$ to maximize the volume. In the second, $L$ varies with $x$ to maintain the relationship $L-2x=4(W-2x)$ and $x$ is chosen to maximize the volume. At the optimum for this one, we have $x=\frac W6, L=3W$

-
Yeah, seems you're right! Thanks – Armen Tsirunyan Nov 17 '12 at 15:59