Maximizing volume of a box Say you have a sheet of gold with dimensions $5$ units by $8$ units, and you want to cut out a square with side-length $z$ from each corner of the box so that you can subsequently fold the sides up in order to construct an open-topped box. What is the optimal value of $z$ if we want to maximize the volume of the resulting box?

Honestly I think the problem I am having is visualizing this. I've tried drawing pictures, and I still don't get it. I think this is like a calculus optimization question, so I tried setting up equations.
Volume = $40 \cdot z$. 
But I don't know how to come up with the constraint function. Can someone please help?
 A: A picture of what is left when you cut a square of size $z$ from each corner of the sheet is below with $z=1$.  The height will be $z$, but the bottom will be smaller than $5 \times 8$.  Once you figure out the area of the bottom, the volume will be a cubic in $z$.  Differentiate and set to zero....

A: 
$V = (8 - 2 z) (5 - 2 z) z$

$\frac{\partial V}{\partial z} = 12 z^2 -52 z + 40$
Set to $0$ to find $z = 1$ (or $10/3$ can be rejected)

A: Hint, maybe this drawing helps:

$$V=Z*(W-2Z)(H-2Z)$$
Given $W=5,H=8$
$$V=Z*(5-2Z)(8-2Z)$$
So now we need to maximize:
$$V=Z*(5-2Z)(8-2Z)$$
Subject to:
$$(5-2Z)(8-2Z)=40$$
V has 1 or more critical point(s) when: $$\frac{dV}{dZ}=0$$
That is:
$$\frac{d}{dZ}\left(Z\left(5-2Z\right)\left(8-2Z\right)\right)=12Z^2-52Z+40=0$$
$$Z=0, Z=\frac{10}{3}, Z=1$$
When $Z=0$, we don't get a box. We get a square. Reject this value.
When $Z=10/3$, we get $W=5-2Z$ negative, so its no good. 
When $Z=1$ we use the 2nd derivative test to identify the whether $Z=1$ is a min. or max. for $V$:
$$\frac{d^2}{dZ^2}\left(Z\left(5-2Z\right)\left(8-2Z\right)\right)=24Z-52$$
At $Z=1$ the above expression is negative. Hence $V$ has a local maximum at $Z=1$.
The volume becomes: $$V=5 * 8 * 1 \hspace{.4cm} unit^{3}$$
A: It is convenient to work with symbols. 
Let the length and width be denoted by $L,W.$
The Volume
$$V= x(L-2x)(W-2 x)$$
For convenience let $ 2x = u \rightarrow 2V= u (u-L)(u-W)$
Differentiate w.r.t. $u$ and simplify
$$3u^2-2u(L+W)+LW=0$$
Solve the quadratic equation
$$ u=2x= \frac{ (L+W)\mp \sqrt{L^2+W^2-LW}}{2} $$
Now insert the given values $ L=8, W=5 $
$$ 2x= (10,3), \,x = 1.5 $$
First solution discarded when finding remaining length/width because we cannot subtract 10 from 8 to result in a positive solution.
Remaining length and width are
$$ (8- 2*1.5, 5-2*1.5)= ( 5, 2) $$
The corners are cut or folded and the  3D box has dimensions $(L,W,H)$
$$ (5,2,1.5)$$
and open topped box Volume $LWH= 15$ cubic units.

It remains to verify by second differentiation in calculus procedure maxima/minima that this is in fact a maximum.
A: Think of it like the red cross symbol. It fits snuggly inside of a square, but the missing squares in the four corners are the ones with side length $z$. Then if you fold the "arms" of the symbol up, it creates a rectangular prism, with height $z$, and base lengths $s-2z$, where $s$ is the sidelength of the original square we cut up. This has a volume of 
$$V = z(s-2z)^2$$
Could you come up for a formula where the original shape we cut from was a rectangle instead of a square?
