next up previous
Next: Appendix

CPS 202 HW 5 Solution

The purpose of this assignment is to determine the maximum area of a rectangle of fixed perimeter. This will be done by first performing a simple analysis to arrive at a one-dimensional formula for the area. A short FORTRAN 90 program is then written to create a set of discrete points. Finally, the points are plotted in MATLAB, whose graphical zoom capabilities are used to determine the maximum area.

Given the rectangle shown in Figure 1, the area $ A$ is given by

$\displaystyle A = LW.$ (1)

The perimeter is fixed to be 57.68:

$\displaystyle P = 2(L + W) = 57.68.$ (2)

Solving the perimeter equation for L and substituting into Equation 1 gives

$\displaystyle A(W) = W(28.84 - W).$ (3)

From the geometry of the rectangle, it is clear that this problem only makes sense for $ 0 \le W \le 28.84.$

Figure 1: Rectangle with width $ W$ and length $ L$ .

The exact solution of to this problem can be found by taking the first and second derivatives of Equation 3. This gives

$\displaystyle \frac{dA}{d\,w}\left( W\left(28.84-W\right)\right)$ $\displaystyle =$ $\displaystyle 28.84 -2W$ (4)
$\displaystyle \frac{d^2A}{d\,w^2}\left(W\left(28.84-W\right)\right)$ $\displaystyle =$ $\displaystyle -2.$ (5)

The first derivative is zero when

$\displaystyle 28.84 - 2W = 0\,\,\Longrightarrow\,\, W_{\mbox{max}} = 14.42.$

Because the second derivative is always negative, the second derivative test concludes that this is the only local maximum. Also, the area at the endpoints of the domain is zero, hence this value of $ W$ is also the global maximum. The corresponding value of $ L$ is

$\displaystyle L_{\mbox{max}} = 28.84 - W_{\mbox{max}} = 14.24$

and the maximum area is

$\displaystyle A(W_{\mbox{max}}) = 14.42*(28.84-14.42) = 207.9364.$

The results indicate that the maximum area that can be enclosed is when the rectangle is actually a square.

The FORTRAN 90 program to create a set of discrete points for $ A(W)$ is attached. The program requests a number of discrete points, $ N,$ on the interval $ 0 \le W \le 28.84.$ It then computes the points and writes these to a file. This data in this file is then plotted by the MATLAB function pfun (also attached).

Some experimentation was necessary in order to obtain a graph that was sufficiently smooth in order to obtain reasonable accuracy. Figure 2 shows the function $ A(W)$ using $ N = 21$ points. In order to obtain a good estimate of the maximum area, the zoom capabilities of MATLAB were used to zoom in on the apex of the parabola in Figure 2. The final zoom is shown in Figure 3. From this graph, the estimates $ W_{\mbox{max}} \approx 14.42,\,
A(W_{\mbox{max}}) \approx 207.935$ can be obtained. These results agree very well with the exact values. It is interesting to note that for good accuracy, it is essential to choose an odd number of discrete points. If an even number is chosen, the zooming process will result in a graph shown in Figure 4 (using N = 20 points). This graph clearly shows that an accurate of estimate of $ W_{\mbox{max}}$ is difficult if not impossible for even values of $ N.$ In this example, the value of $ W_{\mbox{max}}$ is accurate to at most the second significant digit. Though not shown, further experiments reveal that for even values of $ N,$ this effect is still present to some degree no matter how many discrete points are used.

Figure 2: Plot of $ A(W)$ vs. $ W$ using 21 points
Figure 3: Close-up view of the apex of $ A(W)$ .
Figure 4: Close-up of the apex of $ A(W)$ when $ N = 20$ points are used.

next up previous
Next: Appendix
Leigh J. Little 2004-02-10