Tutorials › AP Calculus › Fencing Along a River with Interior Dividers

Optimization and L'Hôpital's Rule · Tutorial 401 of 999

Fencing Along a River with Interior Dividers

Learn to count the fencing correctly, reduce the area to one variable, and verify that the critical point gives the greatest feasible area.

Advanced 10 min read

What You'll Learn

  • Represent the shared depth and total length of adjoining pens with variables
  • Count the back fence and every interior divider in the constraint
  • Derive the area function for a fixed number of pens and fencing budget
  • Find the critical point and check it against the feasible boundary cases
  • Explain why the maximizing dimensions produce an absolute maximum

Modeling Pens Along a River

A river can form one side of a set of rectangular pens, so fencing is needed along only the opposite long side and across the pens’ ends and dividers. The main modeling challenge is counting those segments correctly: every interior divider uses fencing too.

Suppose \(n\) adjoining pens share a common depth \(x\), measured perpendicular to the river. Let \(y\) be their total length along the river. The pens need not have equal widths along the river; what matters is that they have the same depth and together span length \(y\). Assume \(n\) is a fixed positive integer, the river’s edge needs no fence, and the total available fencing is \(F\), where \(F>0\).

Definition: The feasible dimensions are the values of \(x\) and \(y\) that satisfy the fencing constraint and have nonnegative lengths. A physically useful set of pens has \(x>0\) and \(y>0\).

Count the Fencing Before Optimizing

There is one fence running along the back of the pens, of length \(y\). Across the depth \(x\), there are two outside end fences and \(n-1\) interior dividers. That makes \(n+1\) segments of length \(x\) altogether. The river itself supplies the remaining side, so it contributes no fencing to the budget.

$$ F=y+(n+1)x $$

The total area is the sum of the areas of the pens. Since they all have depth \(x\) and their widths along the river add to \(y\), this total is \(xy\). Solving the constraint for \(y\) gives \(y=F-(n+1)x\). Substitution reduces the area to one variable:

$$ A(x)=x\bigl(F-(n+1)x\bigr) =Fx-(n+1)x^2. $$

Because \(x\) and \(y\) must be nonnegative, \(0\leq x\leq F/(n+1)\). The endpoints represent degenerate layouts: \(x=0\) gives no depth, while \(x=F/(n+1)\) leaves no fencing for the back and hence \(y=0\). Both have zero area. A usable layout lies strictly between these endpoints.

Worked Example: Three Pens with 240 Metres of Fencing

Worked Example: Three Pens with 240 Metres of Fencing

Three adjoining pens share a depth \(x\), and together they span length \(y\) along the river. The available fencing is \(240\) metres. Find the dimensions that maximize the total area, and check the feasible candidates.

Here \(n=3\), so there are \(n+1=4\) fences of length \(x\): two outside ends and two dividers. The constraint and area are

$$ 240=y+4x,\qquad y=240-4x, $$
$$ A(x)=xy=x(240-4x)=240x-4x^2. $$

Feasibility requires \(0\leq x\leq60\), because \(y=240-4x\) must be nonnegative. Differentiate and set the derivative equal to zero:

$$ A'(x)=240-8x,\qquad 240-8x=0,\qquad x=30. $$

The corresponding length is \(y=240-4(30)=120\) metres, and the area is \(A(30)=30(120)=3600\) square metres. Check the candidates on the closed feasible interval: \(A(0)=0\), \(A(60)=0\), and \(A(30)=3600\). Thus the interior critical point gives the greatest feasible area.

Finally, the dimensions satisfy the original fencing budget: \(4(30)+120=120+120=240\) metres. The maximum-area layout has depth \(30\) metres and total length \(120\) metres.

Why the Critical Point Gives the Maximum

The derivative identifies an interior candidate, but a maximum-area conclusion also needs to account for the boundary of the feasible interval. The derivative’s sign shows how the area changes as the depth varies; an equivalent algebraic argument makes the global comparison especially clear.

Theorem: For a fixed positive fencing budget \(F\) and a fixed positive integer \(n\), the total area of \(n\) adjoining pens with common depth \(x\) is greatest when \(x=F/[2(n+1)]\) and \(y=F/2\). The maximum area is \(F^2/[4(n+1)]\).
1
Write the feasible area function.
From \(y=F-(n+1)x\), the area is \(A(x)=Fx-(n+1)x^2\), with \(0\leq x\leq F/(n+1)\).
2
Find the interior critical point.
Since \(A'(x)=F-2(n+1)x\), the equation \(A'(x)=0\) gives \(x=F/[2(n+1)]\). This lies inside the feasible interval because \(F>0\).
3
Recover the other dimension.
Substitution into the constraint gives \(y=F-(n+1)F/[2(n+1)]=F/2\).
4
Compare the area with every feasible value.
Completing the square gives \(A(x)=F^2/[4(n+1)]-(n+1)(x-F/[2(n+1)])^2\). The squared term is nonnegative, so no feasible \(x\) can produce a greater area. Equality holds at the critical point.

