Maximum Area With a Fixed Length of Fencing: Why a Square Wins and How a Wall Changes It

October 21, 2026

A farmer, a gardener, or a dog owner with a fixed length of fencing wants to enclose the largest possible area. The answer for a rectangle is a square. With 100 feet of fence, a rectangle that is 25 feet by 25 feet has an area of 625 square feet. Any other rectangle with the same perimeter has less area: 10 by 40 feet gives only 400 square feet, and 20 by 30 gives 600.

This is a classic optimization problem, and its solution shows how calculus or even basic algebra can be used to find a maximum. The result also reveals a general principle: for a given perimeter, shapes that are more 'round' enclose more area, and the circle is the best of all.

Skip the math and get your answer instantly:

Open the Area Calculator →

The Algebra

Let the rectangle have width w and length L, with perimeter 2w + 2L = 100, so L = 50 − w. The area is A = w × L = w(50 − w) = 50w − w². This is a downward-opening parabola, with its maximum at the vertex, w = −b ÷ 2a = 50 ÷ 2 = 25. Then L = 25, and the area is 625 square feet. Without calculus, you can also see that A = 625 − (w − 25)², which is largest when w = 25 and decreases as w moves away from 25 in either direction.

WidthLengthArea (sq ft)
1040400
1535525
2030600
2525625
3020600
4010400

Using a Wall or River as One Side

If one side of the enclosure is an existing wall, you only need fence for three sides. Let the two sides perpendicular to the wall each have length w, and the side parallel to the wall have length L. Fencing: 2w + L = 100, so L = 100 − 2w. Area = w(100 − 2w) = 100w − 2w². The maximum is at w = 100 ÷ 4 = 25, giving L = 50 and an area of 1,250 square feet, exactly double the area of the free-standing square. The optimal shape has the side along the wall twice as long as each of the two sides. Using a wall (or a fence line you already have) is a very efficient way to double the area.

Other Shapes and the Circle

A regular polygon with more sides encloses more area for the same perimeter. A square with a perimeter of 100 feet has an area of 625. A regular hexagon has 100 ÷ 6 = 16.67 foot sides and an area of 2.598 × 16.67² = 722. A circle with circumference 100 feet has radius 15.9 feet and area π × 15.9² = 796 square feet, the maximum possible. So a circular pen uses fence most efficiently, though it is harder to build and fit into a yard, and gates and corner posts add complexity. A circle uses about 11% less fence than a square for the same area.

In practice, rectangles are easier to build, to fit against property lines, and to use for garden beds.

Practical Considerations

The mathematical optimum may not be practical. A long thin garden bed is easier to reach and tend than a square one. A dog run might need to be long for exercise. Gate openings take up fence length. Posts take up some of the length. Use the optimization as a baseline and compare it to your needs. If you have a fixed area to enclose and want to minimize fence, a square (or a rectangle close to square) uses the least material: for 625 square feet, a square needs 100 feet of fence, whereas a 10 by 62.5 foot rectangle needs 145 feet, 45% more.

The General Lesson

Optimization problems appear throughout business and engineering: maximizing profit, minimizing cost, or finding the best dimensions of a container. The recipe is the same: express what you want to optimize in terms of one variable using the constraint, then find the maximum or minimum, using algebra, a graph, or calculus. Always check that the answer makes physical sense.

Frequently Asked Questions

What rectangle encloses the largest area for a given perimeter?

A square.

How much area can 100 feet of fence enclose?

625 square feet as a free-standing square, or 1,250 square feet using a wall as one side.

Is a circle better than a square?

For a given perimeter, yes. A circle encloses about 27% more area than a square.

How do I set up an optimization problem?

Write the quantity to maximize, use the constraint to reduce it to one variable, and find the maximum or minimum.

Does this apply to minimizing fence for a fixed area?

Yes. The square uses the least perimeter for a rectangle of a given area.