Length is L. Width is W.
LW = 338
W = 338/L
Amount Used = Total Area = A = (L + 4)(338/L + 2) - those are the length and width with the margins added.
FOIL: A = 338 + 2L + 1342/L + 8 = 2L + 1342/L + 346 = 2L +1342L^-1 + 346
A' = 2 -1342L^(-2) = 0
2L^2 -1342 = 0
L^2 = 1342/2 = 671
L = sqrt(671) = about +/- 25.9037
-inf to -25.9037: use -100: Derivative is positive. -25.9037 isn't a minimum
-25.9037 to 25.9037: Use 0. Derivative is negative
25.9037 to infinity: use 100: Derivative is positive.
Down before 25.9037, up after 25.9037. 25.9037 is a minimum.
W = 338/sqrt(671) = about 13.0483