If you took calculus, you probably remember this problem:

You have 100 feet of fence. Build a rectangle. Maximize the area.

It's a classic optimization exercise. But I noticed something about the answer that my textbook never pointed out — something that holds not just for rectangles, but for any rectilinear shape you can draw.

Part 1: The Rectangle

Here's the setup. You have a rectangle with width $w$ and height $h$:

w w h h

The perimeter constraint is:

$$2w + 2h = 100$$

So $h = 50 - w$. The area is:

$$A = w \cdot h = w(50 - w) = 50w - w^2$$

Take the derivative and set it to zero:

$$\frac{dA}{dw} = 50 - 2w = 0$$

$$w = 25, \quad h = 25$$

The answer is a square. Area = 625 sq ft. Everyone knows this.

But notice something about the solution. The total length of the horizontal segments is $w + w = 50$. The total length of the vertical segments is $h + h = 50$. Each direction gets exactly half the perimeter.

Is this just a coincidence of the rectangle's symmetry? Let's try a harder shape.

Part 2: The L-Shape

Same problem, different shape. You have 100 feet of fence and need to enclose an L-shaped yard. The shape has six sides — three horizontal and three vertical:

a = ? b = 10 c = ? d = ? e = 8 f = ?

The problem says: the notch is 10 feet wide ($b = 10$) and 8 feet deep ($e = 8$). You have 100 feet of fence. Maximize the enclosed area. Find $a$, $c$, $d$, and $f$.

First, the geometry constrains two relationships. The top edge spans the full width, so $a = b + c = 10 + c$. The left edge spans the full height, so $f = d + e = d + 8$.

The perimeter is:

$$a + b + c + d + e + f = 100$$

Substituting the known values and the geometric constraints:

$$(10 + c) + 10 + c + d + 8 + (d + 8) = 100$$

$$2c + 2d + 36 = 100$$

$$c + d = 32$$

So $d = 32 - c$. Now express the area. The L-shape is the big rectangle minus the notch:

$$A = a \cdot f - b \cdot e = (10 + c)(d + 8) - (10)(8)$$

Substitute $d = 32 - c$:

$$A = (10 + c)(40 - c) - 80$$

$$A = 400 - 10c + 40c - c^2 - 80$$

$$A = 320 + 30c - c^2$$

Same technique as Part 1 — take the derivative, set it to zero:

$$\frac{dA}{dc} = 30 - 2c = 0$$

$$c = 15$$

And from that: $d = 32 - 15 = 17$, $a = 10 + 15 = 25$, $f = 17 + 8 = 25$.

The maximum area is $A = 320 + 30(15) - 15^2 = 545$ sq ft.

Now check the totals. Horizontal segments: $a + b + c = 25 + 10 + 15 = 50$. Vertical segments: $d + e + f = 17 + 8 + 25 = 50$.

Horizontal = vertical = 50. Exactly half the perimeter each. Same as the rectangle.

Try it with different fixed values for the notch. Make $b = 5$ and $e = 12$. Work through it. You'll get different side lengths, but the totals will split 50/50 again. Every time.

Part 3: The General Rule

This isn't just rectangles and L-shapes. For any rectilinear polygon — U-shapes, staircases, plus signs, any closed shape where every edge is horizontal or vertical — the same rule holds:

At maximum area, the sum of all horizontal segments equals the sum of all vertical segments.

Each orthogonal direction gets exactly half the perimeter.

Why?

The area of any rectilinear polygon can be decomposed into rectangles. Every term in the area expression is a product of one horizontal measurement and one vertical measurement. The area is always a multilinear function of the form:

$$A = \sum c_{ij} , h_i , v_j$$

where $h_i$ are horizontal variables, $v_j$ are vertical variables, and $c_{ij}$ are coefficients determined by the shape's topology.

This is a sum of cross-products between two groups. And for any sum of cross-products subject to a fixed total budget, the maximum occurs when the budget is split equally between the two groups. This follows from the AM-GM inequality — or equivalently, from the symmetry of the Lagrange conditions at the critical point.

The Intuition

Think of it as a resource allocation problem. You're distributing a budget $P$ between two departments: horizontal and vertical. Every unit of output (area) requires both departments to collaborate — you can't make area from horizontal alone. In any such system, the optimal allocation is 50/50. Overinvesting in one direction gives diminishing returns because there's not enough of the other direction to multiply against.

So What?

It's a small result. You won't find it as a named theorem anywhere. But it reveals a structure beneath a class of problems that textbooks treat as unrelated exercises. The L-shaped yard, the U-shaped garden bed, the partitioned room — they all obey the same rule, stated in one sentence:

Split the perimeter equally between horizontal and vertical.

The square was never special. It was just the simplest case.