Tin Box with Maximum Volume

vol[x_,a_,b_] := x(a-2x)(b-2x)

dervol[x0_,a_,b_] =
D[vol[x,a,b],x] /. x->x0;

crit[a_,b_] = x /. Solve[dervol[x,a,b] ==0, x][[1]];

markedtin[x_,a_,b_] :=
Graphics[{Thick,
Line[{{0,0},{a,0},{a,b},{0,b},{0,0}}],
Dashed,
Line[{
{{x,0},{x,x},{0,x}},
{{a-x,0},{a-x,x},{a,x}},
{{a-x,b},{a-x,b-x},{a,b-x}},
{{0,b-x},{x,b-x},{x,b}}}]},ImageSize->{200,200}]

tray3D[x_,a_,b_] :=
Graphics3D[
{
Polygon[{{x,x,0},{a-x,x,0},{a-x,b-x,0},{x,b-x,0},{x,x,0}}],(* bottom *)
{Thick,Polygon[{{x,x,0},{x,x,x},{x,b-x,x},{x,b-x,0}}],
Dashed, Line[{{x,b-x,0},{x,x,0}}]}, (* left *)
{Thick,Polygon[{{x,x,0},{x,x,x},{a-x,x,x},{a-x,x,0}}],
Dashed, Line[{{a-x,x,0}, {x,x,0}}]}, (* lower *)
{Thick, Polygon[{{a-x,x,0},{a-x,x,x},{a-x,b-x,x},{a-x,b-x,0}}],
Dashed, Line[{{a-x,b-x,0},{a-x,x,0}}]}, (* right *){Thick,Polygon[{{a-x,b-x,0},{a-x,b-x,x},{x,b-x,x},{x,b-x,0}}],
Dashed, Line[{{x,b-x,0},{a-x,b-x,0}}]} ,(* upper *)
{Thick,Line[{{{x,x,0},{x,0,0},{a-x,0,0},{a-x,x,0},{a,x,0},{a,b-x,0},{a-x,b-x,0},{a-x,b,0},{x,b,0},{x,b-x,0},{0,b-x,0},{0,x,0},{x,x,0}}}]} (* cut in 3D *)
},
PlotRange->{{0,a},{0,b},{0,Min[a/2,b/2]}},ImageSize->{200,200}]

volgraph[x0_,a_,b_] :=
Show[
{Plot[vol[x,a,b], {x,0, Max[a/2,b/2]},PlotStyle->Thick,
PlotLabel -> Row[{Style["V",Italic]," = ",vol[Style["x",Italic],a,b]}]],
Graphics[{Thick,
Line[{{x0,vol[x0,a,b]},{x0,0}}]}]},ImageSize->{180,150}]