This also checks the boundary cases: at either endpoint the area is zero, while the critical point gives \(F^2/[4(n+1)]>0\). The positive interior value therefore exceeds both endpoint values. The derivative test reaches the same conclusion: \(A'(x)>0\) below \(F/[2(n+1)]\) and \(A'(x)<0\) above it, so the area increases up to the critical point and decreases afterward.

Worked Example: Two Pens and a Feasible-Candidate Check

Worked Example: Two Pens and a Feasible-Candidate Check

Two adjoining pens have \(180\) metres of fencing available. Find the maximum total area, explicitly checking the critical point and both boundary candidates.

With \(n=2\), the fence count is \(n+1=3\): two outside ends and one divider. Thus \(180=y+3x\), so \(y=180-3x\). The area function and its feasible interval are

$$ A(x)=x(180-3x)=180x-3x^2,\qquad 0\leq x\leq60. $$

Differentiate: \(A'(x)=180-6x\). Setting \(A'(x)=0\) gives \(6x=180\), hence \(x=30\) metres. Then \(y=180-3(30)=90\) metres and \(A(30)=30(90)=2700\) square metres.

The full candidate comparison is \(A(0)=0\), \(A(30)=2700\), and \(A(60)=0\). Therefore the critical point gives the absolute maximum on the feasible interval. Checking the original constraint confirms \(3(30)+90=90+90=180\) metres of fencing.

How the Number of Dividers Affects the Result

The general formula shows that adding pens while keeping the fencing budget fixed reduces the maximum possible total area. Each additional pen requires another divider of depth \(x\), so the same budget must cover more perpendicular fencing. In the formula, increasing \(n\) increases the denominator of the maximum area \(F^2/[4(n+1)]\).

Worked Example: Comparing One Pen with Five Pens

Compare a single pen and five adjoining pens when each layout has \(300\) metres of fencing. Find the maximum area for each layout and verify the dimensions against the budget.

For one pen, \(n=1\), so \(n+1=2\). The maximizing dimensions are \(x=300/[2(2)]=75\) metres and \(y=300/2=150\) metres. The area is \(75(150)=11250\) square metres. The fencing check is \(2(75)+150=150+150=300\) metres.

For five pens, \(n=5\), so \(n+1=6\). The maximizing dimensions are \(x=300/[2(6)]=25\) metres and \(y=300/2=150\) metres. The total area is \(25(150)=3750\) square metres. The fencing check is \(6(25)+150=150+150=300\) metres.

The five-pen layout uses the same back-fence length but needs four additional dividers compared with the single pen. Its maximum total area, \(3750\) square metres, is less than the single pen’s \(11250\) square metres. The count of pens is a fixed design choice in each optimization; this comparison does not treat the integer \(n\) as a continuous variable.

A Common Counting Error

A frequent mistake is to count only one cross-fence per pen. For three pens, that incorrectly gives three segments of length \(x\), even though the layout has two outside ends as well as two dividers. The correct number is four.

For example, with \(240\) metres and three pens, the incorrect equation \(240=y+3x\) would give the incorrect area model \(A(x)=x(240-3x)\). Differentiating gives \(A'(x)=240-6x\), so this mistaken model predicts \(x=40\) and \(y=120\). But those dimensions would require \(4(40)+120=280\) metres of fencing, not \(240\). The correction is to count all four cross-fences: \(240=y+4x\). The correct maximizing dimensions are \(x=30\) and \(y=120\), which use exactly \(240\) metres.

Why This Model Is Useful

This problem illustrates a general optimization strategy: translate the physical design into a constraint, use that constraint to express the objective with one variable, and check every candidate on the feasible interval. In a fence problem, the diagram and the count of segments are part of the mathematics, not just setup details. A derivative can be calculated correctly from the wrong constraint and still lead to an impossible design.

The final dimensions should therefore pass two checks. First, they must satisfy the original fencing constraint. Second, their area must be at least as large as the areas at the feasible boundary cases. Here the quadratic area function and its completed-square form establish that the interior critical point meets both requirements and is the unique maximum-area design for the fixed number of pens.

Check Your Understanding

For each question, assume the pens share a common depth and the river’s edge requires no fencing.

  1. For \(n\) adjoining pens, why are there \(n+1\) fences of length \(x\), rather than \(n\)?
  2. Write the fencing constraint and area function for four pens with a budget of \(200\) metres.
  3. For \(n\) pens and budget \(F\), state the feasible interval for \(x\) and explain what its endpoints represent.
  4. Use the general result to find the maximizing dimensions for three pens with \(160\) metres of fencing.
  5. Why is checking that the proposed dimensions satisfy the fencing constraint not, by itself, enough to establish that they maximize area?

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon