 So now we have all the tools we need to solve the optimization problem. As it turns out, the calculus is the easy part of the problem. Given a function f of x that's differentiable over some interval between a and b, the local extreme values will occur either at the end points, x equals a and x equals b, or at the critical points, the places where the derivative is 0 or fails to exist. The end points are guaranteed to be local maximum or minimum values. The critical points might be local maximum or minimum values, they must be checked, and this is done in one of two ways, either using the first derivative test, which always works, or the second derivative test, which always involves more works and sometimes tells us nothing. Now it turns out that the calculus is the easy part because once you have the function, the calculus itself is easy. So why are optimization problems hard? The problem is finding the function. There is no formula or algorithm that you can use to construct the function you need to optimize. Instead, you will need to rely on what you know about algebra, geometry, life, the universe, and everything. Now remember, one of the worst ways to try and learn mathematics is to study examples. And the problem is that the real universe has so many more different problems that it is impossible to show you an example of every single type of problem you will ever run into. Where examples are useful is they give you some idea of the type of approaches that you might want to use. So consider this problem. Now we want to maximize A of x, where A of x is the area of the field. And this is a geometry problem, it helps to draw a picture. So in order to construct the function, I'll need to tell you what x is. So since this is going to be some sort of rectangular field, maybe I'll let x be the length of the side of the field that's perpendicular to the wall. No reason for that, it's just the first side of the field I happen to draw, so we'll call it x. What I'd like to do is I'd like to find a formula that gives you the area of the field once you know the value of x. And so using an actual value of x will help us to construct the function. So suppose x equals 10. Now we'll ask ourselves, self, what do you know? And the first thing we know is that the opposite side is also going to be 10 meters in length. Now because I have 500 meters of fencing, I've just used up 10 plus 10, I've used up 20 meters of fencing, and that means that this last part can use up the remaining 480 meters. And so the field is going to have dimensions 10 by 480 meters, so the area is going to be 4800 square meters. Now let's consider what we did there. The area is going to be length times width. So this length is x, and the width is whatever is left over. And I got that amount by subtracting twice the length from 500. And so this gives me an area formula of x times 500 minus 2x. And so now I have my function, a of x, that gives me the area of the field. Because it's possible that our extreme values might occur at the endpoints, it's extremely useful to have some idea of where the function is relevant. And since we only have 500 meters of fencing, we can't make any side of the field longer than 500 meters. And so that tells us that x has to be between 0 and 500. Actually, if we think about it, we can find an even stricter bound on x, but we don't need it for this problem. So let's see what we have so far. We are guaranteed we will have local extreme values at the endpoints, at 0 and at 500. But let's think about that. If x equals 0, the area of the field is 0. And if x equals 500, the area of the field is negative something or other. And since we've already found a field with an area of 4800 square meters, neither one of these is going to give us a maximum area. We know that x equals 0 won't give us a maximum area because we can already exceed the area that we would get. And we know that x equals 500 won't give us a maximum area for the same reason. And that means we have to do some calculus. Well, that's probably a good thing because we're taking a calculus course and it would be a shame to think that we don't actually need calculus for anything. So let's see if we can find the critical points. For that, we'll need the derivative. The critical points are going to occur when the derivative is 0 or undefined. And since the derivative is a polynomial, it's defined everywhere, so we only have to worry about where the derivative is 0. And we get a critical point at x equals 125. And let's do our first derivative test. If x is less than 125, the derivative is positive. And if x is more than 125, the derivative is negative. And so that means A of x is increasing until x equals 125 and decreasing after 125. So x equals 125 corresponds to a local maximum value. And finally, we want to make sure we actually answered the question that was asked. What are the dimensions? And here we find that x equals 125. x is the length of the side of the field perpendicular to the wall. So that means the other side is going to be 250 meters in length.