In the previous post in this series, I explained how you can use derivatives to locate maximizing and minimizing values for functions. Now, I will put that knowledge to use in concrete examples to show exactly how this works.

**Example 1: Building a Fence**

Imagine the following situation. You are a farmer, and you want to build a rectangular fence for your cows. You happen to live near a river, and you know your cows would never fall into the river. So, to save money, you decide to use the river as one of the “sides” of the fence. That way, you’ll only have to build three out of the actual fencing material. You’ve already decided that your fencing needs to contain 45,000 square feet of field so that your cows will have enough grass to graze on. Wanting to save money, you ask yourself… *what is the least amount of fencing I have to buy to build this pen for my cows?*

Notice we just used the word *least*. That’s just another word for minimizing something. That means we should be able to use calculus somehow. But how? Well Step 1 would be to clearly set up the thing you’re trying to minimize. As stated, we are trying to minimize the amount of fence material we buy. And what is the amount of fencing material? Well, that would be the total length of the three sides of the pen we have to build. To make this easier to visualize, let’s say the river runs north-south and we are building the pen to the right of the river. Since this is rectangular, two of the sides are going to be the same length (the top and bottom sides) and the third side (right side) could possibly be a different length. We will say the length of the top/bottom sides are feet and the right-hand side has a length of feet. Then the amount of fencing we need to use, which we will call (stands for perimeter), is

Ok, so far so good. We have a formula for . But we have a problem. We can’t do a derivative yet, because there are too many variables. We need to find a way to “get rid of” the … how? Well, let’s try to use the information about the area of the field we already know. The total area is going to be 45000. But the area of a rectangle is also always equal to . So,

We can do something clever now. If we divide both sides by , then we come to see that . That means

That helped! Because now, we have just the one variable, , on the right-hand side (we can also give the new name to make it more clear that the variable is ). So we can take a derivative now! But before we do, we need to stop to remember why we are taking a derivative in the first place. Remember from the previous post that max and min values always occur either at a place where the derivative does not exist or where the derivative is equal to zero. So, once we take the derivative of , our next step needs to be to catalogue these two potential options. First, the derivative of . We can do this using the distributive rule and the polynomial rule for derivatives (which we discussed in part one of “Computing Derivatives”). Using these rules and simplifying a bit,

Now, we need to categorize ‘special points’ where we might find a max or min value. The only place where doesn’t make sense is at 0, but a rectangle with side length zero (remember, is a side length!) doesn’t make any sense, so we can actually just ignore it. In other words, since has to be a positive number anyways, is never even on our radar of possibilities. Having ruled out the ‘does not exist’ option, we need to solve the equation . To simplify a bit, we can multiply both sides by ,

If we divide both sides of this new equation by 2, then we find that we need to solve . This equation has two solutions, and . But remember from earlier, is a length, so only makes any sense (there is no such thing as a negative length). So, we actually only really have one option. But is this option really a minimum like we want it to be? After all, these special points can sometimes be maximums too. How do we know we actually found a minimum?

In the same post where we talked about how to find these special points, we also talked about how to tell which are which by using the ideas of increasing and decreasing. The idea was to pick values that are close to the special point on the left and right to see what looks like there, and use the visual ideas of increasing/decreasing to give us our answer. Using the equation , if we pick a little to the left of 150 we get a negative number, and if we pick a little to the right then we get a positive number. This means that, as we move from left to right, we find ourselves decreasing, leveling off, then increasing. This is the exact pattern of the U shape, which is the key example we used to show what a minimum looks like. So we actually do have a minimum!

What does all of this mean? It means that, as the farmer, you should build the top and bottom fences 150 feet long. But what about the lone third side? Well, we had an equation for that earlier, . If we just plug in , then we find that . So, the third side should be built at 300 feet long. And this is the best way to save your money!

I like this example because, without using calculus, it isn’t exactly obvious how you should be building the fence to save money. So this is a problem that became much, much easier because we learned how to use derivatives. And the even better thing is that we can solve any problem resembling this one by using exactly the same concept, we won’t have to come up with any complicated new ideas for new problems that are similar enough to this one. In fact, in “Homework Problem 1,” I give as practice this same problem without the river to help you out, so where you’ll have to build all 4 sides of the fence rather than just three.

**Example 2: Building a Low-Cost Container**

Imagine you are running a business and you need to design a very special shipping container. This container is special because the top and bottom of this container need to be made out of a more expensive, slightly magnetic material so the boxes can stay connected better when you stack them. The top and bottom materials are going to cost you $5 per square foot, and the cheaper material for the sides costs $2 per square foot. Your boss asks you to design a box with a total storage volume of 100 square feet for the lowest possible cost, and that the top and bottom of this box need to be squares. How do you design such a box?

Before we even start, notice that is a more complicated problem than the fence problem from earlier. We are going to have to think a little bit more carefully, particularly at the very beginning. Firstly, notice where the word lowest shows up – it refers to the cost. Because our process of minimizing things requires that we take a derivative, we need to write down function that tells us about the cost. We will eventually call this function .

