library(Deriv)

8. A rancher has 1000 feet of fencing in which to construct adjacent,equally sized rectangular pens. What dimensions should these pens have to maximize the enclosed area?

Solution -

  1. First, draw a model of adjacent, equally sized rectangular pens -

                  Y (length)
    
             ------------------
             |        |       |  X (width)
             |        |       |
             ------------------

    Area = X * Y Perimeter = 3x + 2y

  2. Since we want to maximize the area enclosed by the fence, we express the Area in terms of X using the perimeter equal to 1000 feet and then solve for the crtical value of the Area A’.

1000 = 3x + 2y

  y  = (1000 - 3x)/2
  
Area = (1000x - 3x$^2$)/2
     = 500x - (3/2)x$^2$
     
Area' = 500 -3X  (point where area is maximum)
fx <- function(x) {
  500 - (3*x)
}

a <- uniroot(fx, c(200, -200))
a$root
## [1] 166.6667
x = a$root
x
## [1] 166.6667
y = (1000 - 3*x)/2
y
## [1] 250
Area = x*y
Area #maximum
## [1] 41666.67