Let x = the width of the rectangle (now unknown). Then its length is 2x, according to the condition. Then the perimeter of the rectangle is x + 2x + x + 2x = 6x. Then the perimeter of the square is the rest 8-6x and its side is= . Then the total area is = x*(2x) + . Simplify this expression; then take the derivative over x and equate it to zero. In this way you will find x. The rest is just technique.