Maximize the area for two pens.

Problem statement:

Two pens are to be constructed using a total of S feet of fencing.
One pen is to be a square H by H and the other is to be a rectangle
with one side twice as long as the other side; that is, X by 2X.
Determine the dimensions of the pens so that the enclosed areas are
as large as possible.

The accompanying animation uses S= 900 ft.