 Well students, this is the second lecture on our NPTEL course on numerical analysis. In this lecture, we will recall the Taylor's theorem and how it can be used in approximating a function in a small neighborhood of a point. As the name suggests, this concept was developed by Brooke Taylor as a part of his work on astronomical refractions, but his work was not noticed by mathematicians for a longer time until J. L. Legrangi found it and commented that it is a very fundamental work in differential calculus. Let us start our discussion with the definition of Taylor's polynomial for a function at a point. Let us assume that the function f is n times continuously differentiable at a given point say A. Then the Taylor polynomial of degree n for the function f at the point A is denoted by T n and is defined as T n of x is equal to f of A plus f dash of A into x minus A plus f double dash of A divided by 2 factorial into x minus A the whole square plus f triple dash of A divided by 3 factorial into x minus A the whole cube and it goes up to f nth derivative of A divided by n factorial into x minus A to the power of n. So, that is what is written here and this is called the Taylor polynomial. Let us try to have a graphical idea about what is happening in this polynomial. Let us take this function f of x equal to e power x and we all know that is a very nice function. It is a real analytic function. In this graph the blue solid line is the graph of the function e power x and let us take n is equal to 0 and A is equal to 0. That is we want the polynomial of degree 0 for the function f of x equal to e power x around the point A equal to 0 obviously it will be the constant and you can see what is that constant by putting n equal to 0 in the Taylor polynomial. You can see that T naught of x is equal to 1. This red line is the graphical representation of this 0th degree polynomial T naught of x equal to 1. You can see that the polynomial agrees with the function only at the point A equal to 0. Well, let us increase the degree of the Taylor polynomial and see what is going to happen. Let us take n is equal to 1 that is we want a linear polynomial around the point A equal to 0. Now, it is a straight line given by 1 plus x and its graph is shown in the red line in this graph and as usual blue line is the graph of the function e power x. Now, you can see that well the polynomial agrees exactly with the function value at x equal to 0 and also at least graphically we can see that this polynomial is approximating the exact function in a rather very small interval around 0 right. What it means that suppose I want to find the value of the function e power x say at some point here then instead of taking the value from the exponential function if I take the value from this polynomial then the value seems to be pretty close to the exact value at least graphically. Rather than I go somewhere here and try to find the value of say x is equal to minus 0.5 then if I use the polynomial its value may be very much different from the exact value of the function at the point x equal to minus 0.5 right ok. So, to summarize from the 0th degree polynomial when we came to the linear polynomial we see that we got a small interval in which we may have a better approximation to our function through the Taylor polynomial. Let us increase the degree by one more and see what is happening. For n is equal to 2 now and as usual a equal to 0 the graph of the quadratic Taylor polynomial is shown in this red color and blue line is as usual y is equal to f of x. Now, you can see at least graphically that the Taylor polynomial is approximating the exact function in a little bigger neighborhood of 0 then what we got in the linear case right. So, that means to say that now if I have some point say somewhere here then if I compute the value from the polynomial and the value from the original function f of x equal to e power x the difference may be very small that is what I meant by saying that the polynomial is approximating the function pretty well in a rather little bigger neighborhood than what we got in the linear case. With that idea let me go on with the cubic Taylor polynomial you can see that the approximation is rather good in a bigger neighborhood. Now, I can say that the Taylor polynomial is approximating the function rather in a bigger interval say roughly from minus 0.6 to plus 0.6. Similarly, if I go for the fourth degree polynomial it is much more better and so on. So, in this nice function you can see that by increasing the degree of the Taylor polynomial we are getting better approximation of the function by the polynomial in a bigger and bigger neighborhood of the point A which is taken in this particular example as 0. So, this is the purpose of Taylor polynomial. Now, the question is suppose I want to approximate the function f of x by its Taylor polynomial of degree say n. Now, the question is what is the error involved in it? It means what is this number f of x minus t n of x for any x in a small neighborhood of the point A say A minus delta to A plus delta right something like A is equal to 0 in our case. So, I want to approximate my function f by the Taylor polynomial in a small neighborhood if I do so how this quantity will look like that is the question. So, for this we can go to the Taylor's theorem and see how this error will at least look like. Let f be a n plus 1 times continuously differentiable function on a open interval containing both the points A and the point x at which we want to find the approximate value of the function f. Now, the Taylor's theorem says that you can find a xi between the points A and x such that you can write f of x is equal to the Taylor polynomial plus the error. Remember we were interested in understanding how this quantity will look like. Now, Taylor says that that quantity will look like this expression unfortunately this xi is a unknown quantity that is quite natural to expect because if you know this xi then what it means? It means you can represent any sufficiently smooth function by the Taylor's polynomial and whatever you lose as an approximation that can be precisely quantified if you know this xi that looks really too much to expect therefore, xi has to be something which is unknown that is what is also coming from this theorem. If you go through the proof of this theorem you will see that this xi is coming through applying Rolls theorem several times. If you go back to Rolls theorem and see the proof of the Rolls theorem is not constructive it is something conceptual therefore, you just cannot quantify this xi anywhere in this formula. As we have already told T n is the Taylor polynomial of degree n and the second term that is the error term which we will also call as truncation error I will precisely define it later, but in calculus we call it as reminder term. Well I will not prove this theorem however, we have given the proof of this theorem in our notes interested students can go through it. In fact, I will suggest you to go through the proof of this theorem because the idea involved in this theorem is also used in some sense in getting the proof of the error in polynomial interpolations. Therefore, this proof is definitely very helpful for us and it is also important for us to at least once understand in our life. So, that we know how such important theorems are proved. Let us take an example the reminder theorem of the Taylor's formula for the function f of x equal to e power x around the point a equal to 0 is given by this why it is so because you have f n plus 1 of some xi divided by n plus 1 factorial into x minus a to the power of n plus 1. That is the formula here we have taken n is equal to 4 and a equal to 0 where f of x equal to e power x therefore, the reminder formula is e to the power of xi divided by n plus 1 which is 5 factorial into x minus 0 to the power of 5. So, that is how it is coming. What is xi? You should always remember to write what is xi? xi is some unknown lying between x the point at which we want to find the approximate value of the function f and the point 0 which is kept as the point in the Taylor's formula. By the way the formula given in the Taylor's theorem that is this formula is called the Taylor's formula in general. So, the Taylor's theorem says that e power x can be written as the fourth degree polynomial of e power x that is the Taylor polynomial of e power x plus the corresponding reminder term. If you recall the Taylor polynomial of degree 4 for the function e power x is given by this and the reminder term we have already seen that is this. So, these two combined will give you the value of the exponential function at a point x. Unfortunately this term although we know the expression, but its precise value is not known for any given x because the xi is not known to us. So, that is the main problem of this approximation. Just to have a feeling let us take x is equal to 1, the fourth degree polynomial at the point 1 gives 2.7083 and so on whereas, the exact value is something like 2.7183 so on. So, therefore, you can precisely get the error involved in the Taylor polynomial when compared to the exact polynomial in this particular case and that is around 0.01 right. Of course, this is precisely known because we have fixed our x here as 1. In general for a given x we do not know how it will look. If you precisely give x then possibly you can compute provided you know how to compute the exponential function, but as a general case this is not known to us. Then you may ask then what is the point of having this reminder term well we have at least some idea of how that error will look like and in certain cases you can also find an estimate for this error. What is mean by estimate of the error? Let me just give you a idea of it in this particular example. Assume that I want to find approximate value of the function e power x at some point x less than 1. Whatever x I will choose that will be something less than 1. If that is so then what you can do is you take the modulus on both sides of this reminder and that is going to be modulus e psi divided by 5 factorial into x to the power of 5. Now, what I meant by estimating this error? It means I want to find a fixed number. I do not want the upper bound to involve anything which is unknown or something which is a variable. Now, what I will do is I will use the fact that exponential function is a monotonically increasing function. Therefore, its maximum is actually achieved at x equal to 1 right. Therefore, for any given x whatever may be the value of x you have some xi which unfortunately I do not know, but however what I can say is whatever may be that xi is it will be surely less than or equal to e that is what I will say and then divided by 5 factorial and again x is going to be something less than 1, but here I can say that x to the power of 5 is surely going to be less than 1 because I know precisely how I am going to choose my x. Therefore, with all these ideas I can say roughly that this quantity whatever it is which is we do not know will be surely less than or equal to e to the power of 1 divided by 5 factorial that is approximately 0.0227 ok. So, that is what is finally, we meant by estimate. So, whenever we give a function and ask you to write a Taylor polynomial of degree something some n we will give and also we will give some value for a and then ask you to write the Taylor polynomial for that function then you know how to write because you have the formula and you can also write the reminder term for that and if we want to estimate it then somehow you have to get a upper bound for the reminder quantity which does not involve any unknown or any variable it should be a fixed number that is what we meant by estimates. Well, as I told you at the Taylor's theorem the reminder term is called the truncation error involved in the Taylor polynomial when compared to the exact function often we use this word truncation error in our course. Let us see how Taylor's theorem is used generally you are given a real number a and you are also given a real number h. Let us try to visualize it you are given a and you are given a small number h greater than 0 or even less than 0 if it is greater than 0 a plus h will come this side if it is less than 0 a plus h will come this side either it is greater than 0 or less than 0 anything is ok. And now we are also given an integer n and all these informations are given to us practically this is too much to expect. However, as far as this approximation procedure is concerned we have to know all these information that is f of a f dash of a and so on up to f n of a. Once you know all these informations then the question is what will be the value of f at the point a plus h that is you are given information about what is f of a and similarly what is f dash of a and so on up till f n of a and you now want to know what is the value at a plus h say. Suppose this is the function you know all the informations like this at this point only you do not know at any other point now I want to know what is the value of f of a plus that is precisely what your Taylor's theorem is going to tell you now. The Taylor's theorem says that I can write f of a plus h as this is the Taylor's polynomial. So, if I do not write the truncation error here if I do not write that then I should put approximately equal to. So, you should remember this notation is very important whenever you are writing this this is the exact value that you want to compute unfortunately we do not know this. So, we are going to find an approximate value of that by evaluating the value of the corresponding Taylor's polynomial at the point a plus h that turns out to be this. Remember if you want to find the Taylor's polynomial at x it involves x minus a right. So, now our x is a plus h therefore, a plus h minus a is h that is why h is sitting here then x minus a the whole square therefore, this and so on that is why h is sitting here ok. So, this is the way we will use Taylor's theorem in approximating values of a function by the value of the corresponding Taylor's polynomial and the error involved is the truncation error which is also called the reminder. So, as I told you how to estimate the truncation error let us again assume that f is n plus 1 times continuously differentiable and assume that you are working in a closed and bounded interval say I do not want to use a comma b because a is already reserved for the point around which we want to approximate the function. Therefore, I just used alpha comma beta. So, since f is n plus 1 times continuously differentiable therefore, f n plus 1 is a continuous function on a closed and bounded interval. Therefore, you can find a constant such that modulus of f n plus 1 of xi is less than or equal to m n plus 1 that is the constant I am assuming then what you can do recall this is the general formula for reminder term which also is called truncation error. Now you see this can be dominated by m n plus 1 remember by estimate we mean to have an upper bound which is just a number which does not involve any unknown or any variable here xi is a unknown and x is a variable of course, if you change x the xi also will vary right. So, we have to somehow eliminate these two members a is not a variable or unknown it is known to us right. So, therefore, we have to somehow eliminate these two we can eliminate xi by dominating this term by the constant m and you can dominate x by beta because whatever is the value of x it is going to lie between alpha and beta therefore, x will utmost take the value beta. Therefore, we will replace this by beta and this entire term we will replace by m right. So, that will give us an estimate of the truncation error and that is given by m n plus 1 divided by n plus 1 factorial into this one and that further I will eliminate by putting beta instead of x right that is the way we can get the truncation error estimate. Now, let us pause on to what is mean by Taylor's series you are given a C infinity function f then the power series given by this around a point a around which your function is a C infinity function is called the Taylor's series. Now, the question is if the series converges then what is the limit of this series well under certain conditions on f we can say that the limit of this series is equal to f of x well these conditions are listed in the form of a theorem in our notes, but just to keep our discussion simple let us assume that f is a real analytic function then of course by definition f of x can be represented by the Taylor series right. Of course, we know this from our calculus course let us take an example f of x is equal to cos x we know that the Taylor's series at a point x equal to a for the function cos x is given by this right. Now, let me take in particular a is equal to 0 then this series reduces to 1 minus x square by 2 and so on remember all the terms with sign will vanish that is why we do not see the odd powers here only even powers survive and therefore, we can write the series for cos like this right ok. So, why am I telling this we all know this now coming back to Taylor formula at a equal to 0 n equal to 4 for the cos function can be taken like this ok. Now, I am putting approximately equal to because I am not writing the truncation error or the reminder term here. Therefore, I have to put the approximately equal to symbol here and what I am losing in this approximation is precisely given by this expression. However, its value is not known to us precisely, but the expression is known to us like this where the psi which is the unknown lies between 0 and x ok. So, here what I would like to highlight is generally you may write the reminder term just going by the Taylor's theorem may be written with x to the power of 5 term right here, but what we are taking as a reminder term is x power 6 term why we are doing it because that is the immediate next term in your series right and therefore, that dominates your truncated part. What is that you are truncating x to the power of 6 divided by something plus x to the power of 8 divided by something and so on. So, what we are truncating is this part and the leading term of that part is x power 6. Therefore, we actually has to take this as the reminder term and not with x to the power of 5. This one has to remember why we are doing this well when we do the order of convergence at that time we will come and revisit this problem and tell why we prefer to take this term as the reminder term and not the one with x power 5 which actually your Taylor's theorem may suggest ok. So, in that way your Taylor approximation for cos function may be written like this where the index goes from 0 to m with 2 into k here and the reminder is immediately taken at the m plus 1 stage ok. So, this is something that you have to keep in mind when you are writing the reminder term for cos x similarly for sin x also ok. With this our discussion or Taylor approximation is over we will meet you in the next class. Thank you.