STEMviz
Free lesson · no sign-up

20 m of fence: the best rectangle is a square — until you add a wall.

Turn a word problem into a parabola, find its vertex without calculus, and drag the sides in the simulation.

High School Mathematics · Free lesson · ~5 min
The cheat sheet
  • Perimeter 20: b = 10 − a, area P(a) = a(10 − a) = 25 − (a − 5)².
  • The parabola opens downwards, so the vertex is the maximum: a = b = 5, area 25.
  • One side against a wall: 2a + b = 20, P(a) = a(20 − 2a) = 50 − 2(a − 5)².
  • Best pen against the wall: 5 × 10, area 50 — the side along the wall is twice as long.
  • Recipe: constraint → one variable → quadratic → vertex → check the allowed range.

1. The problem

You have 20 m20\ \text{m} of fence and want to enclose the largest possible rectangle. Call the sides aa and bb. The fence fixes the perimeter:

2a+2b=20⟹b=10−a,0<a<102a + 2b = 20 \quad\Longrightarrow\quad b = 10 - a, \qquad 0 < a < 10

The area is

P(a)=a b=a(10−a)=−a2+10aP(a) = a\,b = a(10 - a) = -a^2 + 10a

One unknown, and the area is a quadratic in it. Its graph is a parabola opening downwards (the coefficient of a2a^2 is negative), so it has a highest point — the vertex.

2. Find the vertex by completing the square

P(a)=−(a2−10a)=−[(a−5)2−25]=25−(a−5)2P(a) = -(a^2 - 10a) = -\big[(a - 5)^2 - 25\big] = 25 - (a - 5)^2

A square is never negative, so (a−5)2≥0(a-5)^2 \ge 0 and therefore P(a)≤25P(a) \le 25, with equality only when a=5a = 5. The best rectangle is

a=5,b=10−5=5,Pmax=25 m2a = 5,\quad b = 10 - 5 = 5,\quad P_\text{max} = 25\ \text{m}^2

— a square. (The vertex formula a=−B2A=−102⋅(−1)=5a = -\tfrac{B}{2A} = -\tfrac{10}{2\cdot(-1)} = 5 gives the same, and so does the symmetry of the roots: P=0P = 0 at a=0a = 0 and a=10a = 10, and the vertex lies halfway between them.)

Check a few: 4×6=244 \times 6 = 24, 3×7=213 \times 7 = 21, 1×9=91 \times 9 = 9 — all smaller. Equal distances from a=5a = 5 give equal areas: P(3)=P(7)=21P(3) = P(7) = 21.

3. Twist: one side against a wall

Now build the pen against a long wall, so only three sides need fence: two sides aa perpendicular to the wall and one side bb parallel to it.

2a+b=20⟹b=20−2a,0<a<102a + b = 20 \quad\Longrightarrow\quad b = 20 - 2a, \qquad 0 < a < 10 P(a)=a(20−2a)=−2a2+20a=50−2(a−5)2P(a) = a(20 - 2a) = -2a^2 + 20a = 50 - 2(a - 5)^2

The maximum is at a=5a = 5, so b=20−10=10b = 20 - 10 = 10 and

Pmax=5⋅10=50 m2P_\text{max} = 5 \cdot 10 = 50\ \text{m}^2

The wall doubles the best area, and the best shape is no longer a square: the side along the wall is twice as long as the others. (It is exactly half of a 10×1010 \times 10 square cut along the wall — the square of perimeter 40 mirrored in the wall.)

4. The recipe

  1. Name the quantities and write the constraint (here: the fence length).
  2. Use it to express everything with one variable, and note its allowed range.
  3. Write the quantity to optimise — if it's quadratic with a negative leading coefficient, the vertex is the maximum.
  4. Find the vertex (complete the square or use −B2A-\tfrac{B}{2A}), check it lies in the allowed range, and answer the question that was asked — the dimensions and the area.
Check your understanding · 5 questions

Conceptual Quiz

Tempting answers throughout. Commit to a choice before revealing the reasoning — recognising your own misconception is worth far more than a lucky guess.

Fixed perimeter

Of all rectangles with perimeter 20 cm20\ \text{cm}, which has the largest area?

Select an option to reveal the explanation.

Fence against a wall

20 m20\ \text{m} of fence encloses a rectangle against a long wall, so it covers only three sides (2a+b=202a + b = 20). What is the largest area?

Select an option to reveal the explanation.

Maximum or minimum

How do you know the vertex of P(a)=−a2+10aP(a) = -a^2 + 10a is a maximum and not a minimum?

Select an option to reveal the explanation.

General perimeter

A rectangle has perimeter LL. What is the largest area it can have?

Select an option to reveal the explanation.

Symmetry

For P(a)=a(10−a)P(a) = a(10 - a), how do P(3)P(3) and P(7)P(7) compare?

Select an option to reveal the explanation.

Black Friday: lifetime access up to 50% off · until December 1
Liked this? Keep going

Get all of High School Mathematics

This free lesson covers one topic. The course has 60 full chapters, each with a simulation to play with, the full theory with derivations, exam questions where every option is explained, practice problems with hints and worked solutions, flashcards and saved progress.

Continue with these chapters:
  • Applications of Derivatives: Optimization and Local Extrema
  • Applications of Derivatives in Kinematics (Displacement, Velocity, Acceleration)
  • The Concept of the Indefinite Integral and Basic Formulas
  • Integration by Substitution and by Parts
  • The Definite Integral and the Fundamental Theorem of Calculus
$13.99/monthFirst 3 days free · cancel in one click
Secure checkout by Lemon Squeezy, our merchant of recordSee all 60 chapters of High School Mathematics →
Not ready yet?

Get free lessons by email

One email every few days. Unsubscribe in one click.