Taylor series are infinite series of a particular type. They are extremely important in practical mathematics. Very often we are faced with using functions that aren't that easy to use, like exponential and logarithmic functions, or trigonometric functions, or tricky combinations of those, and life gets much simpler if we can replace them with something that's easier to work with.
Taylor series are polynomial series that can be used to approximate other functions, in most cases to arbitrary precision, as long as we're willing to use terms of high-enough degree. They aren't difficult to come up with, either – you'll see.
We'll start by reviewing linear approximations of functions.
We showed that the linear approximation of a function f near a point x = a in its domain is
Let's just review how that was derived. Look at the figure below. It shows a function, f(x), and its linear approximation, L(x) near the point (a, f(a)). Remember that any function, when we view it closely enough, looks approximately linear. We can approximate a curve in the region around a point, a, in its domain by a line that has the same slope as the curve at x = a, and is tangent to f(x) there, too. Using the approximation, we can estimate values of the function in the domain around x = a.
Here's how we derive L(x). Start with the linear equation y = mx + b, and plug in the slope and the y-intercept.
Notice that f'(a) is the slope of f(x) at x = a, and f(a) - f'(a)·a is just b = y - mx, the y-intercept. Substituting the quantities in blue into the linear equation y = mx + b and rearranging, we get:
There are two features of linear approximation that we will use in developing even better polynomial approximations of functions. They are
In what follows, we'll further insist that all derivatives of the function and its approximation must be the same at x = a. It's all in the green box below.
The linear approximation of a function f(x) near x = a (left), and for x = 0 (right) follows from the well-known formula of a line from its slope, m, and a point, (xo, yo): y - yo = m(x - xo)
Take a look at the plot of f(x) = cos(x) below (thick black curve). Superimposed on it are the graphs of three successively better approximations, each centered around x = 0. They are linear, quadratic and quartic approximations.
Notice that we haven't included any odd polynomial terms
Finally, the dashed green curve includes a quartic term, and clearly it matches cos(x) quite well over the region shown, even relatively far from x = 0.
In the linear approximation, we made the assumptions that the value of the approximation and its slope should be the same at the point x = a. That just makes sense.
Well, we can generalize that kind of thinking to higher derivatives. It's also a reasonable goal to expect the curvature of a better approximation to match the curvature of the function we're trying to approximate.
If the curvature of f(x) is concave-downward, then our approximation should be, too. And that means that both the function and the approximation should have the same second derivative.
We might also insist that the change in curvature (the third derivative) be the same ... and so on.
In order for a polynomial function P(x) to be a good approximation of a function f(x),
Let's explore the derivation of a Taylor-series approximation of a function by making a polynomial approximation of the exponential function,
Our approximation will take the form of a 5th degree polynomial with unknown coefficients. I've chosen five terms because it's enough to show that important patterns emerge, but there's nothing special about 5. It looks like this:
Now we said above that the function and all of its derivatives have to be the equal at the point in which we're interested. We'll center this approximation about x = 0 for convenience. Here are the derivatives of the function, those derivatives evaluated at x = 0, and the corresponding derivatives of our approximation, g(x).
We often write the first, second and third derivatives of a function f(x) as f'(x), f''(x) and f'''(x), but writing all those primes gets tedious for higher derivatives, so we write f(4)(x) for the fourth derivative, f(5)(x) for the fifth, and so on.
Now if we equate g(0) = f(0), g'(0) = f'(0), and so on, we can solve for the coefficients, A, B, C, D & E, of our polynomial, g(x).
The resulting polynomial, just a sum of these terms, looks like this:
Now if we recognize some patterns, including that the factorial function is hidden in those denominators [recall that n! = n(n-1)(n-2) ... 3·2·1, and 0! = 1].
This pattern will continue indefinitely, and we can write the series approximation in shorthand like this:
We can use this sum with x = 1 to estimate the value of e = e1. Here's a table from a spreadsheet. Each row represents one more term added to the series. Notice that each successive term adds a smaller number onto the sum. This series is said to converge to a limit of ex.
The table shows successive values of n, n! and 1/n! used in the series approximation of ex. Notice that each new term is smaller than the previous one. That is, the size of the next term is decreasing.
As terms are added to our series approximation of ex, terms nearest the decimal point begin to be fixed and no longer change (green). This is called convergence, and we say that the series is converging to the number e. If more precision is required, we just add more terms to the series.
For more on the transcendental number e, the base of all continuously-growing exponential functions, you might want to check out the exponential functions section.
Animation: Here is an animation of the first few terms of the series we just derived, centered at x = 0. This animation may not show up too well on a smaller device like a phone. I'm working on that, so stand by.
If we go back to our derivation of the series approximation of f(x) = ex, we can see that a general formula for the series approximation of any differentiable function centered around x = 0 is:
Here f(n)(0) is the nth derivative of f(x) evaluated at x = 0. In the special case where x = 0, the Taylor series is called a MacLaurin series.
The MacLaurin series is a Taylor series approximation of a function f(x) centered at x = 0. f(n)(0) are the nth derivatives of f(x) evaluated at x = 0.
If we choose to center our approximation at some other point, x = a, in the domain of f(x), then any value we calculate from the approximation will be at (x - a), and we just evaluate the derivatives at x = a. The generalized Taylor series looks like this:
Notice that if a = 0, we just end up with the MacLaurin series formula.
Because this approximation will be centered at x = 0, it's a MacLaurin series.
To stay organized, try making yourself a table of derivatives, derivatives evaluated at x = 0, and terms of the series.
Be on the lookout for patterns as you calculate the terms of the series. Looking at the right column of the table it's pretty obvious that terms with even powers of x drop out because the derivative is zero. It also appears that the sign of each term alternates between positive and negative.
If we write the remaining terms out, we can speculate (intelligently) on further terms, such as the last term (
Finally, we should try to capture that series of terms in compact summation notation. We try always to start the index, n, at zero, but sometimes it just isn't convenient. It works fine here, though. The alternating sign is represented by (-1)n, giving us 1 for n = 0, -1 for n = 1, and so on. The exponent and factorial terms are 2n+1 and (2n+1)! to ensure only odd numbers.
Notice that this is a general Taylor series, not a MacLaurin series.
First, organize and set up a table of f(n)(x), f(n)(1) and the terms of the series (right).
Notice that in this example we've centered the approximation on x = 1 because ln(x) is not defined at x = 0.
You might need to take a minute to work out those derivatives for yourself, but they're correct. The first term of the series vanishes but the successive terms are quite predictable and alternate sign, + - + -.
The terms of the series are summed below. Try to notice the patterns and ask how you might extend the series by one or two more terms.
Now notice that the numerators of the fractions of each term are the factorials 0!, 1!, 2!, ... :
If we use the definition of factorials, e.g. 3! = 3 · 2 · 1, it's easy to see how the factorial ratios above can be reduced, like this:
So we can rewrite our series in its simplest form:
Finally, write the summation notation. It's easier, in this case, to start with n = 1 in the sum, and the (-1)n+1 term provides the right alternation of sign. You'll have to do set up these summations with a fair bit of trial and error before you develop some intuition for it. Don't worry – it'll happen with some practice.
The expansion is:
First we'll calculate the derivatives. These derivatives get more complicated with each round. Here are the first five:
The green highlights are the only parts of these derivatives that survive x = 0. All of the tangent terms vanish because tan(0) = 0, whereas sec(0) = 1.
The derivatives, evaluated at x = 0, are:
Now we can construct the MacLaurin series. Notice that only odd powers of x are present.
Note: We could find other representations of this function, for example, by using the trig. identity sec2(x) = tan2(x) + 1 in the derivatives above.
Getting rid of the zero terms gives us the series expansion. Here I've included an x7 term. As far as I know, there's no convenient formula for those coefficients: 1, 2, 4, 16, 272, ..., so I'll leave them as they are.
Finally, let's calculate some values of tan(x) using this expansion and a calculator, and we can compare the results. In the table below, tan(x) is calculated using the first four terms of our expansion (to the x7 term) and a calculator, which presumably uses a more efficient algorithm for calculating the tangent.
The expansion is very accurate up to about a unit away from x = 0, where it falls apart a bit. Because of the large exponents and factorials involved in this expansion, it is an inefficient algorithm for calculating tangents to high precision far from the center of the expansion.
In this example, we'll find the MacLaurin series for f(x) = sin2(x) by the direct method — finding derivatives, evaluating them at x = 0, and so on, and then by squaring part of the MacLaurin series for f(x) = sin(x).
First we need some derivatives. Many will vanish when evaluated at x = 0, so let's go through the painstaking process of calculating a bunch of them:
Evaluating these at x = 0 gives:
Collecting the nonzero terms in our series formula gives:
We can reduce the fractions by expanding the factorials to get this series:
Now let's do this by squaring the first three terms of the MacLaurin series (in example 1 above) for sin(x):
Squaring the first three terms means squaring a trinomial:
That's a little tedious, but the result, after collecting terms of like powers of x, is:
Here again, we can reduce the numerical parts to get a pretty good approximation of our series. The last two terms don't match the one we got from the direct method, but that's because we only squared the first three terms of the sine series.
Still, this method represents a powerful feature of series, namely that we can do many operations with them, some that would be more difficult with the original function.
This site is a one-person operation. If you can manage it, I'd appreciate anything you could give to help defray the cost of keeping up the domain name, server, search service and my time.
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2012, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to firstname.lastname@example.org.