1 00:00:00,000 --> 00:00:07,200 2 00:00:07,200 --> 00:00:07,660 JOEL LEWIS: Hi. 3 00:00:07,660 --> 00:00:09,230 Welcome back to recitation. 4 00:00:09,230 --> 00:00:10,950 In lecture, you've been learning about using the 5 00:00:10,950 --> 00:00:13,970 method of Lagrange multipliers to optimize functions of 6 00:00:13,970 --> 00:00:15,950 several variables given a constraint. 7 00:00:15,950 --> 00:00:19,630 So here's a problem that you can practice this method on. 8 00:00:19,630 --> 00:00:24,290 So I've got a function f of x, y, z equals x squared plus x 9 00:00:24,290 --> 00:00:26,970 plus 2y squared plus 3z squared. 10 00:00:26,970 --> 00:00:29,490 And what I'd like you to do is find the maximum and minimum 11 00:00:29,490 --> 00:00:32,850 values that this function takes as the point x, y, z 12 00:00:32,850 --> 00:00:36,190 moves around the unit sphere x squared plus y squared plus z 13 00:00:36,190 --> 00:00:37,720 squared equals 1. 14 00:00:37,720 --> 00:00:40,630 So to optimize this function given the constraint x squared 15 00:00:40,630 --> 00:00:42,435 plus y squared plus z squared equals 1. 16 00:00:42,435 --> 00:00:44,890 So why don't you pause the video, take some time to work 17 00:00:44,890 --> 00:00:46,970 that out, come back, and we can work it out together. 18 00:00:46,970 --> 00:00:55,410 19 00:00:55,410 --> 00:00:57,660 Hopefully you had some luck working on this problem. 20 00:00:57,660 --> 00:00:58,910 Let's have a go at it. 21 00:00:58,910 --> 00:01:02,100 So remember that the method of Lagrange multipliers-- 22 00:01:02,100 --> 00:01:04,690 in order to apply it-- what it says is that when you have a 23 00:01:04,690 --> 00:01:09,600 function being optimized on some constraint condition, 24 00:01:09,600 --> 00:01:12,520 what you do to find the points where the function could be 25 00:01:12,520 --> 00:01:16,870 maximum or minimum is that first you look for points 26 00:01:16,870 --> 00:01:20,560 where the gradient of your objective function is parallel 27 00:01:20,560 --> 00:01:23,380 to the gradient of your constraint function. 28 00:01:23,380 --> 00:01:26,580 So what that means is you take the partial derivatives fx, 29 00:01:26,580 --> 00:01:30,770 fy, fz, and you say fx has to be equal to lambda times gx, 30 00:01:30,770 --> 00:01:34,030 fy has to be equal to lambda times gy, and fz has to be 31 00:01:34,030 --> 00:01:37,000 equal to lambda times gz, for some lambda. 32 00:01:37,000 --> 00:01:39,190 And then you solve that system together with 33 00:01:39,190 --> 00:01:40,720 the constraint equation. 34 00:01:40,720 --> 00:01:44,960 And so the points that are the solutions of that system of 35 00:01:44,960 --> 00:01:48,340 equations, those points are your points that you have to 36 00:01:48,340 --> 00:01:50,570 check for whether they're the maximum or the minimum. 37 00:01:50,570 --> 00:01:53,760 And also, sometimes you have some boundary to your region 38 00:01:53,760 --> 00:01:54,940 and you have to check that as well. 39 00:01:54,940 --> 00:01:57,850 So in this case, the sphere doesn't have boundary. 40 00:01:57,850 --> 00:01:58,670 Right? 41 00:01:58,670 --> 00:02:00,710 So we don't have any boundary conditions to check. 42 00:02:00,710 --> 00:02:02,770 So we're going to have a really straightforward problem 43 00:02:02,770 --> 00:02:05,320 to solve where we just have to look at the partial 44 00:02:05,320 --> 00:02:05,970 derivatives. 45 00:02:05,970 --> 00:02:08,100 So let's write down that system of equations that we 46 00:02:08,100 --> 00:02:09,070 have to solve. 47 00:02:09,070 --> 00:02:12,290 So the partial derivative of f with respect to x is going to 48 00:02:12,290 --> 00:02:14,810 be 2x plus 1. 49 00:02:14,810 --> 00:02:19,090 So we have to solve the system 2x plus 1 equals. 50 00:02:19,090 --> 00:02:23,457 And the partial derivative of our constraint with respect to 51 00:02:23,457 --> 00:02:28,660 x is 2x, so 2x plus 1 has to equal lambda times 2x. 52 00:02:28,660 --> 00:02:31,700 That's what we get from the x-partial derivatives. 53 00:02:31,700 --> 00:02:33,760 How about from the y-partial derivatives? 54 00:02:33,760 --> 00:02:39,550 The y-partial derivative of f is going to be 4y. 55 00:02:39,550 --> 00:02:42,580 So that has to be equal to lambda and the y-partial 56 00:02:42,580 --> 00:02:46,720 derivative of the constraint equation which is 2y. 57 00:02:46,720 --> 00:02:49,750 58 00:02:49,750 --> 00:02:52,710 And the z-partial derivative of f is 6z. 59 00:02:52,710 --> 00:02:56,110 60 00:02:56,110 --> 00:03:00,615 So 6z has to be equal to lambda times, well the 61 00:03:00,615 --> 00:03:02,530 z-partial derivative of the constraint 62 00:03:02,530 --> 00:03:03,780 function which is 2z. 63 00:03:03,780 --> 00:03:06,150 64 00:03:06,150 --> 00:03:11,340 And we have the last equation x squared plus y squared plus 65 00:03:11,340 --> 00:03:13,780 z squared equals 1. 66 00:03:13,780 --> 00:03:17,150 So we get four equations in our variables x, y, and z, 67 00:03:17,150 --> 00:03:19,750 plus this new parameter lambda that we introduced. 68 00:03:19,750 --> 00:03:22,810 And we want to solve these to find the points x, y, and z at 69 00:03:22,810 --> 00:03:25,240 which these equations are all satisfied. 70 00:03:25,240 --> 00:03:28,260 And then, once we get those points, we have to test them 71 00:03:28,260 --> 00:03:29,770 to see whether they are the maximum or 72 00:03:29,770 --> 00:03:33,000 the minimum or neither. 73 00:03:33,000 --> 00:03:33,960 So OK. 74 00:03:33,960 --> 00:03:35,350 So we have this system of equations. 75 00:03:35,350 --> 00:03:36,720 Now, this is a little bit complicated. 76 00:03:36,720 --> 00:03:39,500 It's not a system of linear equations. 77 00:03:39,500 --> 00:03:41,880 So we need to think about ways that we can solve it. 78 00:03:41,880 --> 00:03:44,560 And one thing that I think we can do here, is if you look at 79 00:03:44,560 --> 00:03:47,650 the second and third equations, you see that in the 80 00:03:47,650 --> 00:03:51,310 second equation, everything has a factor of y in it. 81 00:03:51,310 --> 00:03:55,980 So either y is equal to 0, or we can divide by it. 82 00:03:55,980 --> 00:04:04,580 So from the second equation, we have that either y is equal 83 00:04:04,580 --> 00:04:11,420 to 0, or we can divide by y, in which case we get lambda is 84 00:04:11,420 --> 00:04:12,590 equal to 2. 85 00:04:12,590 --> 00:04:15,360 Similarly, from the third equation, we have that either 86 00:04:15,360 --> 00:04:19,310 z is equal to 0, or we can divide by z and we get lambda 87 00:04:19,310 --> 00:04:19,772 is equal to 3. 88 00:04:19,772 --> 00:04:20,124 So from the third equation we have z equals 0 or 89 00:04:20,124 --> 00:04:21,374 lambda equals 3. 90 00:04:21,374 --> 00:04:31,750 91 00:04:31,750 --> 00:04:34,570 So now we have a bunch of possibilities, right? 92 00:04:34,570 --> 00:04:39,720 So either we have y equals z equals 0, or we have y equals 93 00:04:39,720 --> 00:04:44,370 0 and lambda equals 3, or we have lambda equals 2 94 00:04:44,370 --> 00:04:45,980 and z equals 0. 95 00:04:45,980 --> 00:04:49,060 Or well, the other possibility would be lambda equals 2 and 96 00:04:49,060 --> 00:04:50,800 lambda equals 3, but that can't happen. 97 00:04:50,800 --> 00:04:52,490 So we have three possibilities. 98 00:04:52,490 --> 00:04:54,570 Three different ways that this could be satisfied. 99 00:04:54,570 --> 00:04:57,840 So let's go over here and write down what those 100 00:04:57,840 --> 00:04:58,750 possibilities are. 101 00:04:58,750 --> 00:05:00,820 So case one, or maybe I'll call it case a. 102 00:05:00,820 --> 00:05:05,951 So the case a is when y is equal to z is equal to 0. 103 00:05:05,951 --> 00:05:07,201 So when y is equal to z is equal to 0-- 104 00:05:07,201 --> 00:05:09,210 105 00:05:09,210 --> 00:05:11,360 OK, we need to find x's still. 106 00:05:11,360 --> 00:05:13,690 So let's look back at our equations. 107 00:05:13,690 --> 00:05:16,810 And when y is equal to z is equal to 0, well we can solve 108 00:05:16,810 --> 00:05:18,670 our constraint equation for x. 109 00:05:18,670 --> 00:05:22,220 When y equals z equals 0, we have that x squared equals 1. 110 00:05:22,220 --> 00:05:23,460 So there are two possibilities. 111 00:05:23,460 --> 00:05:27,410 The point 1, 0, 0, and the point minus 1, 0, 0. 112 00:05:27,410 --> 00:05:34,080 So this gives us, in this case, we have x equals 1 or x 113 00:05:34,080 --> 00:05:36,160 equals minus 1. 114 00:05:36,160 --> 00:05:42,030 So that gives us the points 1, 0, 0, and minus 1, 0, 0 that 115 00:05:42,030 --> 00:05:43,960 we're going to have to check at the end. 116 00:05:43,960 --> 00:05:44,270 All right. 117 00:05:44,270 --> 00:05:51,080 So the second case is we could have y equal to 0 and lambda 118 00:05:51,080 --> 00:05:52,880 equal to 3. 119 00:05:52,880 --> 00:05:56,240 So in this case, let's go back to our equations again. 120 00:05:56,240 --> 00:06:02,020 So from lambda equals 3, we have in our first equation 121 00:06:02,020 --> 00:06:05,250 that 2x plus 1 equals 6x. 122 00:06:05,250 --> 00:06:09,180 So 1 equals 4x or x equals 1/4. 123 00:06:09,180 --> 00:06:13,600 So this implies over here that x equals 1/4. 124 00:06:13,600 --> 00:06:16,510 And now, we still need to find z. 125 00:06:16,510 --> 00:06:21,420 So if we go back to our constraint equation here, we 126 00:06:21,420 --> 00:06:25,400 have that x is a quarter and y is 0. 127 00:06:25,400 --> 00:06:29,290 So that means 1/16 plus z squared equals 1. 128 00:06:29,290 --> 00:06:35,170 So z has to be the square root of 15/16, plus or minus. 129 00:06:35,170 --> 00:06:38,760 And z is equal to plus or minus, so that we can also 130 00:06:38,760 --> 00:06:41,470 write that as the square root of 15 over 4. 131 00:06:41,470 --> 00:06:43,780 So this also gives us two points to check. 132 00:06:43,780 --> 00:06:50,930 The points are 1/4, 0, the square root of 15 over 4. 133 00:06:50,930 --> 00:06:58,520 And 1/4, 0, minus square root of 15 over 4. 134 00:06:58,520 --> 00:07:01,250 And finally, we have our third case. 135 00:07:01,250 --> 00:07:07,420 So our third case is when lambda is equal to 2 and z is 136 00:07:07,420 --> 00:07:09,300 equal to 0. 137 00:07:09,300 --> 00:07:12,810 So again, let's go back over to our equation. 138 00:07:12,810 --> 00:07:16,610 So when lambda equals 2 in the first equation, we have 2x 139 00:07:16,610 --> 00:07:18,690 plus 1 equals 4x. 140 00:07:18,690 --> 00:07:21,930 So 2x equals 1 or x is 1/2. 141 00:07:21,930 --> 00:07:24,940 So this gives us x equals a half. 142 00:07:24,940 --> 00:07:29,050 And now if you take z equals 0 and x equals 1/2, we can take 143 00:07:29,050 --> 00:07:30,810 that down to our constraint equation. 144 00:07:30,810 --> 00:07:34,620 And we get a quarter plus y squared equals 1, so y is a 145 00:07:34,620 --> 00:07:36,820 square root of 3/4. 146 00:07:36,820 --> 00:07:42,120 So y equals plus or minus square root of 3 over 2. 147 00:07:42,120 --> 00:07:43,820 And this gives us two points. 148 00:07:43,820 --> 00:07:50,230 1/2, square root of 3 over 2, 0. 149 00:07:50,230 --> 00:07:56,580 And 1/2, minus square root of 3 over 2, 0. 150 00:07:56,580 --> 00:07:57,980 Those were our three cases. 151 00:07:57,980 --> 00:07:59,160 We've solved each of them. 152 00:07:59,160 --> 00:08:03,190 We've solved each of them all the way down to finding the 153 00:08:03,190 --> 00:08:05,280 points that they lead to. 154 00:08:05,280 --> 00:08:07,850 Now remember, we said already that there's no boundary to 155 00:08:07,850 --> 00:08:08,400 this region. 156 00:08:08,400 --> 00:08:10,670 It's just the sphere. 157 00:08:10,670 --> 00:08:12,930 It has no edges. 158 00:08:12,930 --> 00:08:14,670 So these are the only points we have to check. 159 00:08:14,670 --> 00:08:16,170 We have to check these six points. 160 00:08:16,170 --> 00:08:17,190 What do we have to check them for? 161 00:08:17,190 --> 00:08:20,400 Well, we have to look at the value of f at each of these 162 00:08:20,400 --> 00:08:22,560 six points. 163 00:08:22,560 --> 00:08:25,520 And we want to figure out where f is maximized and where 164 00:08:25,520 --> 00:08:28,530 f is minimized, and these six points are the only points 165 00:08:28,530 --> 00:08:30,300 where that could happen, where f could be 166 00:08:30,300 --> 00:08:32,020 maximized or minimized. 167 00:08:32,020 --> 00:08:34,490 So we just have to evaluate our objective function f at 168 00:08:34,490 --> 00:08:36,960 these six points and find the largest value and 169 00:08:36,960 --> 00:08:38,430 the smallest value. 170 00:08:38,430 --> 00:08:39,340 So let's do that. 171 00:08:39,340 --> 00:08:41,490 So our objective function, remember, it's all the way 172 00:08:41,490 --> 00:08:42,880 back over here. 173 00:08:42,880 --> 00:08:46,010 It's this function x squared plus x plus 2y 174 00:08:46,010 --> 00:08:49,210 squared plus 3z squared. 175 00:08:49,210 --> 00:08:49,570 OK. 176 00:08:49,570 --> 00:08:52,850 So let's look at the value of that function at these point. 177 00:08:52,850 --> 00:08:56,840 So x squared plus x plus 2y squared plus 3z squared at the 178 00:08:56,840 --> 00:08:59,710 point 1, 0, that's just equal to 2. 179 00:08:59,710 --> 00:09:02,540 So I'm going to write the function values just off to 180 00:09:02,540 --> 00:09:06,980 the side of the points here. 181 00:09:06,980 --> 00:09:08,700 So this gives me the value 2. 182 00:09:08,700 --> 00:09:10,450 And I'm going to circle them. 183 00:09:10,450 --> 00:09:13,730 So the point 1, 0, 0 gives me the value 2. 184 00:09:13,730 --> 00:09:15,970 The point minus 1, 0, 0-- 185 00:09:15,970 --> 00:09:20,910 so that's x squared is one, plus x is minus 1, so that's 1 186 00:09:20,910 --> 00:09:24,750 minus 1 is 0, and then the y and z terms are both 0. 187 00:09:24,750 --> 00:09:29,230 So at the point minus 1, 0, 0, the function value is 0. 188 00:09:29,230 --> 00:09:32,360 I'm going to circle that. 189 00:09:32,360 --> 00:09:32,970 Oh boy. 190 00:09:32,970 --> 00:09:35,240 OK, so at these points-- 191 00:09:35,240 --> 00:09:40,920 at the point 1/4, 0, square root of 15 over 4, and 1/4, 0, 192 00:09:40,920 --> 00:09:43,350 minus square root of 15 over 4-- 193 00:09:43,350 --> 00:09:45,520 I'm going to cheat and look at what I wrote down already. 194 00:09:45,520 --> 00:09:49,530 So you could do the arithmetic yourself, but I think it's not 195 00:09:49,530 --> 00:09:53,480 that hard to work out that in both of these cases, the 196 00:09:53,480 --> 00:09:57,510 function value that you get out is 25 over 8. 197 00:09:57,510 --> 00:10:00,880 I'm not going to do the arithmetic right now. 198 00:10:00,880 --> 00:10:03,520 199 00:10:03,520 --> 00:10:05,830 But you can double-check that for yourself. 200 00:10:05,830 --> 00:10:09,600 And at these last two points-- the points 1/2, root 3 over 2, 201 00:10:09,600 --> 00:10:13,180 0, and 1/2, minus root 3 over 2, 0-- 202 00:10:13,180 --> 00:10:15,800 203 00:10:15,800 --> 00:10:18,120 the function has the same value at both of those points. 204 00:10:18,120 --> 00:10:19,500 That value is 9/4. 205 00:10:19,500 --> 00:10:23,250 206 00:10:23,250 --> 00:10:26,000 Yeah, so 25 over 8 was the value at both of these points, 207 00:10:26,000 --> 00:10:28,740 and 9/4 is the value of both of these points. 208 00:10:28,740 --> 00:10:32,080 So now, to find the maximum value of the function and the 209 00:10:32,080 --> 00:10:34,340 minimum value of the function, we just look at the values 210 00:10:34,340 --> 00:10:36,070 that we got and say, which of these is biggest and which of 211 00:10:36,070 --> 00:10:36,685 these is smallest? 212 00:10:36,685 --> 00:10:42,610 And in our case, it's easy to see that 0 is the minimum. 213 00:10:42,610 --> 00:10:43,800 You know, all the other values are 214 00:10:43,800 --> 00:10:45,600 positive, so 0 is the minimum. 215 00:10:45,600 --> 00:10:56,740 So our minimum value of f is 0 at the point minus 1, 0, 0. 216 00:10:56,740 --> 00:11:01,480 And if you just compare the values 2 and 25/8 and 9/4, 217 00:11:01,480 --> 00:11:05,766 25/8 is the largest. This is bigger than 3, whereas both of 218 00:11:05,766 --> 00:11:07,280 those are less than 3, for example. 219 00:11:07,280 --> 00:11:08,540 This is one easy way to see that. 220 00:11:08,540 --> 00:11:20,780 So the max of f is 25/8, and that's achieved at the points 221 00:11:20,780 --> 00:11:28,680 1/4, 0, plus or minus square root of 15 over 4. 222 00:11:28,680 --> 00:11:29,820 So there you have it. 223 00:11:29,820 --> 00:11:31,860 The method of Lagrange multipliers. 224 00:11:31,860 --> 00:11:37,220 We just followed exactly the strategy that we have. 225 00:11:37,220 --> 00:11:41,750 So you start out and you have an objective function and a 226 00:11:41,750 --> 00:11:42,770 constraint function. 227 00:11:42,770 --> 00:11:43,710 And so what do you do? 228 00:11:43,710 --> 00:11:46,240 You write down their partial derivatives and you come up 229 00:11:46,240 --> 00:11:47,780 with this system of equations. 230 00:11:47,780 --> 00:11:49,642 So this system of equations that you get by setting, you 231 00:11:49,642 --> 00:11:54,430 know, fx equal to lambda gx, fy equal to lambda gy, fz 232 00:11:54,430 --> 00:11:58,270 equals lambda gz, and your constraint equation g equals 233 00:11:58,270 --> 00:11:59,940 some constant. 234 00:11:59,940 --> 00:12:04,310 So then the one part of this procedure that isn't just a 235 00:12:04,310 --> 00:12:07,120 recipe is that you need to solve this system of 236 00:12:07,120 --> 00:12:09,110 equations, but sometimes that can be hard. 237 00:12:09,110 --> 00:12:12,020 So in this case, there were a couple of observations that we 238 00:12:12,020 --> 00:12:14,570 could make from the second and third equations that made it 239 00:12:14,570 --> 00:12:16,810 relatively straightforward to do. 240 00:12:16,810 --> 00:12:18,460 And that gave us some cases. 241 00:12:18,460 --> 00:12:21,380 And then in each of those cases, we were able to 242 00:12:21,380 --> 00:12:23,890 completely solve for the points x, y, and z. 243 00:12:23,890 --> 00:12:26,400 Now we also could solve for the associated values of 244 00:12:26,400 --> 00:12:29,380 lambda, but lambda isn't important to us. 245 00:12:29,380 --> 00:12:31,690 It doesn't affect f. 246 00:12:31,690 --> 00:12:34,990 We can forget about it as soon as we found it, once we found 247 00:12:34,990 --> 00:12:36,320 x, y, and z. 248 00:12:36,320 --> 00:12:37,490 So we were able to solve. 249 00:12:37,490 --> 00:12:40,330 In this case, we got six points of interest. And then 250 00:12:40,330 --> 00:12:42,690 you just look at the value of your objective function at 251 00:12:42,690 --> 00:12:43,470 those points. 252 00:12:43,470 --> 00:12:46,280 So that was what I wrote down in these circles. 253 00:12:46,280 --> 00:12:49,440 So you look at the value of the objective function. 254 00:12:49,440 --> 00:12:51,810 And to find the maximum value of the function, you just look 255 00:12:51,810 --> 00:12:53,300 at which of those is largest. 256 00:12:53,300 --> 00:12:54,220 Now sometimes-- 257 00:12:54,220 --> 00:12:55,751 not in this problem, but in other problems, you'll also 258 00:12:55,751 --> 00:12:57,640 have to check-- 259 00:12:57,640 --> 00:13:00,420 if the region has a boundary, you'll also have to check for 260 00:13:00,420 --> 00:13:03,180 possible maxima and minima on the boundary of the region. 261 00:13:03,180 --> 00:13:05,160 But a sphere doesn't have any edges, so it 262 00:13:05,160 --> 00:13:06,070 doesn't have any boundary. 263 00:13:06,070 --> 00:13:08,020 So we don't have to worry about that. 264 00:13:08,020 --> 00:13:10,770 So that's how we apply the method of Lagrange multipliers 265 00:13:10,770 --> 00:13:11,690 to this problem. 266 00:13:11,690 --> 00:13:14,370 And how you can apply it to other problems as well. 267 00:13:14,370 --> 00:13:16,080 I'll end there. 268 00:13:16,080 --> 00:13:16,263