1 00:00:00,000 --> 00:00:09,980 DAVID JORDAN: Hello, and welcome back to recitation. 2 00:00:09,980 --> 00:00:13,630 So in this problem, we're considering a function 3 00:00:13,630 --> 00:00:18,970 f of three variables, f of x, y, z, and it's differentiable. 4 00:00:18,970 --> 00:00:22,820 And we're not told a formula for f. 5 00:00:22,820 --> 00:00:25,160 We just know that it's differentiable at this point 6 00:00:25,160 --> 00:00:29,400 P, which is 1, minus 1, 1, and we're 7 00:00:29,400 --> 00:00:32,050 told that the gradient of f at that point 8 00:00:32,050 --> 00:00:36,040 is this particular vector 2i plus j minus 3k, at that point 9 00:00:36,040 --> 00:00:39,245 P. So all we understand about f is how 10 00:00:39,245 --> 00:00:42,960 it looks around the point P. 11 00:00:42,960 --> 00:00:45,690 Now, we also have this relation between the variables, 12 00:00:45,690 --> 00:00:48,280 so x, y and z aren't unrelated. 13 00:00:48,280 --> 00:00:50,240 They're related by this constraint 14 00:00:50,240 --> 00:00:53,750 that z is x squared plus y plus 1. 15 00:00:53,750 --> 00:00:56,220 So with this information, we want 16 00:00:56,220 --> 00:00:59,460 to compute the gradient of a new function g, 17 00:00:59,460 --> 00:01:02,870 and the new function g is a function of two variables, 18 00:01:02,870 --> 00:01:07,990 and this function g is obtained from f by just plugging 19 00:01:07,990 --> 00:01:09,590 in our relation for y. 20 00:01:09,590 --> 00:01:13,000 So we can use our constraint to solve for y, 21 00:01:13,000 --> 00:01:19,730 and then this function g is just f with that constraint applied. 22 00:01:19,730 --> 00:01:21,200 And what we really want to do is we 23 00:01:21,200 --> 00:01:27,750 want to find the gradient of g at the point (1, 1). 24 00:01:27,750 --> 00:01:31,550 So notice that when g is equal to 1, 25 00:01:31,550 --> 00:01:34,680 1, that means that-- sorry, when the input of g 26 00:01:34,680 --> 00:01:40,350 is 1, 1, that means the input of f is P. OK? 27 00:01:40,350 --> 00:01:43,837 So why don't you pause the video and work this out for yourself. 28 00:01:43,837 --> 00:01:45,920 Check back with me and we'll work it out together. 29 00:01:53,962 --> 00:01:54,670 OK, welcome back. 30 00:01:54,670 --> 00:01:55,650 So let's get started. 31 00:01:59,590 --> 00:02:03,110 So this problem may not look like it's 32 00:02:03,110 --> 00:02:06,400 a problem about partial derivatives with constraints, 33 00:02:06,400 --> 00:02:10,360 but that's what it's really going to boil down to, 34 00:02:10,360 --> 00:02:18,689 which is to say that when we want to compute-- so 35 00:02:18,689 --> 00:02:20,730 when we want to answer this question by computing 36 00:02:20,730 --> 00:02:22,330 the gradient, the first thing we're going to want to do 37 00:02:22,330 --> 00:02:24,460 is compute the partial derivative of g 38 00:02:24,460 --> 00:02:26,180 and its variable x. 39 00:02:26,180 --> 00:02:28,260 And from the way we set up the problem, 40 00:02:28,260 --> 00:02:34,390 that's just the same as computing 41 00:02:34,390 --> 00:02:39,120 the partial derivative of f with respect 42 00:02:39,120 --> 00:02:44,450 to x and keeping z constant. 43 00:02:44,450 --> 00:02:46,325 Now, remember, when we do partial derivatives 44 00:02:46,325 --> 00:02:49,200 with constraints, what's important about the notation 45 00:02:49,200 --> 00:02:49,950 is what's missing. 46 00:02:49,950 --> 00:02:52,000 The variable y is missing, and that's 47 00:02:52,000 --> 00:02:54,840 because we are going to use the constraint to get rid of it, 48 00:02:54,840 --> 00:02:57,260 and that's exactly how we define g, 49 00:02:57,260 --> 00:03:00,710 so this is the key observation. 50 00:03:00,710 --> 00:03:02,790 So computing the gradient of g is just 51 00:03:02,790 --> 00:03:05,387 going to be computing these partial derivatives 52 00:03:05,387 --> 00:03:06,095 with constraints. 53 00:03:09,080 --> 00:03:16,040 So we'll do that in a moment, and I'll also just write 54 00:03:16,040 --> 00:03:19,190 that the partial derivative of g in the z-direction 55 00:03:19,190 --> 00:03:26,970 is partial f partial z, now keeping x constrained. 56 00:03:26,970 --> 00:03:31,050 All right, so we need to compute these partial derivatives 57 00:03:31,050 --> 00:03:31,933 with constraints. 58 00:03:34,820 --> 00:03:37,412 And so you remember how this goes. 59 00:03:37,412 --> 00:03:38,870 The way that I prefer to do this is 60 00:03:38,870 --> 00:03:40,328 to compute the total differentials. 61 00:03:40,328 --> 00:03:44,405 So let's compute over here. 62 00:03:49,070 --> 00:04:03,365 The total differential df is-- the total differential 63 00:04:03,365 --> 00:04:06,760 of f is just the partials of f in the x-direction, f 64 00:04:06,760 --> 00:04:09,350 in the y-direction, f in the z-direction, and each of these 65 00:04:09,350 --> 00:04:13,690 is multiplied by the corresponding differential. 66 00:04:13,690 --> 00:04:16,570 And we don't know f, so we can't compute the partial derivatives 67 00:04:16,570 --> 00:04:19,410 of it in general, but we do know these partial derivatives 68 00:04:19,410 --> 00:04:20,700 at this point. 69 00:04:20,700 --> 00:04:23,590 And so in the problem, we were given that this 70 00:04:23,590 --> 00:04:33,590 is 2dx plus dy minus 3dz. 71 00:04:33,590 --> 00:04:40,900 So this is just using the fact that the gradient of f we 72 00:04:40,900 --> 00:04:49,410 were given is 2, 1 minus 3, OK? 73 00:04:49,410 --> 00:04:50,994 So that's the total differential of f, 74 00:04:50,994 --> 00:04:52,326 and now we have this constraint. 75 00:04:52,326 --> 00:04:54,480 And remember, when we do these partial derivatives 76 00:04:54,480 --> 00:04:56,890 with constraints, the trick is to take the differential 77 00:04:56,890 --> 00:04:58,330 of the constraint. 78 00:04:58,330 --> 00:05:05,350 So we had this equation z equals x squared plus y plus 1, 79 00:05:05,350 --> 00:05:07,730 and what we need to do is take its differential. 80 00:05:07,730 --> 00:05:17,320 So we have dz is 2x dx plus dy. 81 00:05:17,320 --> 00:05:20,440 So that's our constraint. 82 00:05:20,440 --> 00:05:21,980 Now here we have this variable x, 83 00:05:21,980 --> 00:05:24,150 but we're not varying x in this problem. 84 00:05:24,150 --> 00:05:28,430 We're only focused on the point P, and at the point P, x is 1. 85 00:05:28,430 --> 00:05:39,630 So, in fact, dz is just 2dx plus dy, OK? 86 00:05:39,630 --> 00:05:46,830 So now what we need to do is we need to combine the constraint 87 00:05:46,830 --> 00:05:53,180 equation and the total differential 88 00:05:53,180 --> 00:05:56,370 for f into one equation, and so this 89 00:05:56,370 --> 00:05:58,320 is just linear algebra now. 90 00:05:58,320 --> 00:05:59,840 So I'll just come over here. 91 00:06:02,580 --> 00:06:12,580 So we can rewrite our total differential for the constraint 92 00:06:12,580 --> 00:06:23,994 as saying that dy is equal to dz minus 2dx, 93 00:06:23,994 --> 00:06:26,410 and then we can plug that back into our total differential 94 00:06:26,410 --> 00:06:27,480 for f. 95 00:06:27,480 --> 00:06:35,470 And so we get that df is equal to 2dx plus-- 96 00:06:35,470 --> 00:06:43,250 now I plug in dy here-- so dz minus 2dx, and then 97 00:06:43,250 --> 00:06:46,286 finally, minus 3dz. 98 00:06:46,286 --> 00:06:50,980 So altogether, I get a minus 2dz, 99 00:06:50,980 --> 00:06:52,712 because this and this cancel. 100 00:06:52,712 --> 00:06:55,080 OK. 101 00:06:55,080 --> 00:06:58,920 We get a minus 2dz. 102 00:06:58,920 --> 00:07:04,170 So what does that tell us about the gradient? 103 00:07:04,170 --> 00:07:08,420 So remember that the differential now 104 00:07:08,420 --> 00:07:18,450 of g and its variables is partial g partial x 105 00:07:18,450 --> 00:07:26,490 dx plus partial g partial z dz. 106 00:07:26,490 --> 00:07:28,722 And remember, the trick about partial derivatives 107 00:07:28,722 --> 00:07:30,430 and their relation to total differentials 108 00:07:30,430 --> 00:07:33,080 is that the partial derivative is just this coefficient. 109 00:07:36,110 --> 00:07:39,370 So the fact that we computed df and we 110 00:07:39,370 --> 00:07:43,960 found that it was minus 2dz, that tells us 111 00:07:43,960 --> 00:07:53,490 that dg-- so the thing that we need to use 112 00:07:53,490 --> 00:07:57,720 is that g, remember, is just the specialization of f. 113 00:07:57,720 --> 00:08:01,310 So dg is equal to df in this case, 114 00:08:01,310 --> 00:08:05,620 because g is just a special case of f with constraints. 115 00:08:05,620 --> 00:08:08,070 So when we computed df here, we were 116 00:08:08,070 --> 00:08:11,270 imposing exactly the constraints that we used to define dg, 117 00:08:11,270 --> 00:08:15,880 and so what this tells us is that we can just 118 00:08:15,880 --> 00:08:23,210 compare the coefficients here and so our gradient is 119 00:08:23,210 --> 00:08:27,110 0, minus 2. 120 00:08:27,110 --> 00:08:30,110 So the 0 is because there is no dependence anymore 121 00:08:30,110 --> 00:08:31,740 on x at this point. 122 00:08:31,740 --> 00:08:33,086 There wasn't a dx term. 123 00:08:33,086 --> 00:08:34,710 There could have been and there wasn't. 124 00:08:34,710 --> 00:08:39,370 And the minus 2 is because that's the dependence on z. 125 00:08:39,370 --> 00:08:41,040 OK, so this is a bit complicated, 126 00:08:41,040 --> 00:08:43,210 so why don't we review what we did. 127 00:08:43,210 --> 00:08:46,480 So going back over to the problem statement, 128 00:08:46,480 --> 00:08:56,250 we first needed to realize that saying that g 129 00:08:56,250 --> 00:09:03,925 was a special case of f where we use our constraints to solve 130 00:09:03,925 --> 00:09:08,390 for y, that's what put us in the context of problems 131 00:09:08,390 --> 00:09:09,650 with constraints. 132 00:09:09,650 --> 00:09:13,671 So the fact that the dependence on y 133 00:09:13,671 --> 00:09:15,837 was so simple that we could just use the constraint. 134 00:09:15,837 --> 00:09:16,337 OK. 135 00:09:19,970 --> 00:09:21,770 So then, what that allowed us to do 136 00:09:21,770 --> 00:09:24,610 is it allowed us to say that the partial derivative of g 137 00:09:24,610 --> 00:09:27,840 in the x-direction is just the partial derivative 138 00:09:27,840 --> 00:09:30,880 in the x-direction subject to the constraint, 139 00:09:30,880 --> 00:09:33,650 and that's what we did here. 140 00:09:33,650 --> 00:09:36,776 And so then, the next steps that we did 141 00:09:36,776 --> 00:09:38,400 are the same steps that we would always 142 00:09:38,400 --> 00:09:42,910 do to compute partial derivatives with constraints, 143 00:09:42,910 --> 00:09:48,570 and so we finally got a relationship that 144 00:09:48,570 --> 00:09:50,860 said that, subject to these constraints, 145 00:09:50,860 --> 00:09:54,890 df is equal to minus 2dz. 146 00:09:54,890 --> 00:09:57,640 And the point is that g is just the function 147 00:09:57,640 --> 00:09:59,500 f with those constraints imposed, 148 00:09:59,500 --> 00:10:05,510 and so dg and df are the same, and so, in particular, dg 149 00:10:05,510 --> 00:10:07,360 is minus 2dz. 150 00:10:07,360 --> 00:10:10,295 And then, we remember that you can always 151 00:10:10,295 --> 00:10:12,670 read off partial derivatives from the total differential. 152 00:10:12,670 --> 00:10:14,140 They're just the coefficients. 153 00:10:14,140 --> 00:10:18,545 And so in the end, we got that the gradient was 0 minus 2. 154 00:10:18,545 --> 00:10:20,789 And I think I'll leave it at that.