CHAPTER 01.07: TAYLOR SERIES REVISITED: Taylor Series: Example: Finding sin(2.0)
In this segment, we're going to talk about an example from Taylor series. An example we're going to take is to find sine 2.0. So we're being asked to calculate the value of the sine at 2.0 radians. Now, if we're going to use Taylor series, or Taylor's Theorem, to be able to calculate sine of 2.0, what you do need to understand is that we need to start with some initial point. And what I'm going to do is, I'm going to start with x equal to pi by 2, and what that means is that I'm going to start with this as my place where I know where the value . . . what the value of sine is and all its derivatives is, and that seems to be pretty all right, because if I take sine of x, if I take the derivative, I get cos of x, if I take the derivative of that, I get minus sine of x, take derivative of that, I get minus cos of x, so you can see that the only kinds of forms of the expression which I get for the derivatives of the function are simply sine and cosine, and I know that sine of pi by 2 is 1, and cos of pi by 2 is 0. So those I know as the exact values, so I don't have to find it from any kind of handbook, or anything like that, those I know as exact values, so this seems to be a good starting point for applying the Taylor's Theorem.
So, let's look at the Taylor's Theorem, and then see that how we can calculate sine of 2.0, based on that we know what the value of the function sine of x and all its derivatives are at the value of x equal to pi by 2. So I'm going to reformulate the problem here, so I'm going to say find sine of 2 using Taylor's Theorem based on x equal to pi by 2. So, writing down the Taylor's Theorem for a general function is that I can give you the value of the function at x plus h, if you are able to give me the value of the function at x, the value of the first derivative at x, the value of the second derivative at x, the value of the third derivative at x, and so on and so forth. So based on these, I'll be able to find out what the value of the function at x plus h is, if I know the value of the function at x, if I know the value of the derivative of the function at that particular point, second derivative, third derivative, and so on and so forth. So if I'm looking at this particular example here, my f of x is nothing but sine of x. And what I'm going to do is, I'm going to calculate my derivatives of the function, like f prime of x is cos of x, f double-prime of x is minus sine of x, then f triple-prime, the third derivative of x . . . f of x is minus cos of x, and, let's suppose if I take one more term, fourth derivative of x . . . of the function at x is sine of x, like that, so let me look at it that way. Now, what I'm going to get is that, since I'm choosing my x to be x is pi by 2, so the value of the derivative . . . the value of the function itself at pi by 2 is 1, the value of the derivative of the function at pi by 2 is 0, because cos of pi by 2 is 0, the value of the second derivative of the function at pi by 2 is . . . is -1, the value of the third derivative at pi by 2, which is, again, minus cos pi by 2 will give me 0, and then, again, the fourth derivative of the function at pi by 2 will be equal to +1. So what I'm getting is that, I'm not showing you all the derivatives of f of x, because there'll be infinite possibilities, infinite order of derivatives is available to us, because you can do fifth derivative, sixth derivative, and so on and so forth, and never-ending, but what I'm doing is I'm just giving you the value of the function and the derivative of the function at the first . . . the zeroth derivative all the way up to the fourth derivative of the function. So what that means is that x I can choose to be pi by 2, what does that make the h? h will be whatever is the difference between where I want to go, which is, I want to be able to go to 2, and I want to start from pi by 2, so the difference between this place where I am, which is pi by 2, to where I want to go, will be 0.42920 . . . sorry, 0.42920 . . . 0.42920, so that's the value of h which I'm getting. So, if you look at this particular formula here, which is the general formula for the Taylor series, I'm going to calculate the value of the function at 2, where x is pi by 2 and h is 0.42920, that'll give me 2, knowing what the value of the function at pi by 2 is, knowing what the value of the first derivative is, second derivative and third derivative, and so on and so forth are, at the value of x equal to pi by 2. So, let's go ahead and see, once I do the substitution, what do I get? So, I want to calculate my value of the function at x plus h, x is pi by 2, h is 0.49 . . . 0.4292, and that is equal to the value of the function at x, which is pi by 2, plus the first derivative of the function at pi by 2 times h, which is 0.4292, then plus the second derivative of the function at pi by 2 divided by factorial 2 times h squared, which will be 0.4292 squared, plus the third derivative at pi by 2, divided by factorial 3 times h cubed, so h is 0.4292, so I cube that, and plus, let's suppose, fourth derivative also we'll take, and so on and so forth. So you can see that I've not used all the terms of the Taylor series here, but I have used the first five terms of the Taylor series here. And the thing is that I know what the value of the function at pi by 2 is, all its derivatives is at that pi by 2, so this one here turns out to be 1, because that's the value of the function at pi by 2, which is 1, this one is 0, just this part, the numerator part here is -1, and this part here is 0, and this part here is, again, +1. So you can very well see that . . . that these are the parts of the derivatives of the function which we already know, so those are the only things which were . . . not unknown, but not being substituted there as numbers. So once I have those numbers, I can write that as the first term is 1, the second term is 0 times 0.4292, the third term is 0 . . . is -1 divided by factorial 2 times 0.4292 squared, the third term is 0 divided by factorial 3 times 0.4292 cubed, and the last term . . . not the last term, but the fifth term of the Taylor's Theorem, Taylor series, is follows, and there are many other terms which are in the series. So I'm going to just take the first four terms of the series, and then I will say this is approximately equal to that. So what I am doing is I'm just taking the first five terms, not four, but five terms of the series, and going to use it as an approximation of sine of 2, and this value here turns out to be 0.90931. So that's what I get as the value of sine of 2.0 to be approximately equal to 0.90931, and keep in mind that this is the value which I get by using the first five terms of the Taylor's Theorem, and this is an approximate value which I get. In order to be able to get the exact value of sine of 2.0, although I have the exact values of sine at pi by 2 and cos pi by 2, I will need infinite terms of the Taylor's Theorem to get the exact value of sine of 2.0. However, if you go ahead and punch sine 2.0 radians in your calculator, this is what you're going to get. So this is from your calculator. And what I will say is that this is the exact value of sine 2.0 to five significant digits. So you can very well see that how close you are getting by using simply first five terms of Taylor's Theorem to calculate sine of 2.0. And the one this which you've got to understand here is that the reason why I'm showing you this example is that all the operations which are required to calculate this approximate value of sine of 2.0 just involved multiplication, addition, division, and subtraction, which are the basic arithmetic unit operations in a computer. And that's the end of this segment. |