1 00:00:00,000 --> 00:00:00,850 2 00:00:00,850 --> 00:00:02,669 Let's learn a little bit about the gradient, and we'll use the 3 00:00:02,669 --> 00:00:05,199 same function we've been using since we're pretty familiar 4 00:00:05,200 --> 00:00:08,960 with it's graph and it's partial derivatives. 5 00:00:08,960 --> 00:00:18,120 So let's say that f of x y is equal to x squared plus x 6 00:00:18,120 --> 00:00:23,839 times y plus y squared. 7 00:00:23,839 --> 00:00:25,730 Now we're going to take the gradient of this, and then I'll 8 00:00:25,730 --> 00:00:26,960 give you a little bit of intuition on what 9 00:00:26,960 --> 00:00:27,800 a gradient is. 10 00:00:27,800 --> 00:00:32,310 We're going to take the gradient in two-dimensional 11 00:00:32,310 --> 00:00:34,789 space, and you'll see what that means in a second. 12 00:00:34,789 --> 00:00:38,350 You can extend this to any dimension. 13 00:00:38,350 --> 00:00:41,810 So the gradient that we use this vector differential 14 00:00:41,810 --> 00:00:47,820 operator-- this upside down triangle-- the gradient of f is 15 00:00:47,820 --> 00:00:54,670 equal to the partial of f in the x direction times the unit 16 00:00:54,670 --> 00:00:58,179 vector i-- which is the unit vector in the x direction so it 17 00:00:58,179 --> 00:01:02,960 gives the magnitude of the slope and the x direction, and 18 00:01:02,960 --> 00:01:06,719 then it points the vector in that direction-- plus the 19 00:01:06,719 --> 00:01:11,000 partial with respect to y in the j direction. 20 00:01:11,000 --> 00:01:12,859 And obviously if there's a function of more variables you 21 00:01:12,859 --> 00:01:16,480 could keep going and you'd multiply the magnitude of the 22 00:01:16,480 --> 00:01:20,630 derivative in each of those dimension's directions times 23 00:01:20,629 --> 00:01:22,780 the unit vector in that dimension. 24 00:01:22,780 --> 00:01:23,689 Well what does this mean? 25 00:01:23,689 --> 00:01:28,280 And another way to view it, you could have also written this as 26 00:01:28,280 --> 00:01:33,909 the gradient of f is equal to the partial with respect to x 27 00:01:33,909 --> 00:01:39,829 of f of x y and then all of that in the i direction. 28 00:01:39,829 --> 00:01:41,319 This is just different notation. 29 00:01:41,319 --> 00:01:48,739 Plus the partial with respect to y times f of x y. 30 00:01:48,739 --> 00:01:50,549 Not times, operated on f of x y. 31 00:01:50,549 --> 00:01:54,870 So the partial of f of x y with respect to y times 32 00:01:54,870 --> 00:01:57,180 the j unit vector. 33 00:01:57,180 --> 00:02:01,960 And because of this notation, a lot of people view this delta 34 00:02:01,959 --> 00:02:04,429 operator-- and actually it's pretty consistent when we learn 35 00:02:04,430 --> 00:02:07,080 about the divergence and the curl-- a lot of people view 36 00:02:07,079 --> 00:02:09,210 this delta operator, they actually define it. 37 00:02:09,210 --> 00:02:14,300 They say that is equal to the partial with respect to x in 38 00:02:14,300 --> 00:02:19,120 the i direction plus the partial with respect to 39 00:02:19,120 --> 00:02:21,939 y in the j direction. 40 00:02:21,939 --> 00:02:26,199 And then if you wanted to do it into three space-- that's not 41 00:02:26,199 --> 00:02:28,189 going to apply to our problem because we only care about 42 00:02:28,189 --> 00:02:29,079 two dimensions right now. 43 00:02:29,080 --> 00:02:29,700 And you'll see what I mean. 44 00:02:29,699 --> 00:02:30,739 Because even though we're applying it to a 45 00:02:30,740 --> 00:02:33,210 three-dimensional surface, but then you can do the partial 46 00:02:33,210 --> 00:02:36,240 with respect to z times the k vector. 47 00:02:36,240 --> 00:02:40,030 And then you could extend it to n dimensions, but it becomes 48 00:02:40,030 --> 00:02:40,969 very hard to visualize. 49 00:02:40,969 --> 00:02:42,919 Actually it becomes hard to visualize beyond what 50 00:02:42,919 --> 00:02:44,919 we're doing right now. 51 00:02:44,919 --> 00:02:48,250 So what does this mean? 52 00:02:48,250 --> 00:02:50,150 Well before I go into what it means, let's actually calculate 53 00:02:50,150 --> 00:02:53,170 it for this and then I'll show you what it means. 54 00:02:53,169 --> 00:02:58,699 55 00:02:58,699 --> 00:03:01,619 Let's actually calculate the gradient of f. 56 00:03:01,620 --> 00:03:05,789 So the gradient of our particular function, it's a 57 00:03:05,789 --> 00:03:08,019 partial with respect to x. 58 00:03:08,020 --> 00:03:08,850 So we figure that out. 59 00:03:08,849 --> 00:03:12,049 That's 2x plus y, and then that doesn't matter anymore. 60 00:03:12,050 --> 00:03:15,160 So it's 2x plus y. 61 00:03:15,159 --> 00:03:19,099 That's the partial of this function with respect to x. 62 00:03:19,099 --> 00:03:22,194 And we multiply that in the i direction, or 63 00:03:22,194 --> 00:03:23,750 in the x direction. 64 00:03:23,750 --> 00:03:28,705 Plus the partial with respect to y, and this is 2y plus x. 65 00:03:28,705 --> 00:03:31,540 66 00:03:31,539 --> 00:03:34,449 And we calculated this in the two videos on the 67 00:03:34,449 --> 00:03:36,539 partial derivatives. 68 00:03:36,539 --> 00:03:40,090 And we multiply that in the j direction. 69 00:03:40,090 --> 00:03:41,460 So what does that look like? 70 00:03:41,460 --> 00:03:45,030 Well what are each of the components of this vector? 71 00:03:45,030 --> 00:03:48,110 What is 2x plus y in the i direction? 72 00:03:48,110 --> 00:03:49,170 What does that vector look like? 73 00:03:49,169 --> 00:03:52,239 What is 2y plus x in the j direction look like? 74 00:03:52,240 --> 00:03:53,645 And this I have graphed. 75 00:03:53,645 --> 00:03:57,010 76 00:03:57,009 --> 00:03:59,179 So this is the same surface we've been working with, but 77 00:03:59,180 --> 00:04:01,330 now I've plotted these points right here. 78 00:04:01,330 --> 00:04:05,300 These are just points that the software has picked to actually 79 00:04:05,300 --> 00:04:07,740 display these vectors. 80 00:04:07,740 --> 00:04:10,879 And if you look at it, this is the x-axis. 81 00:04:10,879 --> 00:04:12,629 And I can rotate this. 82 00:04:12,629 --> 00:04:14,129 I can pull it down a little bit. 83 00:04:14,129 --> 00:04:16,620 And then I can spin it around. 84 00:04:16,620 --> 00:04:18,870 I think that's pretty neat. 85 00:04:18,870 --> 00:04:20,030 But anyway. 86 00:04:20,029 --> 00:04:22,199 This parallel to this line is the vector in 87 00:04:22,199 --> 00:04:23,639 the x-axis, right? 88 00:04:23,639 --> 00:04:26,689 So at this point I've actually calculated the gradient. 89 00:04:26,689 --> 00:04:30,750 This vector says, what is the magnitude of this vector is the 90 00:04:30,750 --> 00:04:34,139 partial derivative of the function, or the partial 91 00:04:34,139 --> 00:04:37,069 derivative of the surface, or the partial derivative 92 00:04:37,069 --> 00:04:40,540 of z with respect to x. 93 00:04:40,540 --> 00:04:44,790 And it's direction, it just goes in the x direction, 94 00:04:44,790 --> 00:04:47,950 because it's that times the i unit vector. 95 00:04:47,949 --> 00:04:50,774 So this vector is the partial derivative of z with respect 96 00:04:50,774 --> 00:04:54,549 to x times the i unit vector at that point. 97 00:04:54,550 --> 00:04:56,110 So we just calculated the partial derivative 98 00:04:56,110 --> 00:04:56,970 at that point. 99 00:04:56,970 --> 00:04:58,800 It gave this length. 100 00:04:58,800 --> 00:05:02,480 And then the direction is just the i unit vector, or in the 101 00:05:02,480 --> 00:05:05,060 direction of increasing x. 102 00:05:05,060 --> 00:05:09,490 Similarly, this vector right here-- I hope you can see it. 103 00:05:09,490 --> 00:05:13,949 Let me see if I can actually zoom in a little bit. 104 00:05:13,949 --> 00:05:17,099 That might be useful. 105 00:05:17,100 --> 00:05:18,590 Zoom in, there you go. 106 00:05:18,589 --> 00:05:22,109 107 00:05:22,110 --> 00:05:25,389 And I wanted to see the axes, which you can't see now that 108 00:05:25,389 --> 00:05:28,649 I'm zoomed in, but you took my word this was the x direction. 109 00:05:28,649 --> 00:05:31,039 Now this is the y direction, or the same direction 110 00:05:31,040 --> 00:05:34,580 as the j unit vector. 111 00:05:34,579 --> 00:05:36,870 The j unit vector goes in the same direction as y. 112 00:05:36,870 --> 00:05:40,389 And the magnitude is determined by the partial derivative of z 113 00:05:40,389 --> 00:05:43,419 with respect to y at that point. 114 00:05:43,420 --> 00:05:44,280 And that's the magnitude. 115 00:05:44,279 --> 00:05:46,129 And we saw there was some symmetry, so the magnitude of 116 00:05:46,129 --> 00:05:48,589 this vector is the same as the magnitude of this vector. 117 00:05:48,589 --> 00:05:50,659 And then when you add the two vectors together, 118 00:05:50,660 --> 00:05:52,280 you get this vector. 119 00:05:52,279 --> 00:05:56,579 And notice that none of these vectors have any dimensions 120 00:05:56,579 --> 00:05:59,120 in the z dimension. 121 00:05:59,120 --> 00:06:02,540 They're all kind of giving you directions in the x y plane. 122 00:06:02,540 --> 00:06:03,930 And why is that interesting? 123 00:06:03,930 --> 00:06:07,160 Well the gradient-- and this is the intuition-- the gradient 124 00:06:07,160 --> 00:06:12,400 tells you the direction in the x y plane you should travel 125 00:06:12,399 --> 00:06:16,329 in order to get the maximum slope in the z dimension. 126 00:06:16,329 --> 00:06:17,750 Or another way to view it. 127 00:06:17,750 --> 00:06:20,990 Remember the partial derivative with respect to x said what is 128 00:06:20,990 --> 00:06:23,519 the slope in the x direction. 129 00:06:23,519 --> 00:06:25,674 The partial derivative with respect to y said what is the 130 00:06:25,675 --> 00:06:26,710 slope in the y direction. 131 00:06:26,709 --> 00:06:29,000 But you could take the partial derivative with respect to any 132 00:06:29,000 --> 00:06:32,420 direction, and the gradient gives you the direction in 133 00:06:32,420 --> 00:06:35,000 which the slope is the largest. 134 00:06:35,000 --> 00:06:41,939 So let me zoom out a little bit because I want you to see the 135 00:06:41,939 --> 00:06:50,969 actual axes There's the axes So all this says if I were to 136 00:06:50,970 --> 00:06:53,800 go in this direction, I get the maximum slope. 137 00:06:53,800 --> 00:06:57,620 So if I go in this direction, my z goes up like that. 138 00:06:57,620 --> 00:07:02,060 Let me see if I can rotate this a little bit. 139 00:07:02,060 --> 00:07:03,569 I don't want to scale it anymore. 140 00:07:03,569 --> 00:07:04,495 Let me do the rotated. 141 00:07:04,495 --> 00:07:07,550 142 00:07:07,550 --> 00:07:09,430 See if I can show that to you. 143 00:07:09,430 --> 00:07:17,439 So if I go in that direction in the x y plane, I get maximum z. 144 00:07:17,439 --> 00:07:21,670 If I go in that direction I get a maximum upward slope. 145 00:07:21,670 --> 00:07:24,740 That's what the gradient tells you, how do you get the 146 00:07:24,740 --> 00:07:26,699 maximum upward slope. 147 00:07:26,699 --> 00:07:32,920 And if you were to take any closed line where the z is 148 00:07:32,920 --> 00:07:35,410 constant-- well actually I don't want to get into that too 149 00:07:35,410 --> 00:07:40,085 much, but this gradient will actually be normal to any, or 150 00:07:40,084 --> 00:07:43,870 it'll be perpendicular to any curve where z is constant. 151 00:07:43,870 --> 00:07:45,819 I don't want to get too involved with that right 152 00:07:45,819 --> 00:07:47,750 now, so let's go back here. 153 00:07:47,750 --> 00:07:51,879 Maybe it's more clear if we look from below the graph. 154 00:07:51,879 --> 00:07:54,019 So if you go to this point right here, this is the 155 00:07:54,019 --> 00:07:57,159 magnitude of this vector, shows what is the slope 156 00:07:57,160 --> 00:07:58,000 in the x direction. 157 00:07:58,000 --> 00:07:59,740 The magnitude of this vector is what is the slope 158 00:07:59,740 --> 00:08:00,769 in the y direction. 159 00:08:00,769 --> 00:08:03,759 And then when you add them together, you get the gradient. 160 00:08:03,759 --> 00:08:06,219 And the gradient says, well, if I travel in this direction in 161 00:08:06,220 --> 00:08:11,150 the x y plane-- notice that none of these have any z's. 162 00:08:11,149 --> 00:08:13,269 The plane defined by all of these vectors is all 163 00:08:13,269 --> 00:08:16,949 flat in the z dimension. 164 00:08:16,949 --> 00:08:19,959 But if I would have traveled this direction in the x y 165 00:08:19,959 --> 00:08:23,779 plane, then I will get the maximum increase in z 166 00:08:23,779 --> 00:08:24,949 per unit that I travel. 167 00:08:24,949 --> 00:08:26,979 And let's actually show you what it looks like 168 00:08:26,980 --> 00:08:27,700 in the x y plane. 169 00:08:27,699 --> 00:08:31,199 So if I just go head on-- so I'm above the graph looking 170 00:08:31,199 --> 00:08:34,580 straight down at the graph, and then the colors just show kind 171 00:08:34,580 --> 00:08:40,120 of you know where we are-- if I travel in this direction in 172 00:08:40,120 --> 00:08:43,750 the x y plane, I get my maximum increase in z. 173 00:08:43,750 --> 00:08:51,159 If I'm here-- notice here the x component of the gradient is 174 00:08:51,159 --> 00:08:52,414 much larger than the y component. 175 00:08:52,414 --> 00:08:54,969 So I need to travel a little bit more in the x direction, 176 00:08:54,970 --> 00:08:58,470 and I'll get the maximum change in z if I travel there. 177 00:08:58,470 --> 00:09:00,320 Another way to think about it. 178 00:09:00,320 --> 00:09:07,010 If I'm on a hill, the gradient of that surface will tell you 179 00:09:07,009 --> 00:09:12,299 at any point what direction you need to travel in to go 180 00:09:12,299 --> 00:09:13,449 up the hill fastest. 181 00:09:13,450 --> 00:09:16,600 Or the direction which the steepness of the 182 00:09:16,600 --> 00:09:17,980 hill is maximum. 183 00:09:17,980 --> 00:09:23,210 This is more of a bowl as opposed to a hill, but anyway. 184 00:09:23,210 --> 00:09:24,280 I'll just rotate it around. 185 00:09:24,279 --> 00:09:25,779 Hopefully that makes some sense. 186 00:09:25,779 --> 00:09:27,319 And I want you to think about it a little bit more. 187 00:09:27,320 --> 00:09:29,840 And we'll do a few more problems where we just 188 00:09:29,840 --> 00:09:32,210 calculate gradients, just because I think it's useful 189 00:09:32,210 --> 00:09:33,280 to get the mechanics. 190 00:09:33,279 --> 00:09:36,529 But in my opinion at least the intuition is a little bit 191 00:09:36,529 --> 00:09:38,764 harder to get your head around than the actual mechanics, 192 00:09:38,764 --> 00:09:41,129 but once you get it, it makes a lot of sense. 193 00:09:41,129 --> 00:09:42,950 I will see you in the next video. 194 00:09:42,950 --> 00:09:44,500