This is a note written for my fall 2013 Math 100 class, but it was not written “for the exam,” nor does anything on here subtly hint at anything on any exam. But I hope that this will be helpful for anyone who wants to get a basic understanding of Taylor series. What I want to do is try to get some sort of intuitive grasp on Taylor series as approximations of functions. By intuitive, I mean intuitive to those with a good grasp of functions, the basics of a first semester of calculus (derivatives, integrals, the mean value theorem, and the fundamental theorem of calculus) – so it’s a mathematical intuition. In this way, this post is a sort of follow-up of my earlier note, An Intuitive Introduction to Calculus.
PLEASE NOTE that this note was written and typeset for my (now) main site: davidlowryduda.com. You can find it here. Because of this, some of the math shown here will display better there, where I have more control. This will also serve as the announcement that davidlowryduda.com is now on an improved webhost and should be fast and fully operational. Now, back to the math.
We care about Taylor series because they allow us to approximate other functions in predictable ways. Sometimes, these approximations can be made to be very, very, very accurate without requiring too much computing power. You might have heard that computers/calculators routinely use Taylor series to calculate things like (which is more or less often true). But up to this point in most students’ mathematical development, most mathematics has been clean and perfect; everything has been exact algorithms yielding exact answers for years and years. This is simply not the way of the world.
Here’s a fundamental fact to both mathematics and life: almost anything worth doing is probably pretty hard and pretty messy.
For a very recognizable example, let’s think about finding zeroes of polynomials. Finding roots of linear polynomials is very easy. If we see , we see that is the zero. Similarly, finding roots of quadratic polynomials is very easy, and many of us have memorized the quadratic formula to this end. Thus has solutions . These are both nice, algorithmic, and exact. But I will guess that the vast majority of those who read this have never seen a “cubic polynomial formula” for finding roots of cubic polynomials (although it does exist, it is horrendously messy – look up Cardano’s formula). There is even an algorithmic way of finding the roots of quartic polynomials. But here’s something amazing: there is no general method for finding the exact roots of 5th degree polynomials (or higher degree).
I don’t mean We haven’t found it yet, but there may be one, or even You’ll have to use one of these myriad ways – I mean it has been shown that there is no general method of finding exact roots of degree 5 or higher polynomials. But we certainly can approximate them arbitrarily well. So even something as simple as finding roots of polynomials, which we’ve been doing since we were in middle school, gets incredibly and unbelievably complicated.
So before we hop into Taylor series directly, I want to get into the mindset of approximating functions with other functions.
1. Approximating functions with other functions
We like working with polynomials because they’re so easy to calculate and manipulate. So sometimes we try to approximate complicated functions with polynomials, a problem sometimes called “polynomial interpolation”.
Suppose we wanted to approximate . The most naive approximation that we might do is see that , so we might approximate by . We know that it’s right at least once, and since is periodic, it’s going to be right many times. I write to indicate that this is a degree polynomial, that is, a constant polynomial. Clearly though, this is a terrible approximation, and we can do better.
1.1. Linear approximation
So instead of a constant function, let’s approximate it with a line. We know that and , and two points determine a line. What is the line that goes through and ?. It’s , and so this is one possible degree approximation:
You might see that our line depends on what two points we use, and this is very true. Intuitively, you would expect that if we chose our points very close together, you would get an approximation that is very accurate near those two points. If we used and instead, we get this picture:
Two points determine a line. I’ve said this a few times. Alternately, a point on the line and the slope of the line are enough to determine the line. What if we used that to give us the point , and used that to give us our direction? Then we would have a line that goes through the point and has the right slope, at least at the point – this is a pretty good approximate. I’ll call this line , and in this case we see that . Aside: Some people call the derivative the “best linear approximator” because of how accurate this approximation is for near (as seen in the picture below). In fact, the derivative actually is the “best” in thise sense – you can’t do better.
These two graphs look almost the same! In fact, they are very nearly the same, and this isn’t a fluke. If you think about it, the secant line going through and is an approximation of the derivative of at – so of course they are very similar!
1.2. Parabolic approximation
But again, we could do better. Three points determine a parabola. Let’s try to use , and to come up with a parabola. One way we could do this would be to use that we know both roots of the parabola, and . So our degree approximation must be of the form , since all degree polynomials with zeroes at and are of this form (I am implicitly using something called the Factor Theorem here, which says that a polynomial has a root if and only if for some other polynomial of degree one less than ). What is ? We want it to pass through the point , so we want . This leads us to , so that . And so
As we can see, the picture looks like a reasonable approximation for near , but as we get farther away from , it gets worse.
Earlier, we managed to determine a line with either 2 points, or a point and a slope. Intuitively, this is because lines look like , so there are two unknowns. Thus it takes pieces of information to figure out the line, be they points or a point and a direction. So for a parabola , it takes three pieces of information. We’ve done it for three points. We can also do it for a point, a slope, and a concavity, or rather a point, the derivative at that point, and the second derivative at that point.
Let’s follow this idea to find another quadratic approximate, which I’ll denote by in parallel to my notation above, for around . We’ll want , , and , since and . How we we find such a polynomial? The “long” way would be to call it and create the system of linear equations
and to solve them. We immediately see that , which lets us see that , which lets us see that . This yields
The “clever” way is to write the polynomial in the form , since then (as the other terms have a factor of ). When you differentiate in this form, you get , so that . And when you differentiate again, you get , so that . This has the advantange of allowing us to simply read off the answer without worrying about solving the system of linear equations. Putting these together gives
And if you check (you should!), you see that these two forms of are equal. This feels very “mathlike” to me. These approximations look like
Comparing the two is insteresting. is okay near , then gets a bit worse, but then gets a little better again near and . But is extremely good near , and then gets worse and worse.
1.3. Cubic approximation
You can see that gives us a better approximation than for close to , just as was better than for near . Let’s do one more: cubic polynomials. Let’s use the points and to generate . This yields
Showing this calculation is true leads us a bit further afield, but we’ll jump right in. Four points, so if we wanted to we could create a system of linear equations as we did above for and solve. It may even be a good refresher on solving systems of linear equations. But that’s not how we are going to approach this problem today. Instead, we’re going to be a bit “clever” again.
Here’s the plan: find a polynomial-part that takes the right value at and is at and . Do the same for the other three points. Add these together. This is reasonable since it’s easy to find a cubic that’s at the points and : it’s . We want to choose the value of so that this piece is when . This leads us to choosing
In other words, this polynomial part is
Written in this form, it’s easy to see that it is at the three points where we want it to be , and it takes the right value at . Notice how similar this was in feel to our work for the quadratic part. Doing the same sort of thing for the other three points and adding all four together yields a cubic polynomial (since all four subparts are cubic) that takes the correct values at 4 points. Since there is only 1 cubic that goes through those four points (since four points determine a cubic), we have found it. Aside: this is just a few steps away from being a full note about Lagrange polynomial interpolation This looks like
These points were chosen symmetrically around so that this might be a reasonable approximation when is close to . How will compare to , the approximating polynomial determined by and his derivatives at ? Our four pieces of information now will be and . Writing first as , we see that , and . This lets us read off the coefficients: we have , so that in total
which looks like
These look very similar. Which one is better? Let’s compare the differences between and with the differences between and in graph form. This next picture shows , or rather the error in the approximation of by . What we want is for this graph to be , since this means that is exactly , or as close to as possible. Since the approximation is so good, the picture is very zoomed in.
Notice that the y-axis is labelled by “1e-3”, which meand . So the error is within , which is very small (we really zoomed in). As you can see, the error is a bit weird. It oscillates a little, and is a bit hard to predict. Now let’s look at the picture of .
This error is very easy to predict, and again we can see that it is extremely accurate near the point we used to generate the approximation (which is in this case). As we get further away, it gets worse, but it is far more accurate and more predictably accurate in the center. Further, was easier to generate than , and it gives four decimal places of accuracy near while can only give two. So maybe there is something special to these polynomials. Let’s look into them more.
Aside: people spend a lot of time on these interpolating problems. If this is something you are interested in, let me know and I can direct you to further avenues of learning about them
2. Taylor Polynomials
The idea that the polynomials were better approximates than around the central point, as we saw above, led to the polynomials getting a special name: they are called “Taylor Polynomials.” This might not be how you’ve seen Taylor polynomials introduced before, but this is where they really come from. And this is what keeps the right intuition. Just as the first derivative is the “best linear approximation,” these Taylor Polynomials give the best quadratic approximation, cubic approximation, etc. Let’s get the next few Taylor polynomials for for near .
We saw that . And the way we got this was by calculating and its first three derivatives at (giving us 4 pieces of information), and finding the unique cubic polynomial satisfying those four pieces of information. So to get more accuracy, we might try to include more derivatives. So let’s use the and its first four derivatives at . These are , and . Writing , we expect . Since the fourth derivative is , we get the same polynomial as before! We get . But before we go on, notice that the constant term came from evaluating , the coefficient of came from evaluating , the coefficient of came from , the coefficient of came from , and the coefficient of came from . These are exactly the same expressions that came up for and from before.
This is something very convenient. We see that the coefficient of in our polynomials depends only of the th derivative of . So to find , I don’t need to recalculate all the coefficients. I just need to realize that the coefficient of will come from the fifth derivative of at (which happens to be ). And to get this, we would have differentiated five times, giving us an extra , so that the coefficient is . All told, this means that
and that this is the best degree approximation around the point . Pictorally, we see
Now that we’ve seen the pattern, we can write the general degree Taylor polynomial ,, approximation for :
The next images shows increasingly higher order Taylor approximations to . Worse approximations are more orange, better are closer to blue.
What we’ve done so far extends very generally. The degree polynomial that agrees with the value and first derivatives of a function at approximates the function for values of near , and in general these polynomials are given by
This prompts two big questions. First: how good are these approximations? And second, since using more derivatives gives us better approximations, does using “all” the derivatives give us the whole function? Rather, if is infinitely differentiable, is it true that ? Or is it at least true that this gives us the “best” approximation we can get from a single point?
These are big questions, and they are all inter-related. The first question leads to considering the remainder, or error, of Taylor polynomials. And the second leads us to consider infinite Taylor series associated to a function.
3. Estimating the Error of Taylor Polynomial Approximations
If we want to know how well we can expect Taylor polynomials to approximate their associated function, then we need to understand the error, or differences, between the two. We might hope that Taylor polynomials always give very good approximations, or that if we use enough terms, then we can get whatever accuracy we want.
But this is not true.
One good example is the function:
This is often called the bump function, because it looks like
which is just a little bump. The weird thing about this is that is differentiable everywhere. This isn’t obvious, because we defined it in two pieces. But it turns out that this function has a derivative even at , where the two “pieces” touch. In fact, this function is infinitely differentiable everywhere. So that’s already sort of weird. It’s weirder, though, in that all the derivatives of at are exactly (so that these derivatives are more like the derivatives of the constant function to its right than the “bump” part to its left).
So if you look at the Taylor polynomials for generated at the point , then you would get for all (all the derivatives are ). These Taylor polynomials do a terrible job of approximating the bump function.
It turns out that there are many, many functions that are very “nice” in that they have many derivatives, but which don’t have well behaved Taylor approximations. There are even functions that have many derivatives, but whose Taylor polynomials never provide good approximations, regardless of what point you choose to generate the polynomials.
To make good use of Taylor polynomial approximations, we therefore have to be a bit careful about the error in the approximations. To do this, we will use the mean value theorem. (Aside: For those keeping score, the mean value theorem gives us so much. In my previous note, I talk about how the mean value theorem gives us the fundamental theorem of calculus. Now we’ll see that it gives us Taylor series and their remainder too. This is sort of crazy, since the statement of the mean value theorem is so underwhelming.)
This also marks a turning point in this note. Suddenly, things become much less experimental and visual. We will prove things – but don’t be afraid!
The mean value theorem says that if a function is differentiable, and we choose any two numbers in the domain and , then there is a point between and so that is equal to the slope of the secant line from to . Stated differently, there is a point between and so that .
If we suppose that and (or you could keep as it is for Taylor polynomials generated at points other than ), then we get that there is some between and such that . Rearranging yields . This serves as a bound on the error of the degree Taylor polynomial at , which is just . How so? This says that the difference between and (which is our approximate in this case) is at most for some . If we happen to know that for all in , then we know that . So our error at the point is at most .
This really isn’t very good, but it is also a very bad approximate. On the other hand, this semi-trivial example contains the intuition for the proof.
To get a bound on linear approximations, we start off with the derivative of . If we apply the mean value theorem of , we get that there is some between and so that , or rather that . (This shouldn’t be a surprise – is just a function too, so we expect to get this in the same form as we had above). Here’s where we can do something interesting: let’s integrate this. In particular, let’s rewrite this in :
and let’s integrate him:
The second fundamental theorem of calculus (which is also essentially the mean value theorem!) says that . So the equation above becomes
which rearranges to
This says that the error in our linear Taylor polynomial is at most for some in . So as before, if we know a bound on the second derivative, then our error is at most . This is much better than what we had above. In particular, if our value is close to , like say less than , then the bit in the error means the error has a factor of . But as we get further away from , we expect worse error. This is why in the pictures above we see that the Taylor polynomials give very good approximations near the center of the expansion, and then get predictably worse.
Let’s do one more, to see how this works. Now we will start with the second derivative. The mean value theorem says again that . Writing this in and integrating both sides, we get
(This shouldn’t surprise us either, since the second derivative is just a function. So of course it has a first order expansion just like we saw above.) Let’s again write this in and integrate both sides,
for some between and . Now we see that the approximations are getting better. Firstly, for near , we now get a cubic factor in the error term. So if we were interested in around , now the error would get a factor of . That’s pretty good. We also see that there is a rising factorial in the denominator of the error term. If there is anything to know about factorials, it’s that they grow very, very fast. So we might hope that this factorial increases with higher derivatives so that the error is even better. (And this is the case).
So the only possible bad thing in this error term is that is not well-behaved, or is not very small, or is very hard to understand. And in these cases, the error might be very large. This is the case with the bump function above – the derivatives grow too rapidly.
If you were to continue this process, you would see that the general pattern is
for some between and . And this is where the commonly quoted Taylor remainder estimate comes from:
where is the maximum value that takes on the interval .
There are other ways of getting estimates on the error of Taylor polynomials, but this is by far my favorite. Now that we have estimates for the error, how can we put that to good use?
Let’s go back to thinking about the Taylor polynomials for that was the source of all the pictures above. What can we say about the error of the degree Taylor polynomial for ? We can say a lot! The derivatives of go in a circle: . And all of these are always bounded below by and above by . So the st derivative of is always bounded by . By the remainder we derived above, this means that
For small , this converges really, really fast – this is why the successive approximations above were so accurate. But it also happens that as gets bigger, the factorial in the denominator grows very fast too – so we get better and better approximations even for not small . This prompts another question: what would happen if we kept on including more and more terms? What could we say then? This brings us to the next topic.
4. Taylor Series
Now we know the th Taylor polynomial approximates very well, and increasingly well as increases. So what if we considered the limit of the Taylor polynomials? Rather, what if we considered
This is a portal into much deeper mathematics, and is the path that many of the mathematical giants of the past followed. You see, infinite series are weird. When do they exist? Is an infinite sum of continuous functions still continuous? What about differentiable? These are big, deep questions that are beyond the scope of this note. But some of the intuition is totally within the scope of this note.
We know the error of the th Taylor polynomial to is bounded above by . If we take the limit as of the sequence of remainders, we get
and it goes to no matter what is. (Factorials grow larger than the numerator for any fixed ). So no matter what is, as we use more and more terms, the approximations become arbitrarily good. In fact, since the error goes to and is well-behaved, we have a powerful result:
That is equality. Not approximately equal to, but total equality. Some people even go so far as to define by that Taylor series. When I say Taylor series, I mean the infinite sum. People study Taylor series to try to see what information they can glean about functions from their Taylor series. For example, we know that is periodic. But how would you determine that from its Taylor series? (It’s not very easy).
It turns out that you can tell a lot about a function from its Taylor series (although not as much as we might like, and we don’t really study this in math 100). Functions that are completely equal to their Taylor series are called “analytic” functions, and analytic functions are awesome. But even Taylor polynomials are good, and used to approximate hard-to-understand things.
Aside: I do a lot of work with complex numbers (where we allow and things like that) instead of real numbers. One reason why I prefer complex numbers is that complex analytic functions, which are complex-valued functions that are exactly equal to their Taylor series, are miraculous things. Being complex analytic is totally amazing, and you can tell essentially anything you want from the Taylor series of a complex analytic function. This is to say that you are on the precipice of exciting and very deep mathematics. Of course, that’s where introductory classes stop.
We saw Taylor polynomials, some approximations, some proofs, and some Taylor series. One thing I would like to mention is that for applications, people normally use finite Taylor polynomials and show (or use, if it’s well known) that the error is small enough for the application. But Taylor polynomials are useless without some understanding of the error. In Math 100, we give a totally lackluster treatment of error estimates. Serious math and physics concentrators will probably need and use more than what we have taught – even though now is perhaps the best time to learn it. So it goes! (Others might very well use Taylor polynomials and their error, but many useful functions and their remainders are understood just as well as those for sine, which we saw here; it is not always necessary to reinvent the wheel, although it can be rewarding in less immediate ways).
I hope you made it this far. If you have any comments, questions, concerns, tips, or whatnot then feel free to leave a comment or to ask me. For additional reading, I would advise you to use only google and free materials, as everything is available for free (and I mean legally and freely available). Something I did not mention but that I’ve been thinking about is presenting a large collection of applications of Taylor series. Perhaps another time.
This note can be found online at mixedmath.wordpress.com or davidlowryduda.com under the title “An Intuitive Overview of Taylor Series.” This note was written with vim in latex, and converted to html by a modified latex2wp. Thus this document also comes in pdf and .tex code . The pdf does not include my beautiful gif, which I am always proud of. The graphics were all produced using the free mathematical software sage . Interestingly, this note was the source of sage trac 15419, which will likely result in a tiny change in sage as a whole. I highly encourage people to check sage out.
And to my students – I look forward to seeing you in class. We only have a few left.