Dido's Problem: Optimizing a Rectangular Enclosure Along a River

Wednesday, April 1, 2026

Imagine a farmer who has a fixed length of fencing — say 120 meters — and wants to enclose a rectangular field along a river. The river acts as a natural boundary, so only three sides need fencing.

The field

What shape should the rectangle be to achieve the largest possible area?

This seemingly simple problem is a simplified version of the famous Dido's problem. It is also an excellent introduction to optimization techniques.

Setting Up the Equations

Let's define:

  • x as the width of the rectangle (the two sides perpendicular to the river)
  • y as the length of the rectangle (the side parallel to the river)

The constraint is that the total fencing equals 120 m:

\(2x + y = 120\)

The area to maximize is:

\(A = x \times y\)

Substituting y using the constraint:

\(A(x) = x \times (120 - 2x) = 120x - 2x^2\)

We obtain a function of the single parameter x. It is a downward-opening parabola, so it does have a maximum.

Graph of the parabola A(x) = 120x − 2x² with the maximum at x = 30

Solving with the Derivative

The derivative of a function measures its slope at each point. Geometrically, it is the slope of the tangent line to the curve. When the derivative is positive, the function is increasing; when negative, it is decreasing. And at the peak? The tangent is horizontal: its slope is zero. This is exactly what we see in the graph above.

Finding the maximum therefore comes down to finding where the derivative equals zero. We differentiate:

\(A'(x) = 120 - 4x\)

Then we solve \(A'(x) = 0\):

\(120 - 4x = 0 \implies x = 30\)

The optimal width is therefore x = 30 m, which gives:

\(y = 120 - 2 \times 30 = 60 \text{ m}\)

The maximum area is:

\(A = 30 \times 60 = 1{,}800 \text{ m}^2\)

Verification: It Is Indeed a Maximum

When the derivative equals zero, we have found a critical point — but is it a maximum or a minimum? The second derivative tells us. The second derivative measures how the slope itself changes:

  • If \(A''(x) < 0\), the slope is decreasing: the curve bends downward, we are on a hill → it is a maximum.
  • If \(A''(x) > 0\), the slope is increasing: the curve bends upward, we are in a valley → it is a minimum.

Let's compute:

\(A''(x) = -4\)

The second derivative is constant and negative. The curve bends downward everywhere — it is indeed an "upside-down" parabola. The critical point \(x = 30\) is therefore a global maximum on the interval \([0, 60]\).

Why Isn't a Square Optimal?

Intuition might suggest a square (three sides of 40 m each). Let's calculate:

\(A_{\text{square}} = 40 \times 40 = 1{,}600 \text{ m}^2\)

That's 200 m² less than the optimal solution. The asymmetry of the problem — one side is free thanks to the river — breaks the symmetry of the solution. The side parallel to the river must be twice as long as the perpendicular sides.

Generalization

For any fencing length L, the optimal dimensions are:

Quantity Value
Width (x) L / 4
Length (y) L / 2
Maximum area L² / 8

The length is always twice the width. This is an elegant result that does not depend on the value of L.

What About the Real Dido's Problem?

The problem we just solved is a simplification. The real Dido's problem, rooted in Phoenician mythology, asks the following question: which closed curve of a given length encloses the largest area?

The answer is the circle — or, in the variant with a straight boundary (like our river), a semicircle. The rigorous proof required centuries of mathematical work and is one of the foundations of the calculus of variations.

Our rectangular version, by restricting to rectangular shapes, turns a complex problem into an exercise accessible with high school tools. That is the key insight: optimization often begins by simplifying the problem before solving it.

Why This Matters in Engineering

Optimization problems are ubiquitous in engineering: minimizing a part's mass while meeting strength constraints, maximizing the interior volume of a tank with a fixed amount of material, or finding the fastest machining path.

The approach is always the same:

  1. Identify the quantity to optimize (objective function)
  2. Express the constraints
  3. Reduce the problem to a single variable when possible
  4. Solve by finding critical points
  5. Verify the nature of the critical point (minimum or maximum)

The rectangular field along the river is a first step in that direction.