 I suspect that every calculus textbook ever written has some variation of the following problem. I'd like to say that it's an homage to the fact that Newton was born on a farm. But it probably isn't. And we'll take a look at this particular variation. A farmer needs to put a fence around some enclosures as shown, and we may assume that the three rectangles are of equal width. Suppose the exterior fence must be made of a material costing $5 per foot, while the interior fence can be made from cheaper material costing $3 per foot. If there is $1500 available for the project, what dimensions yield the maximum area? Since we're trying to maximize the area of a rectangular region, we might let our variables represent the sides. So let x be the width and y be the length, both in feet. Next we might try to find any relationship at all between the variables, and possibly some other quantities. Since we want to maximize the area, we should look for a relationship with the area a. And since our field is a rectangular area, then a is going to be equal to width times length x times y. Now since we're trying to maximize area, then this is the function that we're going to be working with. The only problem is we don't yet know how to deal with two variables. So let's see what else we can do. We're also told that the exterior fence costs $5 per foot, so we might want to find the amount of exterior fencing. So we find there's going to be 2x plus 2y feet of exterior fence, then our exterior fence will cost 5 times 2x plus 2y. Similarly, we know the interior fence costs $3 per foot, so we might find how much interior fence there is, and so we see there's 2y feet of interior fence which will cost us 3 times 2y dollars. And so that means our total cost of the fencing is going to be the cost of the exterior fence plus the cost of the interior fence, which simplifies. Since x and y could change, they are variable. So is the area, which means we must leave them as variables. However, c, our cost, is a constant $1,500, and that never changes. That's all that we have to spend, so we can let it be $1,500. And this allows us to solve for either x or y. We'll solve for x. And so now we have x in terms of y. So substituting this into our area formula, which gives us the area as a function of y only. So we'll find our critical points, and since it's easy enough for this function, the second derivative. Since our derivative is defined everywhere, the only critical point is going to be where the derivative is 0, so solving for that. And because our second derivative is always negative, then this critical point corresponds to a local maximum value. And finally, since we know the relationship between x and y, once we know the value of y, we can find the value of x, which gives us the dimensions. And while we're at it, let's calculate the area.