But how do we write down ? Well, we need to slow down a bit. This function counts the total cost of building a box. When we build this box, there are six sides, so is the sum of the cost of the bottom, the cost of the top, and the cost of each of the four sides. Well then, if we could write down all those numbers, we’d have an equation for ! Here is where we need to pause and remember what our boss asked us to do. He told us that the top and bottom must be squares. So, if those squares have a side length of feet, then the area of the top is square feet, and the area of the bottom is also square feet. We also know that the expensive material for the top and bottom costs us $5 per square foot. This means that the top will cost us dollars and the bottom will also cost us dollars. Now, we need the costs for the four sides, which go for the cheaper rate of $2 per square foot. We can notice that the four sides have a shared base with the squares, but have a height that we can’t determine from the squares. We can call this height . So, the area of each of the four sides panels of the box is . Since these sides cost two dollars per square foot, each panel costs dollars to build. Since there are four of these side panels, then the cost for the sides is dollars.

We now have all the information we need for an initial cost formula. By adding up the dollar total for the top, bottom, and sides, we can conclude that

.

Now what? We can’t exactly take a derivative yet, there are too many variables. How do we get out of that problem? We again turn to what our boss asked us to do. We were asked to build a box with a total volume of 100 square feet. Well, we need to remember the volume formula for a box,

.

The base and the width are both , and and the height is . So, the volume formula tells us that our boss is asking that we make sure . By dividing both sides by , we can conclude that

Because we know this new expression for , we can use that expression in our formula for :

We are in familiar territory now! We have a single function and we need to find its minimum value. This is where we use the same process from earlier – we take a derivative, find zeros, and carry on.

The derivative is a fairly routine one using the power rule, we have

.

We want to solve the equation . By multiplying both sides by , we see that . By adding 8000 to both sides, we arrive at . By dividing both sides by 20, we see that . When you look at this closely, only one number really makes sense, because there is only one positive real number whose cube is 400. So, we see that is probably our desired answer. But, how do we know this? The answer is, as before we need to check the slopes to the ‘left’ and ‘right’ of the key point. When you do this (take some time to do it yourself if you want practice) we find that leading up to the point the graph of slopes downward, then after the key point it slopes upward. This is the characteristic ‘U’ pattern, which tells us we’ve found the minimum!

So, you can tell your boss the base needs to have a side length . I’ve on purpose chosen a problem with a rather strange number as the answer to make a brief point – calculus can solve a lot of not very obvious problems with some not obvious answers. Before we close out this post, I’ll solve one more problem – this time one with a maximum.

**Example 3: The Apple Orchard**

You run an apple orchard, and naturally you want to produce as many apples as you can. You’ve done some research and experiments with your field and the variety of apple tree that you grow. You’ve notice over time that when you plant trees too close together, they crowd each other out and you get fewer apples per tree. But, you also realize that more trees mean more apples. You’ve got on the one hand an increase in apples, and on the other hand a decrease in apples. You are trying to figure out what the perfect balance is between planting as many trees as you can without causing too much overcrowding. Your research has led you to conclude the if the number of trees per acre of land increases by one, then each tree in that acre gives you two fewer apples than it did before. Your field currently has 10 trees per acre and each tree grows 35 apples. Now, how should you change your apple orchard to give you the most apples possible?

As with the previous two examples, we have to start by reminding ourselves of exactly what we are doing. We want the largest number of apples, so mathematically speaking, we want a formula that counts the number of apples we get every harvest, and we want to maximize that formula.

Well, what is a good formula for ? Well, if we know each tree gives us apples every harvest and that we have trees per acre, then . This tells us how to count the number of apples. However, we can’t take the derivative of yet, there are still too many variables. We now must use the time we spent in research about our apple trees. We know that when , . We also know that if we add one to , then goes down by two. We can actually think of this as the slope of a linear equation. To see how, note that in the equation , then if goes up by one, then goes down by two. This means that something like is true… but that isn’t quite right, because doesn’t work with that equation. If we were to plug those in, we’d get , which is surely wrong. We have to ‘shift’ the equation up to make it work, which in this case involves adding stuff onto the right side until the -20 gets all the way up to 35 where we need it. When we make this correction, we end up with the correct equation .

We can now go back to the real problem of maximizing . We know both that and . By using this second equation to modify the first one,

.

Therefore, we’ve found that . This is a one-variable equation for , so we are now at the same point we reached in the other two examples. We proceed in the same way, by finding and solving for in . The derivative of is , and the solution to is . So, in theory, this is our answer. We should be planting about $\dfrac{55}{4} = 11.25$ trees per acre. Since we are currently only planting 10 per acre, we should plant a couple more trees.

**Conclusion**

This would be a really good time to pause and reflect on what calculus has enabled us to do. We’ve just solved a variety of problems that asked us to find best-case scenarios for many different sorts of things. This is one of the most important things that calculus can do. There is another incredibly important application of calculus to physics, which we shall go into later. For now, we can appreciate what these new mathematical tricks have enabled us to do.

**A Practice Problem**

** Problem:** This is a similar problem to Example 1. If you had to build all four sides of the fence instead of just three, prove that the pen you save the most money with will be a square. In other words, if we use the same way as in Example 1. (

*Hint:*

*What is the new version of the equation ?*)