Tutorials › Calculus III › Rectangular Pens Along Existing Walls

Applied Multivariable Optimization · Tutorial 478 of 999

Rectangular Pens Along Existing Walls

Learn to maximize pen area by translating the available walls and fencing into constraints, then checking both interior and boundary designs.

Advanced 9 min read

What You'll Learn

  • Set up fencing and area equations for a pen against one wall or a corner.
  • Account for finite wall lengths as feasibility constraints.
  • Find and interpret interior stationary dimensions.
  • Compare boundary designs with interior candidates.
  • Recognize when an apparently balanced design is infeasible.

Introduction

A rectangular pen beside an existing wall uses less fencing than a free-standing rectangle because the wall replaces one or more fenced sides. The best dimensions depend on how many walls can serve this purpose and, when a wall has finite length, on how much of it the pen can occupy.

The optimization has two parts: first translate the geometry into a fencing constraint and an area formula; then maximize area over the dimensions that are actually feasible. A stationary point is only a candidate. Wall-length limits and the endpoints of the feasible set must also be checked.

Modeling a Pen Against One Wall

Suppose a straight wall forms one side of a rectangular pen. Let \(x\) be the pen's length along the wall, and let \(y\) be its depth, perpendicular to the wall. If the wall can accommodate at most \(A\) units of length and the fencing budget is \(F\), then the fencing forms the opposite long side and the two depths. The area is \(xy\).

Model for one wall: Assume \(F>0\), \(A\geq 0\), and \(x,y\geq 0\). The dimensions must satisfy \(x\leq A\) and \(x+2y=F\). The area to maximize is \(P=xy\). Here \(x+2y=F\) describes designs that use all the fencing; for a positive-area optimum, using additional available fencing to increase a side cannot reduce area.

Eliminating \(y\) gives \(y=(F-x)/2\). Thus feasible designs correspond to \(0\leq x\leq\min(A,F)\), and their areas are given by a function of one variable. The upper bound \(x\leq F\) follows because \(y\) cannot be negative.

$$ P(x)=x\frac{F-x}{2} =\frac{Fx-x^2}{2}, \qquad 0\leq x\leq \min(A,F). $$

