More Derivative Examples (C1W2L06)

Short lecture (Andrew Ng) explaining derivatives as local slopes using numeric "nudge" examples. Covers f(A)=A^2 (derivative 2A), f(A)=A^3 (derivative 3A^2), and f(A)=log(A) (derivative 1/A), showing with small increments (e.g., 0.001) how function values change and emphasizing that derivatives vary by point; closes by previewing computation-graph methods.
Chapters
In this video, I want to show you a slightly more complex example where the slope of the function can be different at different points in the function. Let's start with an example. Here I plotted the function F of A equals A squared. Let's again look at the point a equals 2. So a squared or F of A is equal to 4. Let's nudge a slightly to the right. So now A is equal to 2.001. F of A, which is A squared, is going to be approximately 4.004. It turns out that the exact value, if you put on the calculator and figure this out, is actually 4.004001. But I'm just going to say 4.004 is close enough. So what this means is that when A is equal to 2, let's draw this on the plot. So what we're saying is that if A is equal to 2, then F of A is equal to 4. And here the X and Y axes are not drawn to scale. Technically, this vertical height should be much higher than this horizontal height. So the X and Y axes are not on the same scale. But if I now nudge A to 2.001, then F becomes roughly 4.004. So if you draw this little triangle again, what this means is that if I nudge A to the right by 0.001, F of A goes up four times as much by 0.04. So? So in the language of calculus, we say that the slope that is the derivative of F of A at A equals 2 is 4. Or to write this out with our calculus notation, we say that D DA of F of A is equal to 4 when A is equal to 2. Now, one thing about this function F of A equals A squared is that the slope is different for different values of A. This is different than the example we saw on the previous slide. So? So let's look at a different point. If A is equal to 5, so instead of A equals 2, we now have A equals 5. Then A squared is equal to 25. So that's F of A. If I nudge A to the right, again, tiny little nudge to A. So Now A is 5.001. Then F of A will be approximately 25.010. So what we see is that by nudging a up by 0.001, f of a goes up 10 times as much. So we have that d da f of a is equal to 10 when a is equal to 5, because f of a goes up 10 times AS much as A does when I make a tiny little nudge to a. So one way to see why the derivative is different at different points is that if you draw that little triangle right at different locations on this, you see that the ratio of the height of the triangle of over the width of the triangle is very different at different points on the curve. So here the slope is equal to 4 when A is equal to 2, but is equal to 10 when A is equal to 5. Now, if you pull up a calculus textbook, a calculus textbook will tell you that D da of F of A, so F of A is equal to A squared. So that's D da of A squared. One of the formulas you find in the calculus textbook is that this thing, the slope of the function A squared is equal to 2A. Not going to prove this, but the way you find this out is that you open up a calculus textbook to the table of formulas and it'll tell you the derivative of 2 of a squared is equal to 2a. And indeed, this is consistent with what we've worked out. Namely, when A is equal to 2, the slope of the function 2a is 2 times 2 is therefore equal to 4. And when a is equal to 5, then the slope of the function 2 times a is 2 times 5 is equal to 10. So if you ever pull up a calculus textbook and you see this formula that the derivative of A squared is equal to 2a, all that means is that for any given value of A, if you nudge it upward by 0.001, already a tiny little value, you would expect F to go up by 2a, that is the slope or the derivative times, however much you had nudged to the right, the value of a. Now, one tiny little detail. You know, I had used these approximate symbols here, and this wasn't exactly 4.004, there's an extra 0.001 hanging out there. It turns out that this extra 0.001, this little thing here, is because we were nudging A to the right by 0.001. If we're instead nudging it to the right by this infinitesimally small value, then this extra error term will go away, and you find that the amount that F of A goes up is exactly equal to the derivative times the amount that you nudge A to the right. And the reason why it's not 4.004 exactly is because derivatives are defined using these infinitesimally small nudges to A, rather than you know 0.001, which is. And while 0.001 is small, is not infinitesimally small. So that's why the amount that F went up isn't exactly given by the formula, but is only kind of approximately given by the derivative. To wrap up this video, let's just go through a few more quick examples. The example you've already seen is that if F of A equals A squared, then a calculus textbooks formula table will tell you that the derivative is equal to 2a. And so the example we went through was that if A is equal to 2, F of A equals 4, and if we nudge A so it's a little bit bigger, then F of a is about 4.04. And so F of A went up four times as much. And indeed when A is equal to 2, the derivative is equal to 4. Let's look at some other examples. Let's say instead that F of A is equal to a cubed. If you go to calculus textbook and look up the table of formulas, the you see that the slope of this function, again the derivative of this function is equal to 3a squared. So you can get this formula out of a calculus textbook. So what this means. So the way to interpret this is as follows. Let's take A equals 2 as an example. Again, so F of A or a cubed is equal to 8, that's 2 to the power of 3. So if we give a a tiny little nudge, you find that F of a is about 8.012. And feel free to check this. Take 2.001 to the power of 3, you find that it's very close to 8.012. And indeed when a is equal to 2, that's 3 times 2 squared, that's equal to 3 times 4, which is equal to 12. So the derivative formula predicts that if you nudge A to the right by a tiny little bit, F of A should go up 12 times as much. And indeed this is true. When A went up by 0.001, F of A went up 12 times as much by 0.012. Just one last example and then we'll wrap up. Let's say that F of A is equal to the log function, right? So I'm going to write log of A and going to use this as the base E logarithm. So some people write that as log ln of a. So if you go to calculus textbook you find that when you take the derivative of log of a, so this is a function That I guess, looks like that the slope of this function is given by 1 over A. So the way to interpret this is that if A is any value. Again, let's just keep using A equals 2 as an example. And you nudge A to the right by 0.001, you would expect F of A to go up by one over A, that is by the derivative times the amount that you increased A. So in fact, if you pull up a calculator, you find that if A is equal to 2, F of A is about 0.69315. And if you increase F, and if you increase A to 2.001, then F of A is about 0.69365. So it's gone up by 0.0005. And indeed, if you look at the formula for the derivative, when A is equal to 2D, DAF of A is equal to 1/2. So this derivative formula predicts that if you bump up a by 0.001, you would expect F of A to go up by only 1/2 as much. And 1/2 of 0.001 is is 0.0005, which is exactly what we got, that when A goes up by 0.001, going from a 2 to a 2.001, F goes up by half as much. So it ends up going up by approximately 0.0005. So if you draw that little triangle, if you will, is that if on the horizontal axis, this goes up by 0.001 on the vertical axis, log of A goes up by half of that. So 0.0005, and so that one over a or one half in this case, when a is equal to 2, that's just the slope of this line when A is equal to 2, so that's it for derivatives, they're just 2. Take home messages from this video. First is that the derivative of a function just means the slope of a function. And the slope of a function can be different at different points on the function. In our first example, where F of a equals 3a, that was a straight line. The derivative was the same everywhere. It was three everywhere. But for other functions like F of A equals A squared, or F of a equals log of a, the slope of the line varies and so the slope or the derivative can be different at different points on the curve. So that's the first takeaway. Derivative just means slope of a line. Second takeaway is that if you want to look up the derivative of a line function, you can flip open your calculus textbook or look up Wikipedia and often get a formula for the slope of these functions at different points so that I hope you have an intuitive understanding of derivatives or of slopes of lines. Let's go on to the next video. We'll start to talk about the computation graph and how to use that to compute derivatives of more complex functions.










