1. The problem
You have of fence and want to enclose the largest possible rectangle. Call the sides and . The fence fixes the perimeter:
The area is
One unknown, and the area is a quadratic in it. Its graph is a parabola opening downwards (the coefficient of is negative), so it has a highest point — the vertex.
2. Find the vertex by completing the square
A square is never negative, so and therefore , with equality only when . The best rectangle is
— a square. (The vertex formula gives the same, and so does the symmetry of the roots: at and , and the vertex lies halfway between them.)
Check a few: , , — all smaller. Equal distances from give equal areas: .
3. Twist: one side against a wall
Now build the pen against a long wall, so only three sides need fence: two sides perpendicular to the wall and one side parallel to it.
The maximum is at , so and
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 square cut along the wall — the square of perimeter 40 mirrored in the wall.)
4. The recipe
- Name the quantities and write the constraint (here: the fence length).
- Use it to express everything with one variable, and note its allowed range.
- Write the quantity to optimise — if it's quadratic with a negative leading coefficient, the vertex is the maximum.
- Find the vertex (complete the square or use ), check it lies in the allowed range, and answer the question that was asked — the dimensions and the area.