dervolgraph[x0_,a_,b_] :=
Show[
{Plot[dervol[x,a,b], {x,0, Max[a/2,b/2]},PlotStyle->Thick,
PlotLabel-> Row[{Style["V",Italic]'," = ", Factor[dervol[Style["x",Italic],a,b]]}]],
Graphics[{Thick,
Line[{{x0,dervol[x0,a,b]},{x0,0}}]}]},ImageSize->{180,150}]

abrationalheights[i0_, j0_] :=
Module[{lst = {}},
For[i=1, i≤i0, i++,
For[j=1,j≤i && j≤ j0, j++,
If[IntegerQ[(i^2 - i j + j^2)^(1/2)]&&GCD[i,j]==1,lst = Join[lst, {{i,j,crit[i,j]}},{}]]]];
lst]

Manipulate[
If[rationalbox,a = q pick[[1]]; b = q pick[[2]], pick = {1,1,1/6}];
If[x0>Min[a/2,b/2], x0 =Min[.2a, .2b]];
Column[{
Text@TraditionalForm@Row[{"Tin box holds the most when ", x," = ",crit[a,b],"."}],
Grid[{
{markedtin[x0,a,b],tray3D[x0,a,b]},
{volgraph[x0,a,b],dervolgraph[x0,a,b]}
},Frame->All]
},ItemSize->{Automatic,4},Alignment->{Center, Center}],
{{a,3},1,100,1, Appearance->"Labeled",ControlPlacement->Top},
{{b,3},1,100, 1, Appearance->"Labeled",ControlPlacement->Top},
{{x0,Min[.2a,.2b],"Vary the height x"},0, Min[a/2,b/2],Appearance->"Labeled",ControlPlacement->Top},
{{rationalbox, False, 
StringJoin["Show integer dimensions a and b with rational height for biggest box:"]},{False, True},ControlPlacement->Top},
PaneSelector[{
True->Column[{
"Choose {a, b, optimal x}: ",
Control@{{pick,{1,1,1/6}, ""},abrationalheights[100,100]},
"Choose dimension multiplier: ",
Control@{{q, 1, ""}, Table[i, {i,10}]}}],
False->""
},
Dynamic[rationalbox]],
SaveDefinitions->True,ControlPlacement->Left,AutorunSequencing->{1,2,3,4}]

Problem: A piece of sheet tin three feet square is to be made into a rectangular box open at the top by cutting out equal squares from the corners and bending up the sides of the resulting piece parallel with the edges. Among all such boxes, to find the box of greatest volume.

This is the problem J. L. Walsh used in his 1947 Classroom Note in The American Mathematical Monthly to illustrate a rigorous analysis of maximum-minimum problems. A version of the problem appears in many calculus books and in Walsh’s 1962 booklet.

Let the tin sheet have dimensions a×b, with a≥b, and suppose a square with side x is cut from each corner. The volume of the resulting box is V(x)=x (a-2x) (b-2x), 0≤x≤(b/2).

Walsh’s rigorous analysis uses the extreme value theorem: A continuous function on a closed bounded interval has minimum and maximum values, and the critical point theorem: If a function has an extreme value at an interior point of an interval, its derivative at the point is either zero or does not exist. A proof of the extreme value theorem is best left to an advanced calculus course, but the critical point theorem depends only on the definition of derivative. An extreme value cannot occur where f'(x)>0 or f'(x)<0.

Since V(x) is continuous on 0≤x≤(b/2), it has a maximum value there, by the extreme value theorem.

Let the maximum occur at x=(Subscript[x, 0]).

Since V(0)=V((b/2))=0, and V(x)>0 when 0<x<b, we have 0<(Subscript[x, 0])<(b/2).

Since V'(x) exists for 0<x<(b/2), the critical point theorem implies V'((Subscript[x, 0]))=0.

Since V'(x)=-4 x (a+b)+a b+12 (x^2), V'((Subscript[x, 0]))=0 for 0<(Subscript[x, 0])<(b/2) when  (Subscript[x, 0]) = (1/6) (a+b-(Sqrt[(a^2)-a b+(b^2)])).

Therefore, with a=b=3, the box has maximum volume when (Subscript[x, 0])=(1/2).

Calculations are easiest and the biggest box is easiest to make when a and b are integers and (Subscript[x, 0]) is rational. These are the triples {a,b,(Subscript[x, 0])} with this property, where 1≤(Subscript[b, 0])≤(Subscript[a, 0])≤100 and a and b are relatively prime:

{1,1,(1/6)},{8,3,(2/3)},{8,5,1},{15,7,(3/2)},{15,8,(5/3)},{21,5,(7/6)},{21,16,3},{35,11,(5/2)},{35,24,(14/3)},{40,7,(5/3)},{40,33,6},{48,13,3},{48,35,(20/3)},{55,16,(11/3)},{55,39,(15/2)},{65,9,(13/6)},{65,56,10},{77,32,7},{77,45,(55/6)},{80,17,4},{80,63,(35/3)},{91,40,(26/3)},{91,51,(21/2)},{96,11,(8/3)},{96,85,15},{99,19,(9/2)},{99,80,(44/3)}.

This Demonstration lets you choose one of these triples and an integer multiplier. For example, choosing the first triple and multiplier 3 gives {3,3,(1/2)}, the case in the stated problem. It is somewhat surprising how shallow the biggest box is.

Former Harvard Professor Joseph Leonard Walsh expanded on his 1947 Classroom Note in a 1962 booklet [2] concerned with rigor in finding global maximum and minimum values. He argued the second derivative is unnecessary.

[1] J. L. Walsh, "A Rigorous Treatment of the First Maximum Problem in the Calculus," The American Mathematical Monthly, 54(1), 1947 pp. 35–36.

[2] J. L. Walsh, A Rigorous Treatment of Maximum-Minimum Problems in the Calculus, Boston: Heath, 1962.

Contributed by: Roger B. Kirchner