Differentiation gives \(P'(x)=(F-2x)/2\), so the unconstrained stationary point is \(x=F/2\). The wall limit determines whether that point is feasible. If \(A\geq F/2\), the stationary point lies in the feasible interval. If \(A<F/2\), the area is still increasing throughout the feasible interval, so the maximum occurs at the wall-length boundary \(x=A\).

One-wall result: For \(F>0\) and \(A>0\), the maximizing dimensions are \(x=\min(A,F/2)\) and \(y=(F-x)/2\). When the wall is long enough, the best design has \(x=F/2\) and \(y=F/4\). When the wall is shorter than \(F/2\), the pen uses the full available wall length.

Worked Example: One Wall With Room for the Interior Optimum

Worked Example: One Wall With Room for the Interior Optimum

A pen has \(40\) metres of fencing and a wall at least \(30\) metres long. Find the dimensions that maximize its area, and compare them with the boundary designs.

Let \(x\) be the length along the wall and \(y\) the depth, both in metres. The fencing equation and area are

$$ x+2y=40, \qquad P=xy. $$

Solving for \(y\) gives \(y=(40-x)/2\), and therefore

$$ P(x)=\frac{x(40-x)}{2}=20x-\frac{x^2}{2}, \qquad 0\leq x\leq 30. $$

Differentiate and set the derivative equal to zero:

$$ P'(x)=20-x, \qquad 20-x=0 \quad\Longrightarrow\quad x=20. $$

This candidate is feasible because \(20\leq 30\). The corresponding depth is \(y=(40-20)/2=10\) metres, and the area is \(P=20\cdot10=200\) square metres. At the endpoints, \(x=0\) gives area \(0\), while \(x=30\) gives \(y=5\) and area \(150\) square metres. Also, \(P'(x)>0\) for \(x<20\) and \(P'(x)<0\) for \(x>20\), so the area increases to \(x=20\) and decreases afterward. The dimensions use \(20+2(10)=40\) metres of fencing and fit along the wall.

When the Wall-Length Boundary Determines the Answer

If the available wall is shorter than the unconstrained optimal length \(F/2\), simply reporting the stationary point would give an impossible design. On the feasible interval, the derivative \(P'(x)=(F-2x)/2\) is positive whenever \(x<F/2\). Thus, if \(A<F/2\), the area increases all the way to \(x=A\). This is a constrained maximum at the wall-length boundary, not an interior stationary point.

Worked Example: A Short Wall Forces a Boundary Maximum

Suppose \(30\) metres of fencing are available, but the wall is only \(10\) metres long. Find the maximum-area design.

With \(x\) along the wall and \(y\) perpendicular to it, the constraints are \(x+2y=30\), \(0\leq x\leq10\). Substitution gives

$$ y=\frac{30-x}{2}, \qquad P(x)=\frac{x(30-x)}{2} =15x-\frac{x^2}{2}. $$

The derivative is \(P'(x)=15-x\). Throughout the feasible interval, \(0\leq x\leq10\), this derivative is at least \(5\), so the area is increasing throughout. The maximum therefore occurs at \(x=10\), the wall limit. Then \(y=(30-10)/2=10\) metres, and the area is \(10\cdot10=100\) square metres. The other endpoint \(x=0\) has area \(0\). Checking the constraints, \(x=10\) fits the wall and \(10+2(10)=30\) metres of fencing are used.

Modeling a Pen Against Two Perpendicular Walls

Now suppose the pen occupies a corner formed by two perpendicular walls. Let \(x\) and \(y\) be the side lengths along those walls, whose usable lengths are \(A\) and \(B\). The two walls form two sides of the rectangle, so fencing is needed only for the opposite sides, with total length \(x+y\).

Model for two walls: Assume \(F>0\), \(A,B\geq0\), and \(x,y\geq0\). A feasible design satisfies \(x+y=F\), \(x\leq A\), and \(y\leq B\). Its area is \(P=xy\). The walls are assumed to meet at a right angle.

Substituting \(y=F-x\) turns the area into \(P(x)=x(F-x)\). The wall limits and nonnegative dimensions restrict \(x\) to an interval. That interval is nonempty exactly when the available fencing can be divided between the walls without exceeding either usable length: \(F\leq A+B\).

$$ \max(0,F-B)\leq x\leq\min(A,F), \qquad y=F-x, \qquad P(x)=x(F-x). $$

The lower bound on \(x\) ensures \(y\leq B\); the upper bound ensures \(x\leq A\) and \(y\geq0\). Differentiating gives \(P'(x)=F-2x\), with a stationary point at \(x=F/2\), where the two sides are equal. But this point is usable only if both walls can accommodate \(F/2\). If not, one of the feasible interval's endpoints gives the maximum.

Two-wall result: For a feasible design interval, the area increases when \(x<F/2\) and decreases when \(x>F/2\). Therefore the maximum occurs at \(x=F/2\) if that value lies in the feasible interval; otherwise it occurs at the feasible endpoint closest to \(F/2\). The corresponding \(y\) is always \(F-x\).

Why the Balanced Design Is Best When It Is Feasible

The equal-side result can also be seen without differentiation. For a fixed sum \(x+y=F\), the identity \((x-y)^2\geq0\) implies \(4xy\leq(x+y)^2\). Equality holds precisely when \(x=y\). Thus the product, and hence the area, is greatest at equal sides among designs with the same sum. Wall limits may exclude that balanced design, in which case the maximum must be found on the feasible boundary.

$$ (x-y)^2\geq0 \quad\Longrightarrow\quad (x+y)^2-4xy\geq0 \quad\Longrightarrow\quad xy\leq\frac{F^2}{4}. $$

This argument also explains why checking feasibility matters: the bound is attained only when \(x=y=F/2\), and those dimensions may exceed one of the available wall lengths.

Worked Example: Two Walls Allow a Balanced Design

Worked Example: Two Walls Allow a Balanced Design

A corner pen has \(24\) metres of fencing. Each wall can accommodate at least \(20\) metres. Find and verify the maximum-area dimensions.

The fencing constraint is \(x+y=24\), so \(y=24-x\). The wall capacities give \(0\leq x\leq20\) and \(0\leq y\leq20\). Since \(y=24-x\), the second capacity requires \(x\geq4\). Therefore \(4\leq x\leq20\), and

$$ P(x)=x(24-x), \qquad P'(x)=24-2x. $$

The stationary point satisfies \(24-2x=0\), so \(x=12\), and then \(y=24-12=12\) metres. Both wall limits are satisfied. The area is \(12\cdot12=144\) square metres. At the feasible endpoints, \(x=4,y=20\) gives \(80\) square metres, and \(x=20,y=4\) also gives \(80\) square metres. Because \(P'(x)>0\) for \(x<12\) and \(P'(x)<0\) for \(x>12\), the interior candidate is the maximum. Finally, \(12+12=24\) metres of fencing are used.

Worked Example: A Wall Limit Forces a Boundary Maximum

Worked Example: A Wall Limit Forces a Boundary Maximum

A corner pen has \(20\) metres of fencing. One wall accommodates at most \(6\) metres, and the other accommodates at least \(20\) metres. Find the maximum-area design.

Let \(x\) lie along the wall limited to \(6\) metres. Since \(x+y=20\), we have \(y=20-x\). The constraints imply \(0\leq x\leq6\); the other wall's limit is satisfied because \(y\leq20\). The area function and derivative are

$$ P(x)=x(20-x)=20x-x^2, \qquad P'(x)=20-2x. $$

For every feasible \(x\leq6\), \(P'(x)\geq20-12=8>0\), so area increases through the entire feasible interval. The maximum occurs at \(x=6\), giving \(y=20-6=14\) metres and area \(6\cdot14=84\) square metres. At the other endpoint \(x=0\), the area is \(0\). The maximizing dimensions satisfy \(6\leq6\), \(14\leq20\), and \(6+14=20\), so the design is feasible and uses all the fencing.

A Common Mistake: Keeping the Balanced Candidate When It Is Infeasible

For the preceding corner example, setting \(x=y\) gives \(x=y=10\), since their sum must be \(20\). This is the unconstrained balanced candidate, but it is not a feasible design: the first wall accommodates at most \(6\) metres, and \(10>6\). The value \(100\) square metres is therefore not an attainable area in this model.

The correction is to optimize on the actual feasible interval \(0\leq x\leq6\). The area increases across that interval, so its largest feasible value occurs at \(x=6\), \(y=14\), and is \(84\) square metres. The lesson is not that equal sides are a poor choice in general; it is that a candidate must satisfy every constraint before it can be considered an answer.

Comparing the Two Geometries

Pen arrangementFencing equationUnconstrained balanced candidateWhat can limit it?
Along one wall\(x+2y=F\)\(x=F/2,\ y=F/4\)The usable length of the wall along \(x\)
In a corner between two walls\(x+y=F\)\(x=y=F/2\)The usable lengths of either wall

The two formulas differ because one existing wall replaces one side, while two perpendicular walls replace two sides. As a result, the best proportions differ even when there are no wall-length limits. In either arrangement, a complete optimization checks the feasible set, evaluates any interior candidate that lies in it, and compares it with the feasible boundary when the candidate is excluded or when endpoints need to be considered.

Check Your Understanding

Use the fencing equation and the feasible dimensions in each question; do not assume a candidate is feasible before checking the wall limits.

  1. For a pen along one wall with \(F=36\) metres and \(A=30\) metres, what dimensions maximize area?
  2. For a one-wall pen with \(F=24\) metres and \(A=8\) metres, which constraint determines the maximizing length along the wall?
  3. For a corner pen with \(F=18\) metres and wall lengths \(A=B=12\) metres, is the balanced candidate feasible?
  4. For a corner pen with \(F=16\) metres and wall lengths \(A=5\) metres and \(B=20\) metres, what feasible endpoint maximizes area?
  5. Why must the equal-side candidate be rejected if one of the walls is too short to accommodate it?