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?






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?