Thursday, January 31, 2013

Taylor Polynomials

When attempting to solve certain problems, it is often useful to approximate a function as a polynomial. Polynomials are generally easier to deal with in calculus problems than other functions, and many functions can be approximated as polynomials to arbitrary precision.

The general method for producing a polynomial approximation of a function is as follows. First, choose the point that you want your approximation to be centered around. (When you’re solving a problem, you should expand your approximation around a point within the region that you’re most interested in, because Taylor Polynomial approximations are most accurate near their center, but for simplicity’s sake I’ll just pick x = 0 as the center for now, and give a more general formula later.) Once you've chosen the point that you want to expand about (in our case, x = 0), you can start writing down polynomial approximations. The simplest (and least accurate) polynomial we could use to approximate a function would just be a constant, equal to the value of the function at x = 0 (i.e. P0(x) = f(0), where "P" is a polynomial function and the subscript indicates the order of the polynomial).
Zero-Order Taylor Polynomial (magenta) for f(x) (blue)
As you can probably tell, a zero-order polynomial usually won't be sufficient to provide a useful approximation of a function. It is, of course, exactly equal to the function at x = 0, but it quickly diverges from the function as we move away from x = 0, since the function is changing its value while our approximation is not. We can do better by using a polynomial that not only has the same value as the function at x = 0, but also changes at the same rate (i.e. has the same value of its first derivative). We do this by setting P'(x) = f'(0) and then integrating:
*Remember that the derivative of f evaluated at a single
 point (x = 0) is a constant, not a function of x.
And our approximation gets a whole lot better:
First-Order Taylor Polynomial (magenta) for f(x) (blue)
Of course, f(x) isn't linear, so our first-order approximation still diverges from the function eventually. If we only need to consider small values of x, this approximation may be sufficient, but if the situation calls for accuracy at larger values of x, we need to go deeper...
To the second dream lev- ...err, derivative.
The linear approximation eventually diverges from f because, while Phas a constant slope, the slope of f is changing. To get a better approximation, we need a polynomial that not only has the same value and slope as f at x = 0, but also is changing its slope at the same rate as f(x) (i.e. P''(x) = f''(0)).
As before, we find the constants of integration by setting
the nth derivative of P equal to the nth derivative of f at x = 0.

Second-Order Taylor Polynomial (magenta) for f(x) (blue)
For increasingly better approximations, we repeat this process of setting the nth derivative of P equal to the nth derivative of f at x = 0 and then integrating, for ever-increasing values of n, so that:
In fact, if we let n go to infinity, and if f(x) is a continuous, analytic function, then the Taylor Series is exactly equivalent to the function:
Earlier I promised I'd give a generalized formula to allow for the Taylor Polynomial to be centered around any point. To do this, just replace "0" with "c," and "x
(= x - 0) with "x - c":
Obviously, you're never actually going to calculate an infinite number of terms, but luckily in many cases you can get a pretty good approximation of a function with just a few terms.

Now, you might be wondering when you'd ever want to approximate a function as a polynomial. It turns out that in certain problems, either the function that you're working with isn't explicitly known, or it's just more difficult to work with than a polynomial. For example, if you're only dealing with small angles, it'll often make it easier on you to approximate sin x as just x, and cos x as 1 - x(It's this approximation that allows us to describe the motion of a pendulum bob as simple-harmonic, as long as the maximum displacement angle is small).

No comments:

Post a Comment