1 00:00:00,012 --> 00:00:02,200 [music]. Let's pretend that you're a shepherd and 2 00:00:02,200 --> 00:00:09,585 you want to build a fence for your sheep. Specifically, let's say that you've got 52 3 00:00:09,585 --> 00:00:14,299 meters of fencing. And you're committed to building a 4 00:00:14,299 --> 00:00:17,216 rectangular pen for your sheep next to your barn. 5 00:00:17,216 --> 00:00:20,927 So how big of a sheep pen can you build with that much fencing? 6 00:00:20,927 --> 00:00:29,547 Process is a standard one, it's got five steps. 7 00:00:29,547 --> 00:00:33,693 The first thing I'm going to do is to draw a picture of the situation. 8 00:00:33,693 --> 00:00:37,791 With a picture in hand and everything labelled with variables. 9 00:00:37,791 --> 00:00:41,691 I can write down the thing I'm tying to optimize, the goal. 10 00:00:41,691 --> 00:00:45,349 With that, I can also write down the constraints, right? 11 00:00:45,349 --> 00:00:48,808 Not every combination of variables maybe make sense. 12 00:00:48,808 --> 00:00:51,541 Maybe some domain issues to consider as well. 13 00:00:51,541 --> 00:00:55,480 Then in step four, I'm going to solve my goal for a single variable. 14 00:00:55,480 --> 00:00:59,485 And once I get a function of a single variable, I can apply calculus. 15 00:00:59,485 --> 00:01:02,261 Right? This last step really means to say 16 00:01:02,261 --> 00:01:08,071 differentiate the function of a single variable, find the critical points, figure 17 00:01:08,071 --> 00:01:11,376 out where the largest and smallest values are. 18 00:01:11,376 --> 00:01:15,567 That's my five-step process. First, I draw a picture, so let's 19 00:01:15,567 --> 00:01:18,625 rearrange this in a slightly nicer picture. 20 00:01:18,625 --> 00:01:24,930 I'll build my little sheep pen here. Here's my rectangular pen for my sheep 21 00:01:24,930 --> 00:01:30,903 that I built next to my barn. And I'd better label the side lengths 22 00:01:30,903 --> 00:01:34,760 here. The top and bottom will be x meters long 23 00:01:34,760 --> 00:01:40,850 and this side here will be y meters long. Now, what is it that I'm trying to 24 00:01:40,850 --> 00:01:45,011 maximize? Well, I want the fenced in area here to be 25 00:01:45,011 --> 00:01:50,133 as big as possible. So the thing I'm trying to maximize is the 26 00:01:50,133 --> 00:01:53,856 area of this pen and that area is x times y. 27 00:01:53,856 --> 00:01:59,131 Now at this point, you probably think, well I know how to maximize that function. 28 00:01:59,131 --> 00:02:02,175 I'll just pick x and y to be absolutely enormous. 29 00:02:02,175 --> 00:02:07,557 And if an enormous number is multiplied by an enormous number, if I multiply x times 30 00:02:07,557 --> 00:02:12,168 y, the output will be enormous. Right, I'll build a sheep pen the size of 31 00:02:12,168 --> 00:02:15,355 the Milky Way. But there's a constraint. 32 00:02:15,355 --> 00:02:21,341 Yeah, I mean, I can't simply build this fence as big as I like, because I've only 33 00:02:21,341 --> 00:02:24,668 got 52 meters of yellow fence to begin with. 34 00:02:24,668 --> 00:02:30,869 So the constraint is that the length of this fence, which is 2x plus y is 52. 35 00:02:30,869 --> 00:02:35,726 I'm saying equal 52, because I might as well use all of the fence that I have to 36 00:02:35,726 --> 00:02:39,443 build this sheep pen. Another way to say that, is that this is 37 00:02:39,443 --> 00:02:42,206 what I'm trying to do. I'm trying to maximize this quantity, the 38 00:02:42,206 --> 00:02:44,953 area of the pen, subject to the constraint that 2x plus y, the length of fence in my 39 00:02:44,953 --> 00:02:47,483 pane is 52 meters and I should say that x and y are nonnegative quantities. 40 00:02:47,483 --> 00:02:58,900 It doesn't make any sense to make one side of my sheet pane negative. 41 00:02:58,900 --> 00:03:04,538 Now, I use to constraint to solve the thing I'm trying to optimize for a single 42 00:03:04,538 --> 00:03:05,657 variable. Okay. 43 00:03:05,657 --> 00:03:09,023 So I'm going to solve this for a single variable. 44 00:03:09,023 --> 00:03:15,544 I've got that 2x plus y is 52, so I could solve for y, y is 52 minus 2x. 45 00:03:15,544 --> 00:03:23,238 The quantity that I'm trying to maximize is x times y, but if y is 52 minus 2x, 46 00:03:23,238 --> 00:03:31,298 then, I'm really trying to maximize x times 52 minus 2x, because this quantity 47 00:03:31,298 --> 00:03:34,220 is y. So this Is the function of a single 48 00:03:34,220 --> 00:03:38,196 variable that I'm trying to maximize. Okay, fantastic. 49 00:03:38,196 --> 00:03:42,446 Now, I've got a function of one variable so I can apply calculus. 50 00:03:42,446 --> 00:03:46,946 I can differentiate this thing and search for the critical points. 51 00:03:46,946 --> 00:03:52,042 So let's call this a function f. So f of x is x times 52 minus 2 x, that 52 00:03:52,042 --> 00:03:57,680 dot is multiplication. I could distribute this and write f is 52 53 00:03:57,680 --> 00:04:03,022 times x minus 2 x squared. Now, I can calculate the derivative, the 54 00:04:03,022 --> 00:04:08,786 derivative of f is the derivative of 52x minus the derivative of 2x squared. 55 00:04:08,786 --> 00:04:13,162 The derivative of 52x is just 52. The derivative of 2x squared is 4x. 56 00:04:13,162 --> 00:04:18,098 So, the derivative of f is 52 minus 4x. The critical points are places where the 57 00:04:18,098 --> 00:04:22,712 function's derivative vanishes or the function is not differentiable. 58 00:04:22,712 --> 00:04:26,842 This function is polynomial, so it's differentiable everywhere. 59 00:04:26,842 --> 00:04:31,622 The only thing I have to worry about then, for critical points, is when this 60 00:04:31,622 --> 00:04:36,304 derivative is equal to zero. So for what values of x is that equal to 61 00:04:36,304 --> 00:04:39,687 zero? Well, the only place where this derivative 62 00:04:39,687 --> 00:04:45,161 is equal to zero is when x equals 13. I should also remember that I'm maximizing 63 00:04:45,161 --> 00:04:51,044 this function subject to this constraint and there were also some domain issues. 64 00:04:51,044 --> 00:04:56,508 I don't want x to be negative. And, in order to ensure that y is 65 00:04:56,508 --> 00:05:04,373 nonnegative, if 2x plus y is 52, then x can't be negative, but x also can't be 66 00:05:04,373 --> 00:05:09,121 bigger than 26. So, what's the situation here? 67 00:05:09,121 --> 00:05:14,306 Well, I can summarize it. My critical points. 68 00:05:14,306 --> 00:05:19,922 Well, there's really only one critical point and the critical point is when x is 69 00:05:19,922 --> 00:05:23,881 equal to 13. Then I've also got some endpoints, right? 70 00:05:23,881 --> 00:05:29,446 The endpoints to consider are when x is equal to 0 or when x is equal to 26. 71 00:05:29,446 --> 00:05:34,324 So these are the three points to check. Now, I just have to figure out which of 72 00:05:34,324 --> 00:05:37,331 these values results in the best fence. All right. 73 00:05:37,331 --> 00:05:41,867 So these are the three points that I should check, so I'll make a little table 74 00:05:41,867 --> 00:05:44,847 here. The x values that I'll check are 0, 26, 75 00:05:44,847 --> 00:05:48,439 and 13. And I'll figure out what the corresponding 76 00:05:48,439 --> 00:05:53,513 y value is and then I'll figure out x times y, which will be the area of the 77 00:05:53,513 --> 00:05:58,171 fenced in region if I use these as my side lengths for my sheep pen. 78 00:05:58,171 --> 00:06:03,070 So, let's see. If x is equal to 0 and I satisfy this 79 00:06:03,070 --> 00:06:10,004 constraint that 2x plus y is 52. If x is equal to zero, then y must be 52. 80 00:06:10,004 --> 00:06:14,832 And if x is 26, then 2 times 26 plus what gives me 52. 81 00:06:14,832 --> 00:06:20,844 Well, then y is equal to 0. And if x is 13, then 2 times 13 is 26, 82 00:06:20,844 --> 00:06:24,964 plus what gives me 52? Well, then y must be 26. 83 00:06:24,964 --> 00:06:31,966 Now, in each of these three cases, I can figure out what the area of the resulting 84 00:06:31,966 --> 00:06:36,900 sheep pen would be. 0 times 52 is just 0 and 26 times 0 is 85 00:06:36,900 --> 00:06:39,810 also 0. 13 times 26 is 338. 86 00:06:39,810 --> 00:06:44,175 So here, this is the best choice for my sheep pen. 87 00:06:44,175 --> 00:06:50,879 This isn't just a great calculation. I hope that, intuitively, this method 88 00:06:50,879 --> 00:06:55,955 really makes sense. I mean, look, if x is equal to 0, that 89 00:06:55,955 --> 00:07:03,203 means I'm building my sheep pen just entirely up against the side of the barn. 90 00:07:03,204 --> 00:07:07,941 And if y equals 0, well, that means I'm building my sheep pen like this. 91 00:07:07,941 --> 00:07:12,885 I'm just building fence that goes over and then fence that comes right back. 92 00:07:12,885 --> 00:07:16,760 Again, there's no area that this so-called pen is enclosing. 93 00:07:16,760 --> 00:07:22,373 That x equals 13 and y equals 26 is the best choice for our sheep is clear if you 94 00:07:22,373 --> 00:07:27,248 think about how wiggling x would affect the area of the sheep pen. 95 00:07:27,248 --> 00:07:32,122 So here is the best solution, right, to have x be 13 and y be 26. 96 00:07:32,122 --> 00:07:36,863 What if I were to push this fence in just a little bit, all right? 97 00:07:36,863 --> 00:07:42,966 I'd make the x values a little bit smaller and then make the y value a little bit 98 00:07:42,966 --> 00:07:47,059 bigger to compensate, right? Maybe x is 12 and y is 28. 99 00:07:47,059 --> 00:07:51,163 Why is this worse? Well, think about what happens when I 100 00:07:51,163 --> 00:07:57,308 change from x equals 13 to x equals 12. I give up this region here and that's 26 101 00:07:57,308 --> 00:08:03,957 square meters of fenced in region. I gain this region up here and this region 102 00:08:03,957 --> 00:08:10,383 up here, but this region up here is 12 square meters and this region here is 12 103 00:08:10,383 --> 00:08:15,161 square meters. So I'm giving up 26 square meters to gain 104 00:08:15,161 --> 00:08:18,356 24 square meters. That's a bad deal. 105 00:08:18,357 --> 00:08:20,986 This is really the whole crux of the matter. 106 00:08:20,986 --> 00:08:23,532 Right? When you found the best thing, small 107 00:08:23,532 --> 00:08:26,361 changes to the best thing, don't make it better. 108 00:08:26,361 --> 00:08:30,911 But if you hadn't found the best thing, then you could make a small change that 109 00:08:30,911 --> 00:08:34,041 would make it better. That's the whole idea, right? 110 00:08:34,041 --> 00:08:46,743 That understanding how functions change can be used to understand the best output 111 00:08:46,743 --> 00:08:49,213 for a function.