The Fence Optimization Problem

April 12, 2026

Problem

You have 100 m of fence. What rectangle dimensions maximize the enclosed area?

Explanation

You're given a fixed length of fence and asked to enclose the largest possible rectangular area. The intuition might suggest a long thin rectangle gives "more land per fence" — but the math says the opposite: the square is always optimal. This is a classic application of single-variable optimization with a constraint.

The Physics — Just an Optimization

Let xx be one side of the rectangle and yy be the other. We have two equations:

  • Constraint (fixed perimeter): 2x+2y=100    y=50x2x + 2y = 100 \;\Longrightarrow\; y = 50 - x
  • Objective (maximize): A=xyA = xy

Substitute the constraint into the objective to get AA as a function of one variable. Then take the derivative, set it to zero, and solve.

Step-by-Step Solution

Given: Total perimeter P=100  mP = 100\;\text{m}.

Find: The dimensions (x,y)(x, y) that maximize the enclosed area.


Step 1 — Write the constraint and the objective.

constraint:    2x+2y=100        y=50x\text{constraint:} \;\; 2x + 2y = 100 \;\;\Longrightarrow\;\; y = 50 - x

objective:    A=xy\text{objective:} \;\; A = xy

Step 2 — Substitute the constraint into the objective.

A(x)=x(50x)=50xx2A(x) = x(50 - x) = 50x - x^{2}

Now AA is a function of a single variable xx, valid for 0x500 \le x \le 50.

Step 3 — Differentiate A(x)A(x).

A(x)=502xA'(x) = 50 - 2x

Step 4 — Set A(x)=0A'(x) = 0 and solve.

502x=050 - 2x = 0

2x=502x = 50

x=25  mx = 25\;\text{m}

Step 5 — Find the corresponding yy.

y=50x=5025=25  my = 50 - x = 50 - 25 = 25\;\text{m}

So the optimal rectangle has x=y=25  mx = y = 25\;\text{m} — it's a square.

Step 6 — Compute the maximum area.

Amax=(25)(25)=625  m2A_{\max} = (25)(25) = 625\;\text{m}^{2}

Step 7 — Confirm it's a maximum (not a minimum) using the second derivative.

A(x)=2A''(x) = -2

Since A(x)=2<0A''(x) = -2 < 0 everywhere, the function A(x)A(x) is concave down. The critical point at x=25x = 25 is therefore a global maximum on [0,50][0, 50]. ✓

Step 8 — Compare with other shapes to feel the difference.

  • A long thin rectangle 40×1040 \times 10: A=400  m2A = 400\;\text{m}^{2} (35% smaller!)
  • A medium rectangle 30×2030 \times 20: A=600  m2A = 600\;\text{m}^{2}
  • A square 25×2525 \times 25: A=625  m2A = 625\;\text{m}^{2} ← maximum
  • A long thin rectangle 45×545 \times 5: A=225  m2A = 225\;\text{m}^{2}

The further from a square you go, the worse you do — and the area falls off symmetrically on either side of x=25x = 25 (since A(x)A(x) is a downward parabola).


Answer: The optimal rectangle is a square with side length 25  m25\;\text{m}, giving a maximum area of Amax=625  m2\boxed{A_{\max} = 625\;\text{m}^{2}}. Of all rectangles with a fixed perimeter, the square encloses the most area.

Generalization

This result holds for any total perimeter PP: the optimum is always x=y=P/4x = y = P/4, with Amax=P2/16A_{\max} = P^{2}/16. For P=100P = 100, that's 625  m2625\;\text{m}^{2}. For P=200P = 200, it would be 2500  m22500\;\text{m}^{2}, and so on. (And if you allow any shape, not just rectangles, the circle wins overall — but that requires multivariable calculus.)

Try It

  • Slide the width widget — watch the rectangle reshape and the area number update.
  • The graph below shows A(x)=50xx2A(x) = 50x - x^{2} — a downward parabola with peak at x=25x = 25.
  • The HUD lights up "★ MAXIMUM" when you're at x=25x = 25.
  • Notice the symmetric falloff: A(20)=A(30)=600  m2A(20) = A(30) = 600\;\text{m}^{2}, A(15)=A(35)=525  m2A(15) = A(35) = 525\;\text{m}^{2}, etc.

Interactive Visualization

Parameters

25.00
100.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
The Fence Optimization Problem | MathSpin