Introduction
When one rectangular enclosure is divided into several pens, the partitions are shared with neighboring pens rather than built as separate complete enclosures. That changes how much fencing is needed. To maximize the animals’ total enclosed area, we must count every fence in the arrangement, including the outer sides, and then optimize the area subject to the fencing budget.
We will consider a fixed positive integer \(n\) pens arranged in a single row. The pens share parallel partition fences and have a common depth. Their widths along the row do not need to be equal: the total area depends on the sum of those widths, not on how that sum is divided.
Modeling the fences
Let \(L\) be the total length of the row of pens, and let \(D\) be their common depth. Both are measured in units of length. The combined area is the area of the full rectangle occupied by the pens, so the total enclosed area is \(A=LD\).
There are two outer fences of length \(L\), one along each long side of the row. Across the depth, there are \(n-1\) internal partitions between neighboring pens, as well as two outer side fences. Thus there are \(n+1\) fences of length \(D\) in that direction.
If the available fencing budget is \(F\), measured in units of length, using the full budget gives the constraint
The model assumes the pens are nondegenerate, so \(L>0\) and \(D>0\). A physical arrangement with positive area cannot use less than the full budget at a maximum: if some fencing were unused, the dimensions could be increased while remaining within the budget. We therefore use equality in the constraint.
Reduce the area to one variable
Solving the fencing equation for the depth gives
Substituting this expression into \(A=LD\) leaves a one-variable objective:
For the dimensions to be positive, we need \(L>0\) and \(F-2L>0\). Since \(F>0\), the feasible values of \(L\) are therefore
The limiting endpoints correspond to a zero row length or zero depth, so they are not physical pens. We can still evaluate the area formula at those endpoints when checking the limiting values: it gives zero at each one.
The maximum-area dimensions
The area function is a quadratic. Its maximum can be established by completing the square, which also shows directly why the dimensions have the values they do.
To prove the result, rewrite the area function by completing the square:
Because a square is nonnegative, the subtracted term is nonnegative. Thus \(A(L)\leq F^2/[8(n+1)]\) for every feasible \(L\), with equality exactly when \(L=F/4\). Since \(F>0\), this value lies strictly inside the feasible interval: \(0<F/4<F/2\). It is therefore attainable by positive dimensions.
Substituting \(L=F/4\) into the constraint determines the depth:
The resulting area is
This proof checks the full feasible range, not just a stationary point. Equivalently, differentiating gives \(A'(L)=(F-4L)/(n+1)\), which is positive for \(L<F/4\) and negative for \(L>F/4\). The area increases up to \(F/4\) and decreases after it. At the limiting endpoints \(L=0\) and \(L=F/2\), the area is zero, while the interior maximum is positive.
Worked Example: Three pens with 120 metres of fencing
Worked Example: Three pens with 120 metres of fencing
Three adjacent pens are arranged in one row. The budget is \(F=120\) metres and \(n=3\). The fence count is two fences of length \(L\) and \(n+1=4\) fences of depth \(D\), so the constraint is \(2L+4D=120\).
The maximizing row length is
The corresponding depth is
The total area is
Check the fencing: the two long fences use \(2(30\text{ m})=60\text{ m}\), and the four depth-length fences use \(4(15\text{ m})=60\text{ m}\). Their total is \(60\text{ m}+60\text{ m}=120\text{ m}\), as required. The area formula gives \(120^2/[8(4)]=14{,}400/32=450\text{ m}^2\), matching the dimensions.
Worked Example: Five pens with 180 feet of fencing
Worked Example: Five pens with 180 feet of fencing
Suppose \(n=5\) pens share a fencing budget of \(F=180\) feet. There are \(n+1=6\) fences of depth \(D\). The constraint is \(2L+6D=180\).
The maximizing total row length is
The depth is
Thus the total area is
Check the fence budget: the two long sides require \(2(45\text{ ft})=90\text{ ft}\), and the six fences across the depth require \(6(15\text{ ft})=90\text{ ft}\). The total is \(90\text{ ft}+90\text{ ft}=180\text{ ft}\). Independently, the maximum-area formula gives \(180^2/[8(6)]=32{,}400/48=675\text{ ft}^2\), in agreement.
Worked Example: Two pens with 96 metres of fencing
Worked Example: Two pens with 96 metres of fencing
For \(n=2\) pens and a budget of \(F=96\) metres, the row has two outer depth fences and one internal partition, making \(n+1=3\) fences of length \(D\). The constraint is \(2L+3D=96\).
The maximizing row length is
The depth is
The total enclosed area is
Check the budget: the two long fences use \(2(24\text{ m})=48\text{ m}\), and the three depth fences use \(3(16\text{ m})=48\text{ m}\). Together they use \(48\text{ m}+48\text{ m}=96\text{ m}\). The formula gives \(96^2/[8(3)]=9{,}216/24=384\text{ m}^2\), confirming the area.
What changes when the number of pens increases?
The optimal total row length \(F/4\) does not depend on \(n\). The depth does depend on \(n\): \(D=F/[2(n+1)]\), so adding pens while keeping the same total fencing budget makes the optimal depth smaller. The maximum area \(F^2/[8(n+1)]\) also decreases as \(n\) increases, because each additional pen requires another partition fence.
This comparison assumes the same arrangement each time: all pens are in one row, share a common depth, and use the stated total fencing budget. It does not say that every possible layout of pens has this form or that this row arrangement is optimal among all conceivable layouts.
A common fence-counting mistake
A frequent error is to count only the internal partitions when tallying fences across the depth. For \(n\) pens, there are \(n-1\) internal partitions, but the two outer sides must also be fenced. The correct count is therefore \((n-1)+2=n+1\).
For example, with three pens, counting only the two internal partitions would lead to the incorrect constraint \(2L+2D=F\). The actual layout has two outer side fences in addition to those partitions, so the correct constraint is \(2L+4D=F\). Omitting the outer sides understates the fencing required for any proposed dimensions and produces an incorrect optimized area. A reliable check is to trace the entire boundary and then count every internal partition once.
Check Your Understanding
Use the fence count and one-variable area model to answer the following questions.
- How many fences of length \(D\) are required for a row of \(n\) adjacent pens, including its two outer sides?
- For \(n=4\) and \(F=160\) metres, what total row length and depth maximize the area?
- For \(n=4\) and \(F=160\) metres, verify that the proposed dimensions use all the fencing and calculate the total area.
- Why do the limiting values \(L=0\) and \(L=F/2\) give zero area, and why is the maximum nevertheless attained?
- What fence-counting error results from using \(n-1\) rather than \(n+1\) for the number of depth-length fences?