Let

and

be the sides of the rectangle. The perimeter is given to be 500m, so we are maximizing the area function

subject to the constraint

.
From the constraint, we find

so we can write the area function independently of

:

Differentiating and setting equal to zero, we find one critical point:

which means

, so in fact the largest area is achieved with a square fence that surrounds an area of

.