Why do I need quadratic equations to fence a garden?

With a fixed length of fence, a deeper garden is a narrower one. Area equals depth times width, and because width shrinks as depth grows, area becomes a quadratic. Its graph is an upside-down parabola, and the top of that curve is the biggest garden your fence can make. The vertex formula finds it exactly.

best: 200 m²192 m²house wall12 m16 m
Garden area
192 m²
Garden width
16 m
Biggest possible
200 m²

Challenge: Build the biggest possible garden (within 1%).

How far the garden reaches out from the wall.

Play

Slide the depth. Watch the garden change shape and the dot climb and fall on the curve.

Challenge: Build the biggest possible garden (within 1%). The box under the picture turns green when you get it.

Stuck? Pick one of the examples from the “Try an example” menu, or press “New example.”

Understand

A(x)=x (F−2x)A(x) = x\,(F - 2x)

Area is depth times width. With the fence on three sides, the width is whatever fence is left after the two sides: F−2xF - 2x. So

A(x)=x (F−2x)=−2x2+FxA(x) = x\,(F - 2x) = -2x^2 + Fx

That's a quadratic with a negative x2x^2 term, so its graph is a hill. The blue dot is your garden. The top of the hill (the vertex) is the biggest garden, at

x=−b2a=F4x = -\frac{b}{2a} = \frac{F}{4}

Too shallow and the garden is a thin strip. Too deep and it's a narrow corridor. The vertex is the balance point.

Use

Every input has a unit menu, so you can type values in the units you already have. Results follow your units.

Show the work

  1. Area = depth × widthA = x\,(F - 2x) = -2x^2 + Fx
  2. With your numbersA = 12 \times 16 = 192\ \mathrm{m^2}
  3. Best depth (vertex)x = -\frac{b}{2a} = -\frac{40}{2(-2)} = 10\ \mathrm{m}
  4. Biggest areaA_{\max} = 200\ \mathrm{m^2}

Export

Export PDF

Enter the fence you actually have and try depths, or read the best depth straight from the "Biggest possible" result. Turn off the wall option for a free-standing pen.

  • Leave room for a gate. Subtract its width from the fence length.
  • For round or irregular beds, a circle encloses the most area of any shape.

For learning and estimation. Verify with applicable codes, standards, and a qualified professional before using in design, construction, or safety-critical work.

Cheat card

A(x)=x (F−2x)A(x) = x\,(F - 2x)
xbest=−b2a=F4x_{\text{best}} = -\frac{b}{2a} = \frac{F}{4}
Amax⁡=F28A_{\max} = \frac{F^2}{8}
SymbolMeaningUnit
FFlength of fence you havem
xxdepth (the two sides touching the wall)m
AAgarden aream²
  • Against a wall, the best garden is twice as wide as it is deep.
  • Without a wall, the best rectangle is a square.
  • Using a wall as one side always gives more area from the same fence.

Print this card

Where it’s used

  • Gardening
    Gardeners plan raised beds and vegetable plots to get the most growing room from the fencing they have.
  • Home Projects
    The same math sizes dog runs, patios, and chicken pens.

Questions people ask

What shape gives the most area for a fixed fence?

For a rectangle with fence on all four sides, a square. With a wall as one side, a rectangle twice as wide as it is deep.

Why is this a quadratic?

Area is depth × width, and width depends on depth (F − 2x). Multiplying gives −2x² + Fx, a quadratic with a maximum.

How do I find the maximum without a graph?

Use the vertex formula x = −b / (2a). Here a = −2 and b = F, so the best depth is F/4.