# Taylor Series

(Difference between revisions)
 Revision as of 15:21, 17 July 2012 (edit)← Previous diff Current revision (14:56, 26 July 2013) (edit) (undo) (126 intermediate revisions not shown.) Line 2: Line 2: |ImageName=Taylor Series |ImageName=Taylor Series |Image=Taylor Main.gif |Image=Taylor Main.gif - |ImageIntro=
A Taylor series, or Taylor polynomial, is a function's polynomial expansion that approximates the value of this function around a certain point. For example, the animation at right shows the function ''y'' = sin(''x'') and its expanded Taylor series around the origin: + |ImageIntro= -
+ Taylor series and Taylor polynomials allow us to approximate functions that are otherwise difficult to calculate. The image at the right, for example, shows how successive Taylor polynomials come to better approximate the function sin(''x''). In this page, we will focus on how such approximations might be obtained as well as how the error of such approximations might be bounded. - ::$\sin (x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} ... + \sin({n\pi \over 2}) \cdot {x^n \over n!}$ + -
+ |ImageDescElem= - :with ''n'' varying from 0 to 36. As we can see, the larger ''n'' is, the more terms we will have in the Taylor polynomial, and the more it looks like the original function. If ''n'' goes to infinity, then our approximating polynomial will be identical to the original function ''y'' = sin(''x''). + A '''Taylor series''' is a {{EasyBalloon|Link=power series|Balloon=an infinite series of the form $f(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots$}} representation of an [[Differentiability|infinitely differentiable]] function. In other words, many functions, like the trigonometric functions, can be written alternatively as an ''infinite'' series of terms. -
+ - :For the math behind this, please go to the [[#MME|More Mathematical Explanation]] section. + An ''n''th-degree '''Taylor polynomial''' $P_n(x) for a function is the sum of the first ''n'' terms of a Taylor series. As a finite series, a Taylor polynomial can be computed exactly (no limits needed). Although it will not exactly match the infinite Taylor series or the original function, the approximation becomes progressively better as ''n'' increases. - |ImageDescElem= + - {{Anchor|Reference=Figure1-a|Link=[[Image:TIcalculator.jpg|left|thumb|300px|Figure 1-a A modern TI calculator]]}} + - + In the animation above, Taylor polynomials are compared to the actual function ''y'' = sin(''x'') using the following polynomial expansion: - Have you ever wondered how calculators work? How do they calculate square roots, sines, cosines, and exponentials? For example, if we type the sine of an angle into our calculator, then it will magically spit out a number. We know this number must be related to our input in some way, but what exactly is this relationship? Is the calculator just reading off of a list created from people who used rulers to physically measure the distance on a graph, or is there a more mathematical relationship? + - + :[itex]\sin(x) \approx P_n(x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} + \cdots \pm {x^n \over n!}$    (for odd ''n'') - The answer to the last question above is yes. There are algorithms that give an approximate value of sine, using only the four basic operations (+, -, x, /)[http://www.homeschoolmath.net/teaching/sine_calculator.php How does the calculator find values of sine], from homeschoolmath. This is an article about calculator programs for approximating functions.. Mathematicians studied these algorithms in order to calculate these functions manually before the age of electronic calculators. One such algorithm is given by the '''Taylor series''', named after English mathematician Brook Taylor. Basically, Taylor said that there is a way to expand any [[Differentiability|infinitely differentiable]] function into a polynomial series around a certain point. This process uses a fair amount of single variable calculus, which will be explained in the [[#MME|More Mathematical Explanation]] section. Here we will only give some examples of Taylor series without explanation: + -

+ ''n'' varies from 0 to 36. As ''n'' becomes larger and there are more terms in the Taylor polynomial, the Taylor polynomial comes to "look" more like the original function. In other words, it becomes a progressively better approximation of the function; it becomes more accurate. -
+ - :$\sin (x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} + {x^9 \over 9!} \cdots$ , expanded around the origin. ''x'' is in [[Radians|radians]]. + How does one construct a Taylor series? As mentioned, Taylor series can be used to approximate infinitely differentiable functions. A Taylor polynomial, as will be shown later in the [[#MME|More Mathematical Explanation]], is actually constructed according to the derivatives of a function at a certain point. The key idea behind Taylor series is this: Derivatives, roughly speaking, correspond to the shape of a curve, so the more derivatives that two functions have in common at one point, the more similar they will look at other nearby points. -
+ - :$\cos (x) = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + {x^8 \over 8!} \cdots$ , expanded around the origin. ''x'' is in [[Radians|radians]]. + Taylor series are important because they allow us to compute functions that cannot be computed directly. While the above Taylor polynomial for the sine function looks complicated and is annoying to evaluate by hand, it ''is'' just the sum of terms consisting of exponents and factorials, so the Taylor polynomial can be reduced to the basic operations of addition, subtraction, multiplication, and division. We can obtain an approximation by truncating the infinite Taylor series into a finite-degree Taylor polynomial, which we can evaluate. -
+ - :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + {x^5 \over 5!} \cdots$ , expanded around the origin. ''e'' is [http://en.wikipedia.org/wiki/E_(mathematical_constant) Euler's number], approximately equal to 2.71828··· + The Taylor series for sine may not seem very useful to us, since we are used to hitting the sine function on our calculator which then spits out an answer. But our calculators actually make use of similar series to approximate the trigonometric functions, as well as other functions, to provide us with a decimal approximation. Likewise, physicists often take measurements and produce curves that do not clearly resemble a known function. However, they can use Taylor series to come up with a working model, even if it is not exact. -
+ - :$\log (x) = (x-1) - {(x-1)^2 \over 2} + {(x-1)^3 \over 3} - {(x-1)^4 \over 4} \cdots$ , expanded around the point ''x'' = 1. + -
+ -

+ - With Taylor polynomials in hand, we can easily calculate the numerical value of these functions. For example, if we want to calculate: + - {{Anchor|Reference=Figure1-b|Link=[[Image:TaylorApproximate1ed.jpg|right|thumb|325px|Figure 1-b
3-term-approximation of function ''y'' = cos(''x'')
Click for an image of higher resolution]]}} + - {{Anchor|Reference=Figure1-c|Link=[[Image:TaylorApproximate2.jpg|right|thumb|325px|Figure 1-c
The above approximation zoomed in 2,000 times
Click for an image of higher resolution]]}} + -
+ - :$\cos 30^\circ$ + -

+ - first we need to convert degrees to [[Radians|radians]] in order to use the Taylor series: + -

+ - :$\cos 30^\circ = \cos {\pi \over 6} = \cos 0.523599 \cdots$ + -

+ - then, substitute into the Taylor series of cosine above: + -

+ - :$\cos (0.523599 rad) = 1 - {0.523599^2 \over 2!} + {0.523599^4 \over 4!} - \cdots$ + -

+ - Here we only used 3 terms, since this should be enough to tell us something. Notice that the right side of the equation above involves only the four simple operations, so we can easily calculate its value: + -

+ - :$\cos (0.523599 rad) = 0.866053 \cdots + - + - On the other hand, trigonometry tells us the exact numerical value of this particular cosine: + - + - :[itex]\cos 30^\circ = {\sqrt 3 \over 2} = 0.866025 \cdots$ + -

+ - So our approximating value agrees with the actual value to the fourth digit, which is good accuracy for a 3-term-long approximation. Of course, better accuracy can be achieved by using more terms in the Taylor series. + -

+ - We can get the same conclusion if we graph the original cosine function and its approximation together as shown in [[#Figure1-b|Figure 1-b]]. We can see that the original function and the approximating Taylor series are almost identical when x is small. In particular, the line ''x'' = π/6 cuts the two graphs almost simultaneously, so there is not much difference between the exact value and the approximating value. However, this doesn't mean that these two functions are exactly the same. For example, when ''x'' grows larger, they start to deviate significantly from each other. What's more, if we zoom in the graph at the intersection point, as shown in [[#Figure1-c|Figure 1-c]], we can see that there is indeed a tiny difference between these two functions, which we cannot see in a graph of normal scale. + -

+ - The calculator's algorithm is an improved version of this method. It may be more efficient, more accurate, and more general, but it still evaluates the numerical value of a polynomial series. This algorithm is built in the permanent memory (ROM) of electronic calculators, and is triggered every time we enter the function[http://en.wikipedia.org/wiki/Calculator Calculator], from Wikipedia. This article explains the structure of an electronic calculator.. + -

+
- |ImageDesc=
+ |ImageDesc= - ==How to derive Taylor Series from a given function== + ==Basic Use of Taylor Series== -
+ Readers may, without knowing it, already be familiar with a particular type of Taylor series. Consider an infinite geometric series with first term 1 and common ratio ''x'': - In this subsection, we are going to derive an explicit and general expression of a function's Taylor series, using only the derivatives of the given function ''f''(''x''). + -

+ :{1 \over {1-x}} = 1 + x + x^2 + x^3 + \cdots[/itex] for $-1 < x < 1 - Mathematically, Taylor polynomials and Taylor series can be defined in the following way: + - + The left side of the equation is the formula for the sum of the [[Convergence|convergent]] geometric series on the right. The right side is also an infinite power series, so it is the Taylor series for [itex]f (x) = {1 \over {1-x}}$. Later we will provide examples of some other Taylor series, as well as the process for deriving them from the original functions. - :The '''Taylor polynomial of degree ''n'' for ''f'' at ''a''''', written as $P _n (x)$, is the polynomial that has the same 0th to ''n''th order derivatives as function ''f''(''x'') at point ''a''. In other words, the nth degree Taylor polynomial must satisfy: + -
+ Using Taylor series, we can approximate infinitely differentiable functions. For example, imagine that we want to approximate the sum of the infinite geometric series with first term 1 and common ratio $x = {1 \over 4}$. Using our knowledge of infinite geometric series, we know that the sum is ${1 \over {1 - {1 \over 4}}} = {4 \over 3} = 1.333 \cdots$. Let's see how the Taylor approximation does: - ::$P _n (a) = f (a)$ (the 0th order derivative of a function is just itself) + -
+ :${P_2 \left({1 \over 4}\right) =} 1 + {1 \over 4} + \left({1 \over 4}\right)^2 = 1.3125$ + + This second-order Taylor polynomial brings us somewhat close to the value of $4 \over 3$ that we obtained above. Let's observe how adding on another term can improve our estimate: + + :${P_3 \left({1 \over 4}\right) =} 1 + {1 \over 4} + \left({1 \over 4}\right)^2 + \left({1 \over 4}\right)^3 = 1.328125$ + + As we expect, this approximation is closer still to the actual value, but not exact. Adding more terms would improve this accuracy further, but so long as the amount of terms that we add is finite, the approximation will never be exact. + + + {{Anchor|Reference=Figure1|Link=[[Image:Taylor cos35 zoom.gif|right|thumb|360px|Figure 1
Top: The function cos(''x'') (blue) and its 4th degree Taylor polynomial (red).

Bottom: The approximation of cos(35°) zoomed in 2,000 times.]]}} + At this point, you may be wondering what the use of a Taylor series approximation is if, as in the previous example, + we don't need an estimate; we already have the ''exact'' answer on the left-hand side. Well, we don't always know the exact answer. For instance, a more complicated Taylor series is that of cos(''x''): + + :$\cos (x) = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + \cdots$ where ''x'' is in [[Radians|radians]]. + + In this case, it is easy to select ''x'' so that we cannot exactly evaluate the left-hand side of the equation. For such functions, making an approximation can be more valuable. For instance, consider: + + :\cos 35^\circ + + First we must convert degrees to [[Radians|radians]] in order to use the Taylor series: + + :$\cos 35^\circ = \cos \left({35 \over 180} \pi \right) \approx \cos 0.610865$ + + Then, substitute into the Taylor series of cosine above: + + :$\cos (0.610865) \approx 1 - {0.610865^2 \over 2!} + {0.610865^4 \over 4!}$ + + Here we have written the 4th-degree Taylor polynomial, but this should be enough to show us something. The right side of the equation can be reduced to the four simple operations, so we can easily calculate its value: + + :\cos (0.610865) \approx 0.81922 + + We can compare this to the value given by the calculator. The calculator's value, actually, is also an approximation obtained by a similar method, but we can expect it to be accurate for all displayed decimal places. + + :$\cos 35^\circ = 0.81915 \cdots$ + + So our approximating value agrees with the "actual" value to three decimal places, which is good accuracy for a basic approximation. As above, better accuracy could be attained by using more terms in the Taylor series. + + This result can be observed if we zoom in on the point at which we are evaluating the function, as shown in [[#Figure1|Figure 1]]. In the large graph, the functions look almost identical at the point ''x'' = 35°, but there is indeed a difference between these two functions, as the zoomed-in version shows. + + ==The General Form of a Taylor Series== + In this subsection, we will derive the general formula for a function's Taylor series. We begin by defining Taylor polynomials as follows: + + :The '''Taylor polynomial of degree ''n'' for ''f'' at ''a''''', written $P _n (x)$, is the polynomial that has the same 0th- to ''n''th-order derivatives as function ''f''(''x'') at point ''a''. In other words, the nth-degree Taylor polynomial must satisfy: + + ::$P _n (a) = f (a)$ (the 0th-order derivative of a function is itself) + ::$P _n ' (a) = f ' (a)$ ::$P _n ' (a) = f ' (a)$ -
+ ::$P _n '' (a) = f '' (a)$ ::$P _n '' (a) = f '' (a)$ ::::$\vdots$ ::::$\vdots$ ::$P _n ^{(n)} (a) = f^{(n)} (a)$ ::$P _n ^{(n)} (a) = f^{(n)} (a)$ -
+ - :in which $P _n ^{(k)} (a)$ is the kth order derivative of $P _n (x)$ at ''a''. + :where $P _n ^{(k)} (a)$ is the kth-order derivative of $P _n (x)$ at ''a''. -
+ - :The '''Taylor series''' $T (x)$ is just $P _n (x)$ with infinitely large degree ''n''. Notice the ''f'' must be infinitely differentiable in order to have a Taylor series. + We define Taylor series as follows: -
+ - The following set of images show some examples of Taylor polynomials, from 0th order to 2nd order: + :The '''Taylor series''' $T (x)$ is the infinite Taylor polynomial for which ''all'' derivatives at ''a'' are equal to those of $f (x)$. -

+ + The following set of images show some examples of Taylor polynomials, from 0th- to 2nd-order: + {{{!}}border="0" cellpadding=5 cellspacing=5 {{{!}}border="0" cellpadding=5 cellspacing=5 - {{!}}{{Anchor|Reference=Figure2a|Link=[[Image:TaylorPoly0ed.jpg|center|thumb|325px|Figure 2-a
0th degree Taylor Polynomial]]}}{{!}}{{!}}{{Anchor|Reference=Figure2b|Link=[[Image:TaylorPoly1ed.jpg|center|thumb|325px|Figure 2-b
first degree Taylor Polynomial]]}}{{!}}{{!}}{{Anchor|Reference=Figure2c|Link=[[Image:TaylorPoly2ed2.jpg|center|thumb|325px|Figure 2-c
second degree Taylor Polynomial]]}} + {{!}}{{Anchor|Reference=Figure2a|Link=[[Image:TaylorPoly0ed.jpg|center|thumb|325px|Figure 2a
A 0th-degree Taylor polynomial.]]}}{{!}}{{!}}{{Anchor|Reference=Figure2b|Link=[[Image:TaylorPoly1ed.jpg|center|thumb|325px|Figure 2b
A first-degree Taylor polynomial.]]}}{{!}}{{!}}{{Anchor|Reference=Figure2c|Link=[[Image:TaylorPoly2ed2.jpg|center|thumb|325px|Figure 2c
A second degree Taylor polynomial.]]}} {{!}}} {{!}}} -
+ - From the definition above, the function ''f'' and its 0th order Taylor polynomial $P _0 (x)$ must have the same 0th order derivatives at ''a''. Since the 0th order derivative of a function is just itself by definition, we have: + In order to construct a general formula for a Taylor series, we start with what we know: a Taylor series is a power series. Using the definition of power series, we write a general Taylor series for a function ''f'' around ''a'' as -

+ - :$P _0 ^{(0)} (a) = P _0 (a) = f(a)$ + :{{EquationRef2|Eq. 1}} $T(x) = a_0 + a_1 (x-a)+ a_2 (x-a)^2 + a_3 (x-a)^3 + \cdots$, -
+ - which gives us the horizontal line shown in [[#Figure2a|Figure 2-a]]. This is certainly not a very close approximation. So we need to add more terms. + in which a0, a1, a2, ... are unknown coefficients. Our goal is to find a more useful expression for these coefficients. -

+ - The first order Taylor polynomial $P _1 (x)$ must satisfy: + By definition of a Taylor polynomial, we know that the function $f(x)$ and Taylor series $T(x)$ must have the same derivatives of all degrees evaluated at ''a'': -

+ - :$\left\{ \begin{array}{rcl} P _1 (a) & \mbox{=} & f(a) \\ P _1 ' (a) & \mbox{=} & f ' (a)\end{array}\right.$ + :$T(a) = f(a)$,    $T'(a) = f'(a)$,     $T''(a) = f''(a)$,   $T ^{(3)} (a) = f ^{(3)} (a) \cdots$ -
+ - which gives us the linear approximation shown in [[#Figure2b|Figure 2-b]]. This approximation is much better than the 0th order one. + How might we use this fact to bring us closer to finding the coefficients a0, a1, a2, ...? Let's start by taking the first few derivatives of {{EquationNote|Eq. 1}}: -

+ - Similarly, the second degree Taylor polynomial $P _2 (x)$ must satisfy: + :$T(x) = a_0 + a_1 (x-a) + a_2 (x-a)^2 + a_3 (x-a)^3 + \cdots$ -

+ - :$\left\{ \begin{array}{rcl} P _2 (a) & \mbox{=} & f(a) \\ P _2 ' (a) & \mbox{=} & f ' (a) \\ P _2 '' (a) & \mbox{=} & f '' (a)\end{array}\right.$ + :$T'(x) = 1 a_1 + 2 a_2 (x-a) + 3 a_3 (x-a)^2 + 4 a_4 (x-a)^3 + \cdots$ -
+ - which gives us the quadratic approximation shown in [[#Figure2c|Figure 2-c]]. This is the best approximation so far. + :T''(x) = 2\cdot 1 a_2 + 3 \cdot 2 a_3 (x-a) + 4 \cdot 3 a_4 (x-a)^2 + 5 \cdot 4 a_5 (x-a)^3 + \cdots -

+ - As we can see, the quality of our approximation increases as we add more terms to the Taylor polynomial. Since Taylor series is the Taylor polynomial of infinitely large degree, it should be a perfect approximation - identical to the original function. + :$T^{(3)}(x) = 3 \cdot 2 \cdot 1 a_3 + 4 \cdot 3 \cdot 2 a_4 (x-a) + 5 \cdot 4 \cdot 3 a_5 (x-a)^2 + \cdots$ -

+ - Taylor proved that such a series $T(x)$ must exist for every infinitely differentiable function ''f''. In fact, without loss of generality, we can write the Taylor series of a function ''f'' around ''a'' as + :$T^{(4)}(x) = 4 \cdot 3 \cdot 2 \cdot 1 a_4 + 5 \cdot 4 \cdot 3 \cdot 2 a_5 (x-a) + 6 \cdot 5 \cdot 4 \cdot 3 a_6 (x-a)^2 + \cdots$ -

+ - :{{EquationRef2|Eq. 1}} $T(x) = a_0 + a_1 (x-a)+ a_2 (x-a)^2 + a_3 (x-a)^3 + \cdots$ + The pattern should now be recognizable, and it may be apparent how to solve for ''ak''. When we evaluate any of the above derivatives at ''x'' = ''a'', ''only the constant term will remain'' because all terms with (''x'' - ''a'') go to 0. Note then what happens after ''k'' derivatives. We get: -
+ - in which a0, a1, a2 ... are unknown coefficients. What's more, from the definition of Taylor polynomials, we know that function ''f'' and Taylor series $T(x)$ must have same derivatives of all degrees: + :$T ^{(k)} (a) = k! \cdot a_k$. -

+ - :$T(a) = f(a)$ , $T'(a) = f'(a)$ , $T''(a) = f''(a)$ , $T ^{(3)} (a) = f ^{(3)} (a) \cdots$ + Since in addition $T ^{(k)} (a) = f^{(k)}(a)$ by definition, we conclude -
+ - Using the constraints above, we can determine the value of all unknown coefficients in {{EquationNote|Eq. 1}}. Just substitute $T ^{(n)} (a) = f ^{(n)} (a)$ into {{EquationNote|Eq. 1}} and we can get: + :f^{(k)}(a) = k! \cdot a_k, -

+ - :$T ^{(n)} (a) = n! \cdot a_n = f ^{(n)}(a)$ + so -
+ - in which the terms before an vanished because their associated power of (''x'' - ''a'' ) didn't survive taking derivatives for ''n'' times. The terms after an vanished because there are still (''x'' - ''a'' ) terms left, which make them equal to 0 when ''x'' = ''a''. So we are left with this simple equation, from which we can directly get: + :$a_k = {f ^{(k)}(a) \over k!}$. -

+ - :$a_n = {f ^{(n)}(a) \over n!}$ + This formula even holds for ''k''=0, since -
+ 0! = 1. Thus it holds for all non-negative integers ''k''. So, using derivatives, we have obtained an expression for all unknown coefficients of ''T''(''k'') (''x'') in terms of the given function ''f''. Substitute this back into {{EquationNote|Eq. 1}} to get an explicit expression of Taylor series: - If we agree to define 0! = 1, then this formula holds for all non-negative integers ''n'' from 0 to infinity. So we have determined the value of all unknown coefficients using derivatives of the given function ''f''. Substitute them back into {{EquationNote|Eq. 1}} to get an explicit expression of Taylor series: + -

+ :{{EquationRef2|Eq. 2}}$T(x) = f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2+\frac{f^{(3)}(a)}{3!}(x-a)^3+ \cdots$ :{{EquationRef2|Eq. 2}}$T(x) = f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2+\frac{f^{(3)}(a)}{3!}(x-a)^3+ \cdots$ -
+ - or in summation notation, + or, in [[Summation Notation|summation notation]], -

+ - :$T(x)=\sum_{k=0} ^ {\infin } \frac {f^{(k)}(a)}{k!} \, (x-a)^{k}$ + :$T(x)=\sum_{k=0} ^ {\infin } \frac {f^{(k)}(a)}{k!} \, (x-a)^{k}$. -
+ - This is the standard formula of Taylor series that we are going to use in the rest of this article. In most cases we would like to let ''a'' = 0 to get a neater expression: + This is the standard formula of Taylor series that we will use throughout the rest of this page. -

+ + The ''n''th-degree Taylor polynomial simply restricts this polynomial to a finite number, ''n'', of terms: + + :$P_n(x) = f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2 + \frac{f^{(3)}(a)}{3!}(x-a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n$ + + or, in summation notation, + + :$P_n(x)=\sum_{k=0} ^ {n } \frac {f^{(k)}(a)}{k!} \, (x-a)^{k}$. + + In many cases, it is convenient to let ''a'' = 0 to get a neater expression: + :{{EquationRef2|Eq. 3}}$T(x) = f(0)+\frac {f'(0)}{1!} x + \frac{f''(0)}{2!} x^2 + \frac{f^{(3)}(0)}{3!}x^3 + \cdots$ :{{EquationRef2|Eq. 3}}$T(x) = f(0)+\frac {f'(0)}{1!} x + \frac{f''(0)}{2!} x^2 + \frac{f^{(3)}(0)}{3!}x^3 + \cdots$ -
+ - {{EquationNote|Eq. 3}} is also called '''Maclaurin series''', named after Scottish mathematician Colin Maclaurin, who made extensive use of these series in the 18th century. + {{EquationNote|Eq. 3}} is called the '''Maclaurin series''' and is named after Scottish mathematician Colin Maclaurin, who made extensive use of these series in the 18th century.[http://en.wikipedia.org/wiki/Colin_Maclaurin Colin Maclaurin]. Wikipedia. -

+ - We have given some examples of Taylor series in the [[#Taylorexample|Basic Description]] section. They are easy to derive using {{EquationNote|Eq. 2}} - just substitute ''f'' and ''a'' into it, then compute the derivatives. Here we are going to do this in detail for only one function: the natural log. Other elementary functions, such as sin(''x''), cos(''x''), and ''e'' x, can be treated in a similar manner. + ==Finding the Taylor Series for a Specific Function== -

+ Many Taylor series can be derived using {{EquationNote|Eq. 2}} by substituting in ''f'' and ''a''. Here we will demonstrate this process in detail for the natural logarithm function. The process in this section can be repeated for other elementary functions, such as sin(''x''), cos(''x''), and ''e'' ''x''. Their Taylor series will be discussed in the [[#Other Taylor Series|other Taylor series]] section. - Our natural log function is: + -

+ The natural log function is: - :$f (x) = \log (x)$ + -
+ :$f (x) = \ln (x)$ + Its derivatives are: Its derivatives are: -

+ - :$f'(x)=1/x$, $f''(x)=-1/x^2$, $f ^{(3)}(x)=2/x^3, \cdots$ $f ^{(k)}(x) = {{(-1)^{k-1} \cdot (k-1)!} \over x^k}$ + :$f'(x)=1/x$, -
+ :$f''(x)=-1/x^2$, - Since this function and its derivatives are not defined at ''x'' = 0, we cannot use Maclaurin series for it. Instead we can let ''a'' = 1 and compute the derivatives at this point: + :$f ^{(3)}(x)=2/x^3$, -

+ ::$\vdots$ - :$f(1) = \log 1 = 0$, $f'(1) = {1 \over 1} = 1$, $f''(1) = -{ 1 \over 1^2} = -1$, $f ^{(3)} (1) = {2 \over 1^3} = 2, \cdots$ $f ^{(k)} (1) = {(-1)^{k-1} \cdot (k-1)!}$ + :$f ^{(k)}(x) = {{(-1)^{k-1} \cdot (k-1)!} \over x^k}$ -
+ - {{Anchor|Reference=Figure2d|Link=[[Image:Taylorlog.gif|right|thumb|350px|Figure 2-d
Taylor series for natural log]]}} + Since this function and its derivatives are undefined at ''x'' = 0, we cannot construct a Maclaurin series ({{EquationNote|Eq. 3}}) for it. Note that, when choosing ''a'', one should select a value at which the derivatives ''f'' (''k'')(''a'') exist ''and'' at which they can be evaluated. For instance, centering our Taylor series at ''a'' = 2 would not be helpful because ''f'' (0)(2) = ln (2) is unknown and, in fact, cannot even be approximated until we have obtained our Taylor series. While it would be possible to write out the Taylor series, it would not be usable. - Substitute these derivatives into {{EquationNote|Eq. 2}}, and we can get the Taylor series for $\log (x)$ centered at ''x'' = 1: + -

+ For the natural log, it makes sense to let ''a'' = 1 and compute the derivatives at this point: - :$\log (x) = (x-1) - {(x-1)^2 \over 2} + {(x-1)^3 \over 3} + \cdots$ + -
+ :$f(1) = \ln 1 = 0$, - What's more, we can avoid the cumbersome (''x'' - 1)k notation by introducing a new function ''g''(''x'') = log (1 + ''x''). Now we can expand it around ''x'' = 0: + :$f'(1) = {1 \over 1} = 1$, -

+ :$f''(1) = -{ 1 \over 1^2} = -1$, - :$\log (1 + x) = x - {x^2 \over 2} + {x^3 \over 3} - {x^4 \over 4} + \cdots$ + :$f ^{(3)} (1) = {2 \over 1^3} = 2$, -
+ ::$\vdots$ - The animation to the right shows this Taylor polynomial with degree ''n'' varying from 0 to 25. As we can see, the left part of this polynomial soon approximates the original function as we have expected. However, the right part demonstrates some strange behavior: it seems to diverge farther away from the function as ''n'' grows larger. This tells us that '''Taylor series is not always a reliable approximation of the original function'''. Just the fact that they have same derivatives doesn't guarantee they are the same thing. There are more requirements needed. + :$f ^{(k)} (1) = {(-1)^{k-1} \cdot (k-1)!}$ -

+ - This leads us to the discussion of convergent and divergent sequences in the next subsection. + {{Anchor|Reference=Figure3|Link=[[Image:Taylorlog.gif|right|thumb|350px|Figure 3
Taylor series for natural log]]}} -

+ Substitute these derivatives into {{EquationNote|Eq. 2}}, and we can get the Taylor series for $\ln (x)$ centered at ''x'' = 1: - ==To converge or not to converge, this is the question== + -
+ :$\ln (x) = (x-1) - {(x-1)^2 \over 2} + {(x-1)^3 \over 3} + \cdots$ - From the last example of natural log, we can see that sometimes Taylor series fail to approximate their original functions. This happens because the Taylor series for natural log is divergent when $x > 1$, while a valid polynomial approximation needs to be convergent. Here are the definitions of convergence and divergence: + -

+ We can avoid the cumbersome (''x'' - 1)k notation by introducing a new function, ''g''(''x'') = ln (1 + ''x''). Now we can expand our polynomial around ''x'' = 0: - :Let our infinite sequence be: + -
+ :$\ln (1 + x) = x - {x^2 \over 2} + {x^3 \over 3} - {x^4 \over 4} + \cdots$ - ::$A = a_1, a_2, a_3 , a_4 \cdots$ , + -
+ The animation to the right shows this Taylor polynomial with degree ''n'' varying from 0 to 25. As we can see, at lower values, the polynomial quickly comes to generate a close approximation of the original function. However, the right side exhibits some strange behavior: the polynomial [[Convergence|diverges]] as ''n'' grows larger. This tells us that ''a Taylor series is not always a reliable approximation of the original function''. The fact that they have same derivatives at one point doesn't always guarantee that the Taylor series will represent a suitable approximation at all values of ''x'', even for arbitrarily large ''n''. Other factors need to be considered. - :and define its '''sum series''' to be: + -
+ Alas, power series, like the Taylor series for ln(1 + ''x''), do not necessarily converge for all values of ''x''. The Taylor series for natural log is divergent when $x > 1$, while a valid polynomial approximation needs to be convergent. Consider an arbitrary term in this series, $\pm x^n \over n$. As ''n'' increases, the denominator grows linearly, and the numerator [[Exponential Growth|grows exponentially]]. For arbitrarily large ''n'', exponential growth will override linear growth, so the convergence or divergence of the series is determined by ''x''''n''. If ''x'' > 1, then the Taylor series will diverge, hence the abnormal behavior of the right side of [[#Figure3|Figure 3]]. In this "divergent zone," although we can still write out and evaluate the polynomial for whatever'' n'' we like, we cannot expect it to approximate the original function. - ::$s_n = a_1 + a_2 + \cdots + a_n$ + -
+ Does this make it impossible to approximate ln(1 +''x'') for ''x'' greater than 1? It would seem that this would make our Taylor series useless in many cases. For example, imagine that we want to approximate ln(4): - :The sequence $A$ is said to be '''convergent''' if the following [[Limit|limit]] exists: + -
+ :$\ln (4) = \ln (1 + 3) = 3 - {3^2 \over 2} + {3^3 \over 3} - {3^4 \over 4} \cdots$ - ::$\lim_{n \to \infin}s_n = L$ + -
+ It is clear that this series will diverge rapidly, which contradicts our knowledge that ln(4) is defined. With some clever mathematical footwork, though, we can still find a solution. Instead, we write: - : If this limit doesn't exist, then the series $A$ is said to be '''divergent'''. + -

+ :\ln (4) = \ln (e \cdot {4 \over e}) = \ln (e) + \ln({4 \over e}) \approx 1 + \ln (1.47152) = 1 + \ln (1 + 0.47152) - As we can see in the definition, whether a sequence is convergent or not depends on its sum series. If the sequence is "summable" when ''n'' goes to infinity, then its convergent. If it's not, then it's divergent. Following are some examples of convergent and divergent sequences: + -

+ :$\approx 1 + (0.47152 - {0.47152^2 \over 2} + {0.47152^3 \over 3} - {0.47152^4 \over 4} + \cdots)$ - {{EquationRef2|Seq. 1}}$2 = 1 + {1 \over 2} + {1 \over 4} + {1 \over 8} + {1 \over 16} \cdots$ , convergent. + -
+ Since the Taylor series we found only converged for ''x'' < 1, we had to find some way to reduce the argument, 4, so that ''x'' was less than 1; we also needed to do this in such a way that the value of the whole expression remained unchanged. By using the identity ln(''a'' ·''b'' ) = ln(''a'' ) + ln(''b'' ), we were able to rewrite the logarithm so that our Taylor series did not diverge. Larger powers of ''e'' ([[Euler's Number|Euler's number]]) may be used for larger values of ''x''. - {{EquationRef2|Seq. 2}}${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$ , convergent. + -
+ - {{EquationRef2|Seq. 3}}$1 - 2 + 4 - 8 + 16 - 32 \cdots$ , divergent. Vibrates above and below 0 with increasing magnitudes. + Let's review what we have done to find a Taylor series for ln(1 + ''x''). How might this process be generalized to finding other Taylor series? -
+ *We began by choosing a base point at which we could evaluate the derivatives of our function. - {{EquationRef2|Seq. 4}}$1 + {1 \over 2} + {1 \over 3} + {1 \over 4} + {1 \over 5} \cdots$ , divergent. Adds up to infinity. + *We then figured out what those derivatives would be and found a general expression for the ''k''th derivative of our function at ''a''. -
+ *With this information, we could substitute into {{EquationNote|Eq. 2}} to obtain our Taylor series. - {{EquationNote|Seq. 1}} comes directly from the summation formula of [[Geometric Sequence|geometric sequences]]. {{EquationNote|Seq. 2}} is a famous summable sequence discovered by [http://en.wikipedia.org/wiki/Gottfried_Wilhelm_Leibniz Leibniz]. We are going to briefly explain these sequences in the following sections. + **In this example, we modified this Taylor series by recentering it around 0. This is generally not necessary; many Taylor series can be centered around ''x'' = 0 to begin with. -

+ *In using our Taylor series, we had to be attentive to its "divergent zone." This, also, is not always necessary, since other Taylor series, like those introduced in the next section, converge for all values of ''x''. - {{EquationNote|Seq. 3}} and {{EquationNote|Seq. 4}} are divergent because both of them add up to infinity. However, there is one important difference between them. On one hand, {{EquationNote|Seq. 3}} has terms going to infinity, so it's not surprising that this one is not summable. On the other hand, {{EquationNote|Seq. 4}} has terms going to zero, but they still have an infinitely large sum! This counter-intuitive result was first proved by Johann Bernoulli and Jacob Bernoulli in 17th century. In fact, this sequence is so epic in the history of math that mathematicians gave it a special name: the '''harmonic series'''. Click [http://prairiestate.edu/skifowit/harmapa.pdf here] for a proof of the divergence of harmonic series[http://prairiestate.edu/skifowit/harmapa.pdf The Harmonic Series Diverges Again and Again], by Steven J. Kifowit and Terra A. Stamps. This article explains why harmonic series is divergent.. + -

+ ==Other Taylor Series== - By definition, divergent series are not summable. So if we talk about the "sum" of these series, we may get ridiculous results. For example, look at the summation formula of geometric series: + Using the process described above, we can obtain Taylor series for a variety of other functions, such as the following: -

+ - :${ 1 \over {1 - r}} = 1 + r + r^2 + r^3 + \cdots$ + :$\sin (x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} + {x^9 \over 9!} - \cdots$ , expanded around the origin. ''x'' is in [[Radians|radians]]. -
+ - This formula could be easily derived with a little manipulation of algebra, or by expanding the Maclaurin series of the left side. Click [http://mathworld.wolfram.com/GeometricSeries.html here] for a simple proof[http://mathworld.wolfram.com/HarmonicSeries.html Harmonic Series], from Wolfram MathWorld. This is a simple proof that harmonic series diverges. However, what we want to show here is that this formula doesn't work for all values of ''r''. For values less than 1, such as 1/2, we can get reasonable results like: + :\cos (x) = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + {x^8 \over 8!} - \cdots[/itex] , expanded around the origin. ''x'' is in radians. -

+ - :$2 = 1 + {1 \over 2} + {1 \over 4} + {1 \over 8} + {1 \over 16} \cdots$ + :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + {x^5 \over 5!} + \cdots$ , expanded around the origin. -
+ - However, if the value of ''r'' is larger than 1, such as 2, things start to get weird: + In comparison with the above example of ln(''x''), these Taylor series are perhaps more straightforward to derive, even though they look slightly more complicated. Because the derivatives of sine, cosine and ''ex'' are all defined and easily evaluable at ''x'' = 0, we can center -

+ their respective Taylor series at 0 from the outset. As noted above, these series converge for all ''x'' (although a given Taylor polynomial for some finite ''n'' may not be ''accurate'', particularly for values of ''x'' that are not close to the base point; see [[#Error Bound of a Taylor Series|error bound]]). - :$-1 = 1 + 2 + 4 + 8 + 16 \cdots$ + -
+ Note that the powers of each successive term in the Taylor series for sine and cosine increase by 2, and each term alternates between positive and negative; this makes sense when we consider the nature of successive derivatives of sin (''x'') and cos(''x'') at ''x'' = 0. Their derivatives cycle through 1, 0, -1, and 0, so we obtain a pattern like that observed above, where every other term is zero and the remaining terms alternate in signs. - How can we get a negative number by adding a bunch of positive integers? Well, if this case makes mathematicians uncomfortable, then they are going to be even more puzzled by the following one, in which ''r'' = -2: + -

+ The Taylor series for ''e''''x'' follows from the fact that the derivative of ''e''''x'' is itself. ''e''''x'' will be derived in [[#Approximating e|Approximating ''e'']]. Let the derivation of Taylor series for sine and cosine using {{EquationNote|Eq. 2}} be left to the reader. - :${1 \over 3} = 1 - 2 + 4 - 8 + 16 \cdots$ + -
+ - This is ridiculous: the sum of integers can not possibly be a fraction. In fact, we are getting all these funny results because the last two series are divergent, so their sums are not defined. See the following images for a graphic representation of these series: + These days, Taylor series are not often used directly to approximate the trigonometric functions, since it is easy enough to approximate the trigonometric functions using a calculator. They are, however, used in various indirect ways. For instance, we can compute the Taylor series of the function composition sin (2''x''2) by substituting 2''x''2 for ''x'' into the Taylor series for sin(''x''): -
+ - {{{!}}border="0" cellpadding=5 cellspacing=5 + :$\sin (2x^2) = 2x^2 - {(2x^2)^3 \over 3!} + {(2x^2)^5 \over 5!} - {(2x^2)^7 \over 7!} + \cdots = 2x^2 - {8x^6 \over 3!} + {32x^{10} \over 5!} - {128x^{14} \over 7!} + \cdots$ - {{!}}{{Anchor|Reference=Figure3a|Link=[[Image:InfiniteSeries1.jpg|center|thumb|325px|Figure 3-a
Geometric Sequence with ''r'' = 1/2]]}}{{!}}{{!}}{{Anchor|Reference=Figure3b|Link=[[Image:InfiniteSeries2.jpg|center|thumb|325px|Figure 3-b
Geometric Sequence with ''r'' = 2]]}}{{!}}{{!}}{{Anchor|Reference=Figure3c|Link=[[Image:InfiniteSeries3.jpg|center|thumb|325px|Figure 3-c
Geometric Sequence with ''r'' = -2]]}} + - {{!}}} + More complicated composition is also possible; for instance, to find the Taylor series for $e^{\sin x}$ one may substitute the whole Taylor series of sin(''x'') for ''x'' in the Taylor series for ''ex.'' In physics, it is often useful to make approximations using the first few terms of compositions of a Taylor series. The [[Rope around the Earth|Rope around the Earth]] problem is one instance where this technique is necessary. -
+ - In the images above, the blue lines trace the geometric sequences, and the red lines trace their sum series. As we can see, the first sequence with ''r'' = 1/2 does have a limited sum, since its sum series converge to a finite value as ''n'' increases. However, the sum series of the other two sequences don't converge to anything. They never settle around a finite value. Thus the second and third sequences diverge, and their sums don't exist. Although we can still write down the summation formula in principle, this formula is meaningless. So no wonder we have got those weird results. + It is also possible to compose ''other'' objects into Taylor series . For instance, if we have a square [[Matrix|matrix]] ''A'', the operation ''eA'' is not defined by the normal rules of exponents. What does it mean, anyway, to put something to the power of a matrix? However, we can compose the matrix ''A'' into the Taylor series for ''e'': -

+ - Same thing happens in the Taylor series of natural log: + :$e^A = I + A + {1 \over 2!}A^2 + {1 \over 3!}A^3 + {1 \over 4!}A^4 + {1 \over 5!}A^5 + \cdots$, where ''I'' is the identity matrix of the same size as ''A''. -

+ - :$\log (1 + x) = x - {x^2 \over 2} + {x^3 \over 3} - {x^4 \over 4} + \cdots$ + This composition is necessary for solving some [[Systems of Linear Differential Equations|systems of linear differential equations]]. Hopefully these brief examples give you an idea of how powerful Taylor series can be when applied to other branches of mathematics! -
+ - Let's look at an arbitrary term in this series: ±''x''n / n. As ''n'' increases, the denominator is experiencing a linear growth, and the numerator is experiencing an [[Exponential Growth|exponential growth]]. It is a known fact that exponential growth will eventually override linear growth, as long as the absolute value of ''x'' is larger than one. So if ''x'' > 1, then the terms ''x''n / n will go to infinity, and this Taylor series will be divergent. This is why we saw the abnormal behavior of the right side of [[#Figure2d|Figure 2-d]]. In this "divergent zone", although we can still write down the polynomial, it's no longer a valid approximation of the function. For example, if we want to calculate the value of log 4, instead of writing: + -

+ Consider another example: - :$log (4) = log (1 + 3) = 3 - {3^2 \over 2} + {3^3 \over 3} - {3^4 \over 4} \cdots$ (divergent) + -
+ :\lim_{x \rightarrow 0} {\sin(x) \over x}[/itex] - we have to write: + -

+ It is clear that when ''x'' = 0, the quotient in this limit expression is undefined, so one cannot evaluate the limit by evaluating the quotient at 0. One way to evaluate the limit of an expression whose numerator and denominator both go to 0 is by using l'Hôpital's rule: - :$log (4) = log (e \cdot {4 \over e}) = 1 + log ({4 \over e}) = 1 + log (1.47152) + :[itex]\lim_{x \rightarrow 0} {\sin(x) \over x} = \lim_{x \rightarrow 0} {(\sin(x))' \over (x)'} = \lim_{x \rightarrow 0} {\cos(x) \over 1} = 1 - + - :[itex] = 1 + 0.47152 - {0.47152^2 \over 2} + {0.47152^3 \over 3} - {0.47152^4 \over 4} + \cdots$ (convergent) + Alternatively, one can use Taylor series! Substitute the Taylor series for sin(''x'') in: -
+ - in which we saved it from the "divergent zone" to the "convergent zone" by using the identity log(''a'' ·''b'' ) = log (''a'' ) + log (''b'' ). + :$\lim_{x \rightarrow 0} {\sin(x) \over x} = \lim_{x \rightarrow 0} {{x - {x^3 \over 3!} + {x^5 \over 5!} - \cdots} \over x} = \lim_{x \rightarrow 0} ({1 - {x^2 \over 3!} + {x^4 \over 5!} - \cdots}) = 1$ -

+ + We have obtained the same limit. + + + Taylor series also help us understand the derivatives of these functions. Above it was mentioned that each derivative of ''e''''x'' is itself. More generally, for any real ''c'', the arbitrary ''k''th derivative of ''e''''cx'' is given by: + + :${d^k \over dx^k}e^{cx} = c^k e^{cx} + + If we substitute ''cx'' for'' x'' in our Taylor series for ''e''''x'', we get: + + :[itex]e^{cx} = 1 + cx + {(cx)^2 \over 2!} + {(cx)^3 \over 3!} + {(cx)^4 \over 4!} + \cdots = 1 + cx + {c^2 \over 2!} x^2 + {c^3 \over 3!} x^3 + {c^4 \over 4!} x^4 + \cdots$ + + Differentiating this, we get: + + :{d \over dx} e^{cx} = c + c^2 x + {c^3 \over 2!} x^2 + {c^4 \over 3!} x^3 + {c^5 \over 4!} x^4 + \cdots + :$= c(1 + cx + {c^2 \over 2!} x^2 + {c^3 \over 3!} x^3 + {c^4 \over 4!} x^4 + \cdots)$ + :=ce^{cx} + + Each differentiation of the Taylor series will multiply ''e''''cx'' by ''c'', as expected. + + + ==Error Bound of a Taylor Series== + {{SwitchPreview|HideMessage=Click here to hide the error bound of a Taylor series.|ShowMessage=Click here to show the error bound of a Taylor series. + |PreviewText=Throughout this page so far, we have often made reference to the accuracy of our Taylor polynomial approximations...|FullText= + Throughout this page so far, we have often made reference to the accuracy of our Taylor-polynomial approximations. Recall that '''accuracy''' is the closeness of an approximation to its true value. It would be practical to be able to quantify the closeness of our approximations so that we can know how much we can rely on them, or so that we may add more terms if our approximation is not sufficiently accurate. In other words, we want to understand how much '''error''' there might be for a given Taylor approximation so that the approximation is usable. + + We should not expect to be able to calculate the exact error. If that were possible, then we would be able to find an exact "approximation" by adding the "error" to our Taylor polynomial. Similarly, we cannot directly compare the approximate value to the actual value because we don't know the actual value! What we can do is ''bound'' the error; we can find how accurate our approximation is ''at worst''. + + Consider a function $f (x) for which we have a Taylor polynomial [itex]P_n (x) centered at ''a''. We would like to find a formula to bound our approximation. We define the '''remainder''' [itex]R_n (x)$ as: + + :R_n (x) = f (x) - P_n (x), or + :$f (x) = P_n (x) + R_n(x)$ + + A useful characterization of $R_n (x)$ happens to be: + + :{{EquationRef2|Eq. 4}}$|R_n (x)| \leq {M \over (n+1)!} (x-a)^{n+1}$ where ''M'' is the upper bound for the (''n''+1)th derivative of ''f'' on the interval [''a'', ''x'']. + + It is not obvious how {{EquationNote|Eq. 4}} is derived from our definition of remainder; the proof is rather complex and unintuitive. You can choose to skip the derivation and go on to learn how to use the above equation to bound the error of a Taylor-polynomial approximation. + {{SwitchPreview|HideMessage=Click here to hide the derivation of Eq. 4|ShowMessage=Click here to show the derivation of Eq. 4. + |PreviewText=|FullText=:Recall that we constructed our Taylor polynomial ''Pn''(''x'') such that ''f''(''x'') and ''Pn''(''x'') have the same first ''n'' derivatives at ''a''. We also defined + + ::$R_n(x) = f(x) - P_n(x). + + :It must hold that + + ::[itex]R_n(a) = f(a) - P_n(a) = 0 + ::[itex]R'_n(a) = f'(a) - P'_n(a) = 0 + ::[itex]R''_n(a) = f''(a) - P''_n(a) = 0 + :::::[itex]\vdots + ::[itex]R^{(n)}_n(a) = f^{(n)}(a) - P^{(n)}_n(a) = 0 + + :Since ''Pn''(''x'') is an ''n''th-degree polynomial, its (''n'' + 1)th derivative is 0: + + ::P^{(n+1)}_n(x) = 0 + + :so + + ::R^{(n+1)}_n(x) = f^{(n+1)}(x). + + :We bound ''f'' (''n'' + 1) (''x'') on the interval [''a'', ''x'']. In particular, we choose ''M'' so that + + ::|f^{(n+1)}(x)| = |R^{(n+1)}_n(x)| \leq M. + + :So + + ::[itex]-M \leq R^{(n+1)}_n(x) \leq M$ + + :and + + ::$- \int_a ^x M dx \leq \int_a ^x R^{(n+1)}_n(x) dx \leq \int_a ^x M dx$ + ::-M(x-a) \leq R^{(n)}_n(x) - R^{(n)}_n(a) \leq M(x-a). + + :As established above, + + ::R^{(n)}_n(a) = 0, + + :so + + ::[itex]-M(x-a) \leq R^{(n)}_n(x) \leq M(x-a). + + :We can integrate this again: + + ::-\int_a^x M(x-a) dx \leq \int_a^x R^{(n)}_n(x) dx \leq \int_a^x M(x-a) dx. + + :Examine the integral: + + ::[itex]\begin{align} + \int_a^x (Mx-Ma)dx &= \left[ {Mx^2 \over 2} - Max \right]_a^x \\ + &= {Mx^2 \over 2} - Max - {Ma^2 \over 2} + Ma^2 = {Mx^2 \over 2} - Max + {Ma^2 \over 2} \\ + &= {M \over 2}(x^2 - 2ax + a^2) \\ + &= {M \over 2}(x - a)^2 + \end{align} + + :So we now have: + + :: -{M \over 2}(x-a)^2 \leq R^{(n-1)}_n(x) \leq {M \over 2}(x-a)^2 + + :It might be intuitively evident that, integrating this inequality ''n'' - 1 more times, we will obtain {{EquationNote|Eq. 4}}. We will now demonstrate this by induction. + + ::Above we established the base case. We now assume that {{EquationNote|Eq. 4}} holds for some integer ''k'' < ''n'' and will demonstrate that it therefore holds for ''k'' + 1. + + :::-{M \over k!}(x-a)^k \leq R^{(n+1-k)}_n(x) \leq {M \over k!}(x-a)^k + + ::Again, we examine the integral: + + :::$\int_a^x {M \over k!}(x-a)^k dx = \left[ {M \over (k+1)!}(x-a)^{k+1} \right]_a^x = {M \over (k+1)!}(x-a)^{k+1} - {M \over (k+1)!}(a-a)^{k+1} = {M \over (k+1)!}(x-a)^{k+1}$ + + ::As established previously, the first ''n'' derivatives of ''Rn''(''x'') evaluated at ''x'' = ''a'' are 0, so we obtain: + + :::$-{M \over (k+1)!}(x-a)^{k+1} \leq R^{(n-k)}_n(x) \leq {M \over (k+1)!}(x-a)^{k+1}$ + + :Therefore, if we continue integrating, we obtain: + + ::-{M \over (n+1)!}(x-a)^{n+1} \leq R_n(x) \leq {M \over (n+1)!}(x-a)^{n+1}[/itex], or + + ::$|R_n(x)| \leq {M \over (n+1)!}(x-a)^{n+1}$. + }} + + How might one use {{EquationNote|Eq. 4}} to check the accuracy of a Taylor polynomial? ''M'' is an upper bound on the (''n''+1)th derivative of ''f'' on the interval [''a'', ''x''] (that is, on the interval between where the Taylor polynomial is centered and where it is being evaluated). This seems fairly arbitrary but may make more sense in practice. + + [[Image:Actual vs bounded.gif|right|thumb|350px|Figure 4
A comparison between the actual error and the upper error bound computed using {{EquationNote|Eq. 4}} for increasing values of ''n''.]] + [[Image:Error animation.gif|right|thumb|350px|Figure 5
A comparison of the Taylor polynomial with the actual function sin(''x'') at two ''x'' values for successive approximations.

+ Modified from [http://www.keycurriculum.com/resources/sketchpad-resources/free-activities/sketchpad-calculus-activities KeyCurriculum Taylor series activity on Sketchpad].]] + + Imagine that we are trying to find an error bound for sin(''x''). All derivatives of sin(''x'') are one of: + + :\pm \sin(x), \pm \cos(x). + + In other terms, + + :$-1 \leq f^{(k+1)}(x) \leq 1$ $\forall$ $x,k$, + + so + + :-1 \leq M \leq 1[/itex]. + + Then we can say that, for any Taylor polynomial for sin(''x'') evaluated at any ''x'', + + :R_n(x) \leq \left |{x^{n+1} \over (n+1)!} \right| + + This is straightforward to evaluate. Since the factorial growth in the denominator outpaces the exponential growth in the numerator, it is evident that, as expected, the error becomes smaller for larger ''n''. + + In [[#Figure4|Figure 4]], the "flattened" part in the center of the graph is where our approximation is "good". To the naked eye, at least, the error appears to be very close to 0. + + Notice, in [[#Figure5|Figure 5]], that the approximation becomes sufficiently close to 0 for the lower ''x'' value much more quickly than it does for higher ''x'' values. But by including enough terms, we can make our approximation as accurate as we would like at either point. In this figure, it is also noteworthy that, although the error eventually displays a 0 in each decimal place, the error at any value never actually ''reaches'' 0, so long as ''n'' is finite. Finally, note that ''Rn'' in this graphic is ''actual error'', the difference between the Taylor polynomial and the original function, not the error bound computed by bounding''f'' (''k'' + 1)(''c''). + + As [[#Figure4|Figure 4]] shows, the error bound is rarely equal to actual error; it is usually greater, often much greater, than the actual error. For instance, + + :$P_5(1) - \sin (1) = 0.000196 \cdots$ + + but + + :$R_5 (1) = {1 \over 6!} = 0.00138 \cdots$ + + As we can see, even at a point where the difference between the Taylor polynomial and original function could not be distinguished by the naked eye, the actual error is often much smaller than the bounded error. This should make us especially confident in using our approximations. In [[#Figure4|Figure 4]], the red curve is almost always less than or equal to the blue curve (with a small exception when ''n'' = 1). This is desirable when approximating error: we would like to be certain that the actual error is less than our approximation. + + + Suppose that we would like to make an approximation of the value of f(x) = e^{2x} at ''x'' = 0.25. Say we choose to make a 3rd-degree Taylor approximation using the Taylor polynomial centered at 0. The Taylor polynomial is: + + :$P_3 (0.25) = 1 + {2(0.25) \over 1!} + {4(0.25)^2 \over 2!} + {8(0.25)^3 \over 3!} = 1.6458333\cdots$ + + The error is: + + :$R_3 (0.25) = {M \over 4!} (0.25)^{4}$ + + How do we bound ''M'' on the interval [0, 0.25]? We know that in general, + + :{d^k \over dx^k}e^{px} = p^k e^{px} + + Evaluating this initially seems to be problematic. In our example, ''p'' = 2, and ''p''''k'' can be calculated easily. But we don't know what ''e''2''x'' is at most for the interval [0, 0.25]; that is why we are making a Taylor polynomial approximation in the first place! However, we just need to recall that we are looking for an error ''bound'', which does not to be exact. We know: + + :e^{2 \cdot 0.25} = e^{0.5} = \sqrt{e}. + + Moreover, + + :$e < 4$, + + so + + :$\sqrt{e} < \sqrt{4}$. + + Thus we are certain that on the interval [0, 0.25], $e^{2x} < 2$. Each differentiation doubles this bound, so + + :$M = 2 \cdot 2^{n+1}$. + + We can now finish calculating the error: + + :$R_3 (0.25) \leq {2 \cdot 2^4 \over 4!} (0.25)^{4} = 0.00521$ + + This gives us a good idea of how accurate our approximation is. The actual value of the function is less than 0.00521 away from the third-degree Taylor approximation: + + :$P_3(0.25) - R_3(0.25) < f(0.25) < P_3(0.25) + R_3(0.25)$ + :$1.640623 < e^{0.5} < 1.651043$ + + Suppose that we desire greater accuracy. Say, specifically, that we would like to know what degree Taylor polynomial would be necessary to have error less than 10-4. We must solve for ''N'' where: + + :${2 \cdot 0.5^{N+1} \over (N+1)!} < {1 \over 10^4}$ + + By substituting in various values of ''N'', we find that the lowest integer for which this inequality holds is ''N'' = 5, so if we want to be sure our approximation has an error of less than 10^-4, we should use a 5th degree Taylor polynomial. + }} |other=Calculus |other=Calculus Line 242: Line 467: |WhyInteresting= |WhyInteresting=
-
A modern TI calculator]]}} - As we have stated before, Taylor series can be used to derive many interesting sequences, which helped mathematicians to determine the values of important math constants such as $\pi$ and $e$. + Have you ever wondered how calculators determine square roots, sines, cosines, and exponentials? For instance, if you were to type $\sin{\pi \over 2}$ or $e^2$ into your calculator, how does it determine which value to spit out? The number must be related to our input in some way, but what exactly is the relationship? Does the calculator just read from an index of known values? Is there a more mathematical and precise way for the calculator to evaluate these functions? -

+ -

Approximating Pi

+ The answer to this latter question is yes. There are algorithms that give an approximate value of sine, for example, using only the four basic operations (+, -, x, /)[http://www.homeschoolmath.net/teaching/sine_calculator.php How does the calculator find values of sine], from homeschoolmath. This is an article about calculator programs for approximating functions.. Before the age of electronic calculators, mathematicians studied these algorithms in order to approximate these functions manually. The Taylor series, named after English mathematician Brook Taylor, is one such way of making these approximations. Basically, Taylor said that there is a way to expand any [[Differentiability|infinitely differentiable]] function into a polynomial series about a certain point. The strength of the Taylor series is its ability to approximate certain functions that cannot otherwise be calculated. -
+ + The calculator's algorithm for many functions uses this method to efficiently find a suitable approximation in the form of a polynomial series. Expanding enough terms for several digits of accuracy is easy for a computing device, even though Taylor series may look daunting and tedious to the naked eye. This algorithm is built in the permanent memory (ROM) of electronic calculators, and is triggered when a function like sine or cosine is called[http://en.wikipedia.org/wiki/Calculator Calculator], from Wikipedia. This article explains the structure of an electronic calculator.. + + + As is shown in the [[#MME|More Mathematical Explanation]], Taylor series can be used to derive many interesting and useful series. Some of these series have helped mathematicians to approximate the values of important irrational constants such as $\pi$ and $e$. + +

Approximating π

$\pi$, or the ratio of a circle's circumference to its diameter, is one of the oldest, most important, and most interesting mathematical constants. The earliest documentation of $\pi$ can be traced back to ancient Egypt and Babylon, in which people used empirical values of $\pi$ such as 25/8 = 3.1250, or (16/9)2 ≈ 3.1605[http://mathworld.wolfram.com/Pi.html Pi], from Wolfram MathWorld. This article contains some history of Pi.. $\pi$, or the ratio of a circle's circumference to its diameter, is one of the oldest, most important, and most interesting mathematical constants. The earliest documentation of $\pi$ can be traced back to ancient Egypt and Babylon, in which people used empirical values of $\pi$ such as 25/8 = 3.1250, or (16/9)2 ≈ 3.1605[http://mathworld.wolfram.com/Pi.html Pi], from Wolfram MathWorld. This article contains some history of Pi.. -

+ - {{Anchor|Reference=Figure4a|Link=[[Image:PolygonPi.png|right|thumb|450px|Figure 4-a
Archimedes' method to approximate π]]}} + {{Anchor|Reference=Figure7a|Link=[[Image:PolygonPi.png|right|thumb|450px|Figure 7a
Archimedes' method to approximate π]]}} The first recorded algorithm for rigorously calculating the value of $\pi$ was a geometrical approach using polygons, devised around 250 BC by the Greek mathematician Archimedes. Archimedes computed upper and lower bounds of $\pi$ by drawing regular polygons inside and outside a circle, and calculating the perimeters of the outer and inner polygons. He proved that 223/71 < $\pi$ < 22/7 by using a 96-sided polygon, which gives us 2 accurate decimal digits: π ≈ 3.14[http://itech.fgcu.edu/faculty/clindsey/mhf4404/archimedes/archimedes.html Archimedes' Approximation of Pi]. This is a thorough explanation of Archimedes' method.. The first recorded algorithm for rigorously calculating the value of $\pi$ was a geometrical approach using polygons, devised around 250 BC by the Greek mathematician Archimedes. Archimedes computed upper and lower bounds of $\pi$ by drawing regular polygons inside and outside a circle, and calculating the perimeters of the outer and inner polygons. He proved that 223/71 < $\pi$ < 22/7 by using a 96-sided polygon, which gives us 2 accurate decimal digits: π ≈ 3.14[http://itech.fgcu.edu/faculty/clindsey/mhf4404/archimedes/archimedes.html Archimedes' Approximation of Pi]. This is a thorough explanation of Archimedes' method.. -

+ - Mathematicians continued to use this polygon method for the next 1,800 years. The more sides their polygons have, the more accurate their approximations would be. This approach peaked at around 1600, when the Dutch mathematician Ludolph van Ceulen used a 260 - sided polygon to obtain the first 35 digits of $\pi$[http://www.ams.org/samplings/math-history/hap-6-pi.pdf Digits of Pi], by Barry Cipra. Documentation of Ludolph's work is included here.. He spent a major part of his life on this calculation. In memory of his contribution, sometimes $\pi$ is still called "the Ludolphine number". + Mathematicians continued to use this polygon method for the next 1,800 years. The more sides their polygons had, the more accurate their approximations would be. This approach peaked at around 1600, when the Dutch mathematician Ludolph van Ceulen used a 260 - sided polygon to obtain the first 35 digits of $\pi$[http://www.ams.org/samplings/math-history/hap-6-pi.pdf Digits of Pi], by Barry Cipra. Documentation of Ludolph's work is included here.. He spent a major part of his life on this calculation. In memory of his contribution, sometimes $\pi$ is still called "the Ludolphine number". -

+ - However, mathematicians have had enough of trillion-sided polygons. Starting from the 17th century, they devised much better approaches for computing $\pi$, using calculus rather than geometry. Mathematicians discovered numerous infinite series associated with $\pi$ , and the most famous one among them is the Leibniz series: + However, mathematicians have had enough of trillion-sided polygons. Starting in the 17th century, they devised much better approaches for computing $\pi$, using calculus rather than geometry. Mathematicians discovered numerous infinite series associated with $\pi$ , and the most famous one among them is the Leibniz series: -

+ :${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$ :${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$ -
+ - We have seen the Leibniz series as an example of convergent series in the [[#MME|More Mathematical Explanation]] section. Here we are going to briefly explain how Leibniz got this result. This amazing sequence comes directly from the Taylor series of arctan(''x''): + We will explain how Leibniz got this amazing result and how it allowed him to approximate \pi[/itex]. -

+ - {{EquationRef2|Eq. 4a}}$\arctan (x) = x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots$ + {{SwitchPreview|HideMessage=Click here to hide the approximation of $\pi$ using Taylor series.|ShowMessage=Click here to show the approximation of π using Taylor series. -
+ |PreviewText=This amazing series comes directly from the Taylor series of arctan(''x'')...|FullText= - We can get {{EquationNote|Eq. 4a}} by directly computing the derivatives of all orders for arctan(''x'') at ''x'' = 0, but the calculation involved is rather complicated. There is a much easier way to do this if we notice the following fact: + This amazing series comes directly from the Taylor series of arctan(''x''): -

+ - {{EquationRef2|Eq. 4b}}${{d \arctan (x)} \over dx} = {1 \over {1 + x^2}}$ + {{EquationRef2|Eq. 5a}}$\arctan (x) = x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots$ -
+ + We can get {{EquationNote|Eq. 5a}} by directly computing the derivatives of all orders for arctan(''x'') at ''x'' = 0, but the calculation involved is rather complicated. There is a much easier way to do this if we notice the following fact: + + {{EquationRef2|Eq. 5b}}${d \over dx} \arctan (x) = {1 \over {1 + x^2}}$ + Recall that we gave the summation formula of geometric series in the [[#MME|More Mathematical Explanation]] section : Recall that we gave the summation formula of geometric series in the [[#MME|More Mathematical Explanation]] section : -

+ :${ 1 \over {1 - r}} = 1 + r + r^2 + r^3 + r^4 \cdots$ , $-1 < r < 1$ :${ 1 \over {1 - r}} = 1 + r + r^2 + r^3 + r^4 \cdots$ , $-1 < r < 1$ -
+ - If we substitute r = - x2 into the summation formula above, we can expand the right side of {{EquationNote|Eq. 4b}} into an infinite sequence: + If we substitute ''r'' = - ''x''2 into the summation formula above, we can expand the right side of {{EquationNote|Eq. 5b}} into an infinite sequence: - [[Image:Leibniz.jpg|right|thumb|230px|Figure 4-b
Gottfried Wilhelm Leibniz
Discoverer of Leibniz series]] + [[Image:Leibniz.jpg|right|thumb|230px|Figure 7b
Gottfried Wilhelm Leibniz
Discoverer of Leibniz series]] -
+ :${ 1 \over {1 + x^2}} = 1 - x^2 + x^4 - x^6 + x^8 \cdots$ :${ 1 \over {1 + x^2}} = 1 - x^2 + x^4 - x^6 + x^8 \cdots$ -
+ - So {{EquationNote|Eq. 4b}} changes into: + So {{EquationNote|Eq. 5b}} changes into: -

+ - :${{d \arctan (x)} \over dx} = 1 - x^2 + x^4 - x^6 + x^8 \cdots$ + :${d \over dx} \arctan (x) = 1 - x^2 + x^4 - x^6 + x^8 \cdots$ -
+ Integrating both sides gives us: Integrating both sides gives us: -

+ - :$\arctan (x) = x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots + C$ + :$\arctan (x) = C + x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots$ -
+ - Let ''x'' = 0, this equation changes into 0 = ''C'' . So the integrating constant ''C'' vanishes, and we get {{EquationNote|Eq. 4a}}. + Let ''x'' = 0. This changes the equation to 0 = ''C'' . So the integrating constant ''C'' vanishes, and we get {{EquationNote|Eq. 5a}}. -

+ One may notice that, like Taylor series of many other functions, this series is not convergent for all values of ''x''. It only converges for -1 ≤ ''x'' ≤ 1. Fortunately, this is just enough for us to proceed. Substituting ''x'' = 1 into it, we can get the Leibniz series: One may notice that, like Taylor series of many other functions, this series is not convergent for all values of ''x''. It only converges for -1 ≤ ''x'' ≤ 1. Fortunately, this is just enough for us to proceed. Substituting ''x'' = 1 into it, we can get the Leibniz series: -

+ :${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$ :${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$ -
+ - The Leibniz series gives us a radically improved way to approximate $\pi$: no polygons, no square roots, just the four basic operations. However, this particular series is not suitable for computing $\pi$, since it converges too slowly. The first 1,000 terms of Leibniz series give us only two accurate digits: π ≈ 3.14. This is horribly inefficient, and no mathematicians will ever want to use this algorithm. + The Leibniz series gives us a radically improved way to approximate $\pi$: no polygons, no square roots, just the four basic operations. However, this particular series is not very efficient for computing $\pi$, since it converges rather slowly. The first 1,000 terms of Leibniz series give us only two accurate digits: π ≈ 3.14. This is horribly inefficient, so most mathematicians would prefer not to use this algorithm. -

+ - Fortunately, we can get series that converge much faster if we substitute smaller values of ''x'' , such as $1 \over \sqrt{3}$ , into {{EquationNote|Eq. 4a}}: + Fortunately, we can get series that converge much faster if we substitute smaller values of ''x'' , such as $1 \over \sqrt{3}$ , into {{EquationNote|Eq. 5a}}: -

+ :$\arctan {1 \over \sqrt{3}} = {\pi \over 6} = {1 \over \sqrt{3}} - {1 \over {3 \cdot 3 \sqrt{3}}} + {1 \over {5 \cdot 3^2 \sqrt{3}}} - {1 \over {7 \cdot 3^3 \sqrt{3}}} \cdots$ :$\arctan {1 \over \sqrt{3}} = {\pi \over 6} = {1 \over \sqrt{3}} - {1 \over {3 \cdot 3 \sqrt{3}}} + {1 \over {5 \cdot 3^2 \sqrt{3}}} - {1 \over {7 \cdot 3^3 \sqrt{3}}} \cdots$ -
+ which gives us: which gives us: -

+ :$\pi = \sqrt{12}(1 - {1 \over {3 \cdot 3}} + {1 \over {5 \cdot 3^2}} - {1 \over {7 \cdot 3^3}} + \cdots)$ :$\pi = \sqrt{12}(1 - {1 \over {3 \cdot 3}} + {1 \over {5 \cdot 3^2}} - {1 \over {7 \cdot 3^3}} + \cdots)$ -
+ - This series is much more efficient than the Leibniz series, since there are powers of 3 in the denominators. The first 10 terms of it give us 5 accurate digits, and the first 100 terms give us 50. Leibniz himself used the first 22 terms to compute an approximation of pi correct to 11 decimal places as 3.14159265358. + This series is much more efficient than the Leibniz series, since there are powers of 3 in the denominators. The first 10 terms of it give us 5 accurate digits, and the first 100 terms give us 50. Leibniz himself used the first 22 terms to compute an approximation of π, which is correct to 11 decimal places: 3.14159265358. -

+ - However, mathematicians are still not satisfied with this efficiency. They kept substituting smaller ''x'' values into {{EquationNote|Eq. 4a}} to get more convergent series. Among them is Leonhard Euler, one of the greatest mathematicians in the 18th century. In his attempt to approximate $\pi$, Euler discovered the following non-intuitive formula: + However, mathematicians were still not satisfied with this efficiency. They kept substituting smaller ''x'' values into {{EquationNote|Eq. 5a}} to get more convergent series. Among the mathematicians who did this was Leonhard Euler, one of the greatest mathematicians in the 18th century. In his attempt to approximate $\pi$, Euler discovered the following non-intuitive formula: -

+ - {{EquationRef2|Eq. 4c}}$\pi = 20 \arctan {1 \over 7} + 8 \arctan {3 \over 79}$ + {{EquationRef2|Eq. 5c}}$\pi = 20 \arctan {1 \over 7} + 8 \arctan {3 \over 79}$ -
+ - Although {{EquationNote|Eq. 4c}} looks really weird, it is indeed an equality, not an approximation. The following hidden section shows how it is derived in detail: + Although {{EquationNote|Eq. 5c}} looks really weird, it is indeed an equality, not an approximation. The following hidden section shows how it is derived in detail. -

+ - {{HideShowThis|ShowMessage=Click to show the derivation of Eq. 4c|HideMessage='''Click to hide this message.|HiddenText= + {{HideShowThis|ShowMessage=Click to show the derivation of Eq. 5c|HideMessage='''Click to hide this message.|HiddenText=:{{EquationNote|Eq. 5c}} comes from the trigonometric identity of the tangent of two angles. Suppose we have 3 angles, $\alpha$, $\beta$, and $\gamma$ that satisfy: - {{{!}}border=1 cellpadding=0 cellspacing=5 + - {{!}} + -
+ - :{{EquationNote|Eq. 4c}} comes from the trigonometric identity of the tangent of two angles. Suppose we have 3 angles, $\alpha$, $\beta$, and $\gamma$ that satisfy: + -
+ ::$\gamma = \alpha - \beta$ ::$\gamma = \alpha - \beta$ -
+ :Then the trigonometric identity gives us: :Then the trigonometric identity gives us: -
+ ::$\tan \gamma = \tan (\alpha - \beta) = {{\tan \alpha - \tan \beta} \over {1 + \tan \alpha \cdot \tan \beta}}$ ::$\tan \gamma = \tan (\alpha - \beta) = {{\tan \alpha - \tan \beta} \over {1 + \tan \alpha \cdot \tan \beta}}$ -
+ :Let $\tan \alpha = a$ , $\tan \beta = b$, and substitute into the equation above: :Let $\tan \alpha = a$ , $\tan \beta = b$, and substitute into the equation above: -
+ ::$\tan \gamma = {{a - b} \over {1 + a \cdot b}}$ , or $\gamma = \arctan {{a - b} \over {1 + a \cdot b}}$ ::$\tan \gamma = {{a - b} \over {1 + a \cdot b}}$ , or $\gamma = \arctan {{a - b} \over {1 + a \cdot b}}$ -
+ :Recall that we have the relationship: :Recall that we have the relationship: -
+ ::$\alpha - \beta = \gamma$ ::$\alpha - \beta = \gamma$ -
+ :Change the angles into arctan functions: :Change the angles into arctan functions: -
+ ::$\arctan(a) - \arctan (b) = \arctan {{a - b} \over {1 + a \cdot b}}$ ::$\arctan(a) - \arctan (b) = \arctan {{a - b} \over {1 + a \cdot b}}$ -
+ :If we move arctan(''b'') to the right side, we will get Euler's arctangent addition formula, which is the most important formula in this hidden section: :If we move arctan(''b'') to the right side, we will get Euler's arctangent addition formula, which is the most important formula in this hidden section: -
+ - {{EquationRef2|Eq. 4d}}$\arctan(a) = \arctan (b) + \arctan {{a - b} \over {1 + a \cdot b}}$ + {{EquationRef2|Eq. 5d}}$\arctan(a) = \arctan (b) + \arctan {{a - b} \over {1 + a \cdot b}}$ -
+ - :What {{EquationNote|Eq. 4d}} does is that, it takes a large angle, arctan(''a''), and divides it into two smaller angles, as shown in [[#Figure4c|Figure 4-c]]. From our previous discussion, we know that the series we use to estimate $\pi$ gets more convergent when we plug in smaller angles. So this formula helps us to get more efficient algorithms. + :What {{EquationNote|Eq. 5d}} does is that, it takes a large angle, arctan(''a''), and divides it into two smaller angles, as shown in [[#Figure7c|Figure 7c]]. From our previous discussion, we know that the series we use to estimate $\pi$ gets more convergent when we plug in smaller angles. So this formula helps us to get more efficient algorithms. -
+ - {{Anchor|Reference=Figure4c|Link=[[Image:Divide.jpg|right|thumb|400px|Figure 4-c
Dividing an angle]]}} + {{Anchor|Reference=Figure7c|Link=[[Image:Divide.jpg|right|thumb|400px|Figure 7c
Dividing an angle]]}} :Euler himself used this formula to get his algorithm for estimating $\pi$. He started from a simple fact: :Euler himself used this formula to get his algorithm for estimating $\pi$. He started from a simple fact: -
+ {{EquationRef2|Step 1}}${\pi \over 4} = \arctan 1$ {{EquationRef2|Step 1}}${\pi \over 4} = \arctan 1$ -
+ - :To divide this angle into smaller angles, we can plug ''a'' = 1 and ''b'' = 1/2 into {{EquationNote|Eq. 4d}}: + :To divide this angle into smaller angles, we can plug ''a'' = 1 and ''b'' = 1/2 into {{EquationNote|Eq. 5d}}: -
+ ::$\arctan 1 = \arctan {1 \over 2} + \arctan {1 \over 3}$ ::$\arctan 1 = \arctan {1 \over 2} + \arctan {1 \over 3}$ -
+ - :So it turns out that the angle left is arctan (1/3). Substituting this into {{EquationNote|Step 1}} yields: + :So it turns out that the angle is arctan (1/3). Substituting this into {{EquationNote|Step 1}} yields: - {{Anchor|Reference=Figure4d|Link=[[Image:EulerApproximationed.gif|right|thumb|400px|Figure 4-d
Euler's approximation of $\pi$]]}} + {{Anchor|Reference=Figure7d|Link=[[Image:EulerApproximationed.gif|right|thumb|400px|Figure 7d
Euler's approximation of $\pi$]]}} -
+ {{EquationRef2|Step 2}}${\pi \over 4} = \arctan {1 \over 2} + \arctan {1 \over 3}$ {{EquationRef2|Step 2}}${\pi \over 4} = \arctan {1 \over 2} + \arctan {1 \over 3}$ -
+ - :Next, let's focus on the angle arctan (1/2). Plug ''a'' = 1/2 and ''b'' = 1/3 into {{EquationNote|Eq. 4d}}: + :Next, let's focus on the angle arctan (1/2). Plug ''a'' = 1/2 and ''b'' = 1/3 into {{EquationNote|Eq. 5d}}: -
+ ::$\arctan {1 \over 2} = \arctan {1 \over 3} + \arctan {1 \over 7}$ ::$\arctan {1 \over 2} = \arctan {1 \over 3} + \arctan {1 \over 7}$ -
+ :Substitute this into {{EquationNote|Step 2}}: :Substitute this into {{EquationNote|Step 2}}: -
+ {{EquationRef2|Step 3}}${\pi \over 4} = 2\arctan {1 \over 3} + \arctan {1 \over 7}$ {{EquationRef2|Step 3}}${\pi \over 4} = 2\arctan {1 \over 3} + \arctan {1 \over 7}$ -
+ :We can keep doing this, using the Euler's arctangent addition formula to get smaller and smaller angles: :We can keep doing this, using the Euler's arctangent addition formula to get smaller and smaller angles: -
+ ::$\arctan {1 \over 3} = \arctan {1 \over 7} + \arctan {2 \over 11}$ (''a'' = 1/3 , ''b'' = 1/7) ::$\arctan {1 \over 3} = \arctan {1 \over 7} + \arctan {2 \over 11}$ (''a'' = 1/3 , ''b'' = 1/7) -
+ {{EquationRef2|Step 4}}${\pi \over 4} = 3\arctan {1 \over 7} + 2\arctan {2 \over 11}$ {{EquationRef2|Step 4}}${\pi \over 4} = 3\arctan {1 \over 7} + 2\arctan {2 \over 11}$ -
+ ::$\arctan {2 \over 11} = \arctan {1 \over 7} + \arctan {3 \over 79}$ (''a'' = 2/11 , ''b'' = 1/7) ::$\arctan {2 \over 11} = \arctan {1 \over 7} + \arctan {3 \over 79}$ (''a'' = 2/11 , ''b'' = 1/7) -
+ {{EquationRef2|Step 5}}${\pi \over 4} = 5\arctan {1 \over 7} + 2\arctan {3 \over 79}$ {{EquationRef2|Step 5}}${\pi \over 4} = 5\arctan {1 \over 7} + 2\arctan {3 \over 79}$ -
+ - :Here we have got{{EquationNote|Eq. 4c}}, the formula that Euler used to approximate $\pi$. [[#Figure4d|Figure 4-d]] shows a graphic representation of these 5 steps. + :This is {{EquationNote|Eq. 5c}}, the formula that Euler used to approximate $\pi$. [[#Figure7d|Figure 7d]] shows a graphic representation of these 5 steps. -
+ :We can certainly carry on to keep dividing it into even smaller angles, or try different values for ''a'' and ''b'' to get different series, but Euler stopped here because he thought these angles were small enough to give him an efficient algorithm. :We can certainly carry on to keep dividing it into even smaller angles, or try different values for ''a'' and ''b'' to get different series, but Euler stopped here because he thought these angles were small enough to give him an efficient algorithm. -
+ - {{!}}} + -

+ |NumChars=0}} |NumChars=0}} - The next step is to expand {{EquationNote|Eq. 4c}} using Taylor series, which allows us to do the numeric calculations: + The next step is to expand {{EquationNote|Eq. 5c}} using Taylor series, which allows us to do the numeric calculations: -

+ :$\pi = 20 ({1 \over 7} - {1 \over 3 \cdot 7^3} + {1 \over 5 \cdot 7^5} - {1 \over 7 \cdot 7^7} \cdots)$ :$\pi = 20 ({1 \over 7} - {1 \over 3 \cdot 7^3} + {1 \over 5 \cdot 7^5} - {1 \over 7 \cdot 7^7} \cdots)$ -
+ ::$+ 8 ({3 \over 79} - {3^3 \over 3 \cdot 79^3} + {3^5 \over 5 \cdot 79^5} - {3^7 \over 7 \cdot 79^7} \cdots)$ ::$+ 8 ({3 \over 79} - {3^3 \over 3 \cdot 79^3} + {3^5 \over 5 \cdot 79^5} - {3^7 \over 7 \cdot 79^7} \cdots)$ -
+ This series converges so fast that each term of it gives more than 1 digit of $\pi$. Using this algorithm, it will not take more several days to calculate the first 35 digits of $\pi$ with pencil and paper, which Ludolph spent most of his life on. This series converges so fast that each term of it gives more than 1 digit of $\pi$. Using this algorithm, it will not take more several days to calculate the first 35 digits of $\pi$ with pencil and paper, which Ludolph spent most of his life on. -

- Although Euler himself has never undertaken the calculation, this idea was developed and used by many other mathematicians at his time. In 1789, the Slovene mathematician Jurij Vega calculated the first 140 decimal places for $\pi$ of which the first 126 were correct. This record was broken in 1841, when William Rutherford calculated 208 decimal places with 152 correct ones. By the time of the invention of electronic digital computers, $\pi$ had been expanded to more than 500 digits. And we shouldn't forget that all of these started from the Taylor series of trigonometric functions. -

- Acknowledgement: Most of the historical information in this section comes from these this article: click [http://www.maa.org/editorial/euler/HEDI%2064%20Estimating%20pi.pdf here][http://www.maa.org/editorial/euler/HEDI%2064%20Estimating%20pi.pdf How Euler Did It], by Ed Sandifer. This articles talks about Euler's algorithm for estimating π.. + Although Euler himself never undertook the calculation, this idea was developed and used by many other mathematicians at his time. In 1789, the Slovene mathematician Jurij Vega calculated 140 decimal places for $\pi$, 126 of which were correct. This record was broken in 1841, when William Rutherford calculated 208 decimal places, 152 of which were correct. By the time of the invention of electronic digital computers, $\pi$ had been expanded to more than 500 digits. All of these efficient approximations began with the Taylor series of trigonometric functions! + Acknowledgement: Most of the historical information in this section comes from [http://www.maa.org/editorial/euler/HEDI%2064%20Estimating%20pi.pdf this article][http://www.maa.org/editorial/euler/HEDI%2064%20Estimating%20pi.pdf How Euler Did It], by Ed Sandifer. This articles talks about Euler's algorithm for estimating π.. + }} +

Approximating ''e''

+ The mathematical constant $e$, approximately equal to 2.71828, is also called [[Euler's Number]]. This important constant appears in calculus, differential equations, complex numbers, and many other branches of mathematics. It's also widely used in other disciplines like physics and engineering. So we would really like to know its exact value as accurately as possible. + [[Image:edef.jpg|right|thumb|360px|Figure 8a
Definition of $e$]] + + One way to define $e$ is: -

Approximating e

-
- The mathematical constant $e$, approximately equal to 2.71828, is also called [http://en.wikipedia.org/wiki/E_(mathematical_constant) Euler's Number]. This important constant appears in calculus, differential equations, complex numbers, and many other branches of mathematics. What's more, it's also widely used other subjects such as physics and engineering. So we would really like to know its exact value. - [[Image:edef.jpg|right|thumb|360px|Figure 5-a
Definition of $e$]] -

- Mathematically, $e$ is defined as: -

:$e = \lim_{n \to \infin} (1 + {1 \over n}) ^n$ :$e = \lim_{n \to \infin} (1 + {1 \over n}) ^n$ -
+ - In principle, we could have approximated $e$ using this definition. However, this method is so slow and inefficient that we are forced to find another one. For example, set ''n'' to 100 in the definition, and we can get: + In principle, we can approximate ''e'' using this definition. However, this method is slow and inefficient. For example, let ''n'' = 100 and substitute it into the definition. We get: -

+ :$e \approx (1 + {1 \over 100}) ^{100} = 2.70481 \cdots$ :$e \approx (1 + {1 \over 100}) ^{100} = 2.70481 \cdots$ -
+ - which gives us only 2 accurate digits. This is really, really horrible accuracy for an approximating algorithm. So we have to find another way to do this. + This is only accurate to 2 digits. This is horrible accuracy for an approximating algorithm, so we have to find an alternative. One such alternative approximation can be found using Taylor series. Using calculus, we can derive the Taylor series for ''e''''x'' and use it to make our approximation. -

+ - One possible way is to use the Taylor series of function ex, which has a very nice property: + {{SwitchPreview|HideMessage=Click here to hide the approximation of ''e'' using Taylor series.|ShowMessage=Click here to show the approximation of ''e'' using Taylor series. -

+ |PreviewText=''e''''x'' has the very convenient property...|FullText= + ''e''''x'' has a very convenient property: :$\frac{d}{dx} e^x = e^x$ :$\frac{d}{dx} e^x = e^x$ -
+ The proof of this property can be found in almost every calculus textbook. It tells us that all derivatives of the exponential function are equal: The proof of this property can be found in almost every calculus textbook. It tells us that all derivatives of the exponential function are equal: -
+ - :$f(x) = f'(x) = f''(x) = f ^{(3)}(x) = \cdots = e^x$ + :$f(x) = f'(x) = f''(x) = f ^{(3)}(x) = \cdots = e^x$, -
+ - , and: + and: -

+ :$f(0) = f'(0) = f''(0) = f ^{(3)}(0) = \cdots = 1$ :$f(0) = f'(0) = f''(0) = f ^{(3)}(0) = \cdots = 1$ -
+ - Substitute these derivatives into {{EquationNote|Eq. 2}}, the general formula of Taylor Series, we can get: + Substitute these derivatives into {{EquationNote|Eq. 2}}, the general formula of Taylor Series. We get: -

+ - :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} \cdots$ + :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + \cdots$ -
+ - Let ''x'' = 1, and we can get another way to approximate $e$: + Let ''x'' = 1 to approximate $e$: -

+ :$e = 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots$ :$e = 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots$ -
+ - This sequence is strongly convergent, since there are factorials in the denominators, and factorials grow really fast as ''n'' increases. Just take the first 10 terms and we can get: + This sequence converges quickly, since there are factorials in the denominators of each term, and factorials grow really fast as ''n'' increases. Just take the first 10 terms and we can get: -

+ + {{Anchor|Reference=Figure8b|Link=[[Image:TwoApproximations.gif|right|thumb|400px|Figure 8b
Two approximations of ''ex''. The Taylor series approximates ''e'' much more quickly.]]}} + :$e \approx 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots + {1 \over 9!} = 2.718281801 \cdots$ :$e \approx 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots + {1 \over 9!} = 2.718281801 \cdots$ -
+ - The real value of $e$ is 2.718281828··· , so we have got 7 accurate digits! Compared to the approximation by definition, which gives us only two digits at order 100, this algorithm is incredibly fast and efficient. + The real value of $e$ is 2.718281828··· , so we have obtained 7 accurate digits! Compared to the approximation by definition, which gives us only two accurate digits at order 100, this algorithm is incredibly fast and efficient. -

+ - In fact, we can get the same conclusion if we plot the function ex and its two approximations together, and see which one converges faster. We already have the Taylor series approximation: + In fact, we can get the same conclusion if we plot the function ''ex'' and its two approximations together, and see which one converges faster. We already have the Taylor series approximation: - {{Anchor|Reference=Figure5-b|Link=[[Image:TwoApproximations.gif|right|thumb|400px|Figure 5-b
Two approximations of ex. Taylor series is much faster.]]}} + -
+ :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + \cdots + {x^n \over n!}$ :$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + \cdots + {x^n \over n!}$ -
- We can also find the powers of $e$ using the [[#edef|definition]]: -

- :$e^x = (\lim_{n \to \infin} (1 + {1 \over n}) ^{n})^x = \lim_{n \to \infin} (1 + {1 \over n}) ^{nx} = \lim_{n \to \infin} (1 + {x \over nx}) ^{nx} = \lim_{{n'} \to \infin} (1 + {x \over {n'}}) ^ {n'}$ -
- ::$= \lim_{{n} \to \infin} (1 + {x \over {n}}) ^ {n}$ -
- in which n' = n·x . We can switch between n' and n because both of the go to infinity, and which one we use doesn't matter. -

- In [[#Figure5-b|Figure 5-b]], these two approximations are graphed together to approximate the original function ex. As we can see in the animation, Taylor series approximates the original function much faster than the definition does. -

+ In [[#Figure8b|Figure 8b]], these two approximations are graphed together with the original function ''e''''x''. As we can see in the animation, the Taylor series approximates the original function much faster than the definition does. + }} + ===Small-Angle Approximation=== + Taylor series are useful in physics for approximating the trigonometric values of small angles. Consider sin(0.1): + :$\sin (0.1) = 0.1 - {0.1^3 \over 3!} + {0.1^5 \over 5!} - \cdots$ + It is straightforward to evaluate both ''P''1(0.1) = 0.1 and ''P''3(0.1) = 0.099833···. The calculator evaluates sin(0.1) = 0.0998334166. For small angles like 0.1 radians, the third term in the Taylor-series approximation is substantially smaller than the first term, which, in the case of sine, is equal to the argument of the function. (The second term is 0.) It is often suitable, then, to take the first-order term of the Taylor series for sin(''x'') as its '''small-angle approximation''': + + :$\sin (x) \approx x$ for small ''x'' + + By a similar token, we may obtain small-angle approximations for the other trigonometric functions. In the case of cosine, we go out to the second-order term, since that is the first term that includes ''x'': + + :$\cos (x) \approx 1 - {x ^2 \over 2!}$ for small ''x'' + + Then + + :$\tan (x) = {\sin (x) \over \cos (x)} \approx {x\over 1-{x^2 \over 2}} \approx {x\over 1} = x$ for small ''x'', + + because for small ''x'' we only need the first-order approximations and the first-order approximation of cos(''x'') is 1. + + {{{!}}border="0" cellpadding=5 cellspacing=5 + {{!}}{{Anchor|Reference=Figure9a|Link=[[Image:Small sinx.gif|center|thumb|325px|Figure 9a
Comparison of sin(''x'') with its small-angle approximation.]]}}{{!}}{{!}}{{Anchor|Reference=Figure9b|Link=[[Image:Small cosx.gif|center|thumb|325px|Figure 9b
Comparison of cos(''x'') with its small-angle approximation.]]}}{{!}}{{!}}{{Anchor|Reference=Figure9c|Link=[[Image:Small tanx.gif|center|thumb|325px|Figure 9c
Comparison of tan(''x'') with its small-angle approximation.]]}} + {{!}}} + + What is the small-angle approximation good for? In the simplest respect, the small-angle approximation is "close enough," and it's quicker than evaluating more terms of a Taylor series. However, the small-angle approximation has an additional utility in that it can allow us to solve certain differential equations in closed form. The prime example of this is the derivation of the closed-form pendulum formula, which involves solving a second-order differential equation. Substituting in the small-angle approximation makes the derivation much simpler and gives us a cleaner result, although, since it is an approximation, it is not perfect and only holds for small angles. + + ====How Small is Small?==== + {{Anchor|Reference=Figure10a|Link=[[Image:Small abs error.gif|left|thumb|320px|Figure 10a
The absolute error of the various small angle approximations.]]}} + It is, of course, important to know when a small-angle approximation is appropriate and at what values the small-angle approximation ceases to be accurate. (Recall, again, that '''accuracy''' is the closeness of an approximation to the actual value.) There is not a universal answer to this concern. Physicists will often use an approximation as long as it can be used to represent whatever they need to model. If an approximation is not useful, then they will not use it. + + In any case, it is necessary to have some idea of how accurate an approximation is. Here, we will try to at least get a sense of just how accurate these small-angle approximations are. + + {{Anchor|Reference=Figure10b|Link=[[Image:Small_rel_error.gif|right|thumb|320px|Figure 10b
The relative error (the absolute error divided by the actual function value) of the various small angle approximations. The horizontal, black curve represents 1% error.]]}} + One way to do this would be to bound the error of our approximation as we do above in [[#Error Bound of a Taylor Series|error bound of a Taylor series]], but, for reasons explained in that section, this would necessarily be an overestimation of the error, which is helpful in practical circumstances but not for the point we are trying to make in this section. We can simply compare our small-angle approximations to the actual values of the functions that they approximate. + + [[#Figure 10a|Figure 10a]] plots the ''actual error'' of these functions; that is, the absolute value of the difference between the small-angle approximation and the original function. [[#Figure10b|Figure 10b]] plots the ''relative error'', or the actual error divided by the value of the actual function (this represents accuracy in the truest sense). The horizontal line represents 1% of relative error; where the curves intersect with this horizontal line is where the approximations begin to exceed 1% of relative error. + + + Cosine's small-angle approximation is the most accurate, while tangent is the least accurate. This makes sense when we consider the nature of each of the small-angle approximations. Sine and tangent are both first-order approximations, while cosine must be a second-order approximation, since its first-order Taylor polynomial is always 1. We would expect it, then, to be the most accurate. + + On the other hand, in making our small-angle approximation for tangent, we lose accuracy because we assume that the cosine is essentially 1. One could improve the tangent approximation's accuracy by using the second-order small-angle approximation for cosine instead of 1, but then the tangent approximation would lose its simplicity, which is the appeal and utility of a small-angle approximation in the first place! - |Field=Algebra - |InProgress=Yes |Field=Algebra |Field=Algebra - |InProgress=Yes + |InProgress=No }} }}

## Current revision

Taylor Series
Field: Algebra
Image Created By: Peng Zhao
Website: Math Images Project

Taylor Series

Taylor series and Taylor polynomials allow us to approximate functions that are otherwise difficult to calculate. The image at the right, for example, shows how successive Taylor polynomials come to better approximate the function sin(x). In this page, we will focus on how such approximations might be obtained as well as how the error of such approximations might be bounded.

# Basic Description

A Taylor series is a power series representation of an infinitely differentiable function. In other words, many functions, like the trigonometric functions, can be written alternatively as an infinite series of terms.

An nth-degree Taylor polynomial $P_n(x)$ for a function is the sum of the first n terms of a Taylor series. As a finite series, a Taylor polynomial can be computed exactly (no limits needed). Although it will not exactly match the infinite Taylor series or the original function, the approximation becomes progressively better as n increases.

In the animation above, Taylor polynomials are compared to the actual function y = sin(x) using the following polynomial expansion:

$\sin(x) \approx P_n(x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} + \cdots \pm {x^n \over n!}$    (for odd n)

n varies from 0 to 36. As n becomes larger and there are more terms in the Taylor polynomial, the Taylor polynomial comes to "look" more like the original function. In other words, it becomes a progressively better approximation of the function; it becomes more accurate.

How does one construct a Taylor series? As mentioned, Taylor series can be used to approximate infinitely differentiable functions. A Taylor polynomial, as will be shown later in the More Mathematical Explanation, is actually constructed according to the derivatives of a function at a certain point. The key idea behind Taylor series is this: Derivatives, roughly speaking, correspond to the shape of a curve, so the more derivatives that two functions have in common at one point, the more similar they will look at other nearby points.

Taylor series are important because they allow us to compute functions that cannot be computed directly. While the above Taylor polynomial for the sine function looks complicated and is annoying to evaluate by hand, it is just the sum of terms consisting of exponents and factorials, so the Taylor polynomial can be reduced to the basic operations of addition, subtraction, multiplication, and division. We can obtain an approximation by truncating the infinite Taylor series into a finite-degree Taylor polynomial, which we can evaluate.

The Taylor series for sine may not seem very useful to us, since we are used to hitting the sine function on our calculator which then spits out an answer. But our calculators actually make use of similar series to approximate the trigonometric functions, as well as other functions, to provide us with a decimal approximation. Likewise, physicists often take measurements and produce curves that do not clearly resemble a known function. However, they can use Taylor series to come up with a working model, even if it is not exact.

# A More Mathematical Explanation

Note: understanding of this explanation requires: *Calculus

## Basic Use of Taylor Series

Readers may, without knowing it, already be familiar with a particular [...]

## Basic Use of Taylor Series

Readers may, without knowing it, already be familiar with a particular type of Taylor series. Consider an infinite geometric series with first term 1 and common ratio x:

${1 \over {1-x}} = 1 + x + x^2 + x^3 + \cdots$ for $-1 < x < 1$

The left side of the equation is the formula for the sum of the convergent geometric series on the right. The right side is also an infinite power series, so it is the Taylor series for $f (x) = {1 \over {1-x}}$. Later we will provide examples of some other Taylor series, as well as the process for deriving them from the original functions.

Using Taylor series, we can approximate infinitely differentiable functions. For example, imagine that we want to approximate the sum of the infinite geometric series with first term 1 and common ratio $x = {1 \over 4}$. Using our knowledge of infinite geometric series, we know that the sum is ${1 \over {1 - {1 \over 4}}} = {4 \over 3} = 1.333 \cdots$. Let's see how the Taylor approximation does:

${P_2 \left({1 \over 4}\right) =} 1 + {1 \over 4} + \left({1 \over 4}\right)^2 = 1.3125$

This second-order Taylor polynomial brings us somewhat close to the value of $4 \over 3$ that we obtained above. Let's observe how adding on another term can improve our estimate:

${P_3 \left({1 \over 4}\right) =} 1 + {1 \over 4} + \left({1 \over 4}\right)^2 + \left({1 \over 4}\right)^3 = 1.328125$

As we expect, this approximation is closer still to the actual value, but not exact. Adding more terms would improve this accuracy further, but so long as the amount of terms that we add is finite, the approximation will never be exact.

Figure 1
Top: The function cos(x) (blue) and its 4th degree Taylor polynomial (red).

Bottom: The approximation of cos(35°) zoomed in 2,000 times.

At this point, you may be wondering what the use of a Taylor series approximation is if, as in the previous example, we don't need an estimate; we already have the exact answer on the left-hand side. Well, we don't always know the exact answer. For instance, a more complicated Taylor series is that of cos(x):

$\cos (x) = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + \cdots$ where x is in radians.

In this case, it is easy to select x so that we cannot exactly evaluate the left-hand side of the equation. For such functions, making an approximation can be more valuable. For instance, consider:

$\cos 35^\circ$

First we must convert degrees to radians in order to use the Taylor series:

$\cos 35^\circ = \cos \left({35 \over 180} \pi \right) \approx \cos 0.610865$

Then, substitute into the Taylor series of cosine above:

$\cos (0.610865) \approx 1 - {0.610865^2 \over 2!} + {0.610865^4 \over 4!}$

Here we have written the 4th-degree Taylor polynomial, but this should be enough to show us something. The right side of the equation can be reduced to the four simple operations, so we can easily calculate its value:

$\cos (0.610865) \approx 0.81922$

We can compare this to the value given by the calculator. The calculator's value, actually, is also an approximation obtained by a similar method, but we can expect it to be accurate for all displayed decimal places.

$\cos 35^\circ = 0.81915 \cdots$

So our approximating value agrees with the "actual" value to three decimal places, which is good accuracy for a basic approximation. As above, better accuracy could be attained by using more terms in the Taylor series.

This result can be observed if we zoom in on the point at which we are evaluating the function, as shown in Figure 1. In the large graph, the functions look almost identical at the point x = 35°, but there is indeed a difference between these two functions, as the zoomed-in version shows.

## The General Form of a Taylor Series

In this subsection, we will derive the general formula for a function's Taylor series. We begin by defining Taylor polynomials as follows:

The Taylor polynomial of degree n for f at a, written $P _n (x)$, is the polynomial that has the same 0th- to nth-order derivatives as function f(x) at point a. In other words, the nth-degree Taylor polynomial must satisfy:
$P _n (a) = f (a)$ (the 0th-order derivative of a function is itself)
$P _n ' (a) = f ' (a)$
$P _n '' (a) = f '' (a)$
$\vdots$
$P _n ^{(n)} (a) = f^{(n)} (a)$
where $P _n ^{(k)} (a)$ is the kth-order derivative of $P _n (x)$ at a.

We define Taylor series as follows:

The Taylor series $T (x)$ is the infinite Taylor polynomial for which all derivatives at a are equal to those of $f (x)$.

The following set of images show some examples of Taylor polynomials, from 0th- to 2nd-order:

 Figure 2aA 0th-degree Taylor polynomial. Figure 2bA first-degree Taylor polynomial. Figure 2cA second degree Taylor polynomial.

In order to construct a general formula for a Taylor series, we start with what we know: a Taylor series is a power series. Using the definition of power series, we write a general Taylor series for a function f around a as

Eq. 1         $T(x) = a_0 + a_1 (x-a)+ a_2 (x-a)^2 + a_3 (x-a)^3 + \cdots$,

in which a0, a1, a2, ... are unknown coefficients. Our goal is to find a more useful expression for these coefficients.

By definition of a Taylor polynomial, we know that the function $f(x)$ and Taylor series $T(x)$ must have the same derivatives of all degrees evaluated at a:

$T(a) = f(a)$,    $T'(a) = f'(a)$,     $T''(a) = f''(a)$,   $T ^{(3)} (a) = f ^{(3)} (a) \cdots$

How might we use this fact to bring us closer to finding the coefficients a0, a1, a2, ...? Let's start by taking the first few derivatives of Eq. 1:

$T(x) = a_0 + a_1 (x-a) + a_2 (x-a)^2 + a_3 (x-a)^3 + \cdots$
$T'(x) = 1 a_1 + 2 a_2 (x-a) + 3 a_3 (x-a)^2 + 4 a_4 (x-a)^3 + \cdots$
$T''(x) = 2\cdot 1 a_2 + 3 \cdot 2 a_3 (x-a) + 4 \cdot 3 a_4 (x-a)^2 + 5 \cdot 4 a_5 (x-a)^3 + \cdots$
$T^{(3)}(x) = 3 \cdot 2 \cdot 1 a_3 + 4 \cdot 3 \cdot 2 a_4 (x-a) + 5 \cdot 4 \cdot 3 a_5 (x-a)^2 + \cdots$
$T^{(4)}(x) = 4 \cdot 3 \cdot 2 \cdot 1 a_4 + 5 \cdot 4 \cdot 3 \cdot 2 a_5 (x-a) + 6 \cdot 5 \cdot 4 \cdot 3 a_6 (x-a)^2 + \cdots$

The pattern should now be recognizable, and it may be apparent how to solve for ak. When we evaluate any of the above derivatives at x = a, only the constant term will remain because all terms with (x - a) go to 0. Note then what happens after k derivatives. We get:

$T ^{(k)} (a) = k! \cdot a_k$.

Since in addition $T ^{(k)} (a) = f^{(k)}(a)$ by definition, we conclude

$f^{(k)}(a) = k! \cdot a_k$,

so

$a_k = {f ^{(k)}(a) \over k!}$.

This formula even holds for k=0, since 0! = 1. Thus it holds for all non-negative integers k. So, using derivatives, we have obtained an expression for all unknown coefficients of T(k) (x) in terms of the given function f. Substitute this back into Eq. 1 to get an explicit expression of Taylor series:

Eq. 2        $T(x) = f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2+\frac{f^{(3)}(a)}{3!}(x-a)^3+ \cdots$

or, in summation notation,

$T(x)=\sum_{k=0} ^ {\infin } \frac {f^{(k)}(a)}{k!} \, (x-a)^{k}$.

This is the standard formula of Taylor series that we will use throughout the rest of this page.

The nth-degree Taylor polynomial simply restricts this polynomial to a finite number, n, of terms:

$P_n(x) = f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2 + \frac{f^{(3)}(a)}{3!}(x-a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n$

or, in summation notation,

$P_n(x)=\sum_{k=0} ^ {n } \frac {f^{(k)}(a)}{k!} \, (x-a)^{k}$.

In many cases, it is convenient to let a = 0 to get a neater expression:

Eq. 3        $T(x) = f(0)+\frac {f'(0)}{1!} x + \frac{f''(0)}{2!} x^2 + \frac{f^{(3)}(0)}{3!}x^3 + \cdots$

Eq. 3 is called the Maclaurin series and is named after Scottish mathematician Colin Maclaurin, who made extensive use of these series in the 18th century.[1]

## Finding the Taylor Series for a Specific Function

Many Taylor series can be derived using Eq. 2 by substituting in f and a. Here we will demonstrate this process in detail for the natural logarithm function. The process in this section can be repeated for other elementary functions, such as sin(x), cos(x), and ex. Their Taylor series will be discussed in the other Taylor series section.

The natural log function is:

$f (x) = \ln (x)$

Its derivatives are:

$f'(x)=1/x$,
$f''(x)=-1/x^2$,
$f ^{(3)}(x)=2/x^3$,
$\vdots$
$f ^{(k)}(x) = {{(-1)^{k-1} \cdot (k-1)!} \over x^k}$

Since this function and its derivatives are undefined at x = 0, we cannot construct a Maclaurin series (Eq. 3) for it. Note that, when choosing a, one should select a value at which the derivatives f (k)(a) exist and at which they can be evaluated. For instance, centering our Taylor series at a = 2 would not be helpful because f (0)(2) = ln (2) is unknown and, in fact, cannot even be approximated until we have obtained our Taylor series. While it would be possible to write out the Taylor series, it would not be usable.

For the natural log, it makes sense to let a = 1 and compute the derivatives at this point:

$f(1) = \ln 1 = 0$,
$f'(1) = {1 \over 1} = 1$,
$f''(1) = -{ 1 \over 1^2} = -1$,
$f ^{(3)} (1) = {2 \over 1^3} = 2$,
$\vdots$
$f ^{(k)} (1) = {(-1)^{k-1} \cdot (k-1)!}$

Figure 3
Taylor series for natural log

Substitute these derivatives into Eq. 2, and we can get the Taylor series for $\ln (x)$ centered at x = 1:

$\ln (x) = (x-1) - {(x-1)^2 \over 2} + {(x-1)^3 \over 3} + \cdots$

We can avoid the cumbersome (x - 1)k notation by introducing a new function, g(x) = ln (1 + x). Now we can expand our polynomial around x = 0:

$\ln (1 + x) = x - {x^2 \over 2} + {x^3 \over 3} - {x^4 \over 4} + \cdots$

The animation to the right shows this Taylor polynomial with degree n varying from 0 to 25. As we can see, at lower values, the polynomial quickly comes to generate a close approximation of the original function. However, the right side exhibits some strange behavior: the polynomial diverges as n grows larger. This tells us that a Taylor series is not always a reliable approximation of the original function. The fact that they have same derivatives at one point doesn't always guarantee that the Taylor series will represent a suitable approximation at all values of x, even for arbitrarily large n. Other factors need to be considered.

Alas, power series, like the Taylor series for ln(1 + x), do not necessarily converge for all values of x. The Taylor series for natural log is divergent when $x > 1$, while a valid polynomial approximation needs to be convergent. Consider an arbitrary term in this series, $\pm x^n \over n$. As n increases, the denominator grows linearly, and the numerator grows exponentially. For arbitrarily large n, exponential growth will override linear growth, so the convergence or divergence of the series is determined by xn. If x > 1, then the Taylor series will diverge, hence the abnormal behavior of the right side of Figure 3. In this "divergent zone," although we can still write out and evaluate the polynomial for whatever n we like, we cannot expect it to approximate the original function.

Does this make it impossible to approximate ln(1 +x) for x greater than 1? It would seem that this would make our Taylor series useless in many cases. For example, imagine that we want to approximate ln(4):

$\ln (4) = \ln (1 + 3) = 3 - {3^2 \over 2} + {3^3 \over 3} - {3^4 \over 4} \cdots$

It is clear that this series will diverge rapidly, which contradicts our knowledge that ln(4) is defined. With some clever mathematical footwork, though, we can still find a solution. Instead, we write:

$\ln (4) = \ln (e \cdot {4 \over e}) = \ln (e) + \ln({4 \over e}) \approx 1 + \ln (1.47152) = 1 + \ln (1 + 0.47152)$
$\approx 1 + (0.47152 - {0.47152^2 \over 2} + {0.47152^3 \over 3} - {0.47152^4 \over 4} + \cdots)$

Since the Taylor series we found only converged for x < 1, we had to find some way to reduce the argument, 4, so that x was less than 1; we also needed to do this in such a way that the value of the whole expression remained unchanged. By using the identity ln(a ·b ) = ln(a ) + ln(b ), we were able to rewrite the logarithm so that our Taylor series did not diverge. Larger powers of e (Euler's number) may be used for larger values of x.

Let's review what we have done to find a Taylor series for ln(1 + x). How might this process be generalized to finding other Taylor series?

• We began by choosing a base point at which we could evaluate the derivatives of our function.
• We then figured out what those derivatives would be and found a general expression for the kth derivative of our function at a.
• With this information, we could substitute into Eq. 2 to obtain our Taylor series.
• In this example, we modified this Taylor series by recentering it around 0. This is generally not necessary; many Taylor series can be centered around x = 0 to begin with.
• In using our Taylor series, we had to be attentive to its "divergent zone." This, also, is not always necessary, since other Taylor series, like those introduced in the next section, converge for all values of x.

## Other Taylor Series

Using the process described above, we can obtain Taylor series for a variety of other functions, such as the following:

$\sin (x) = x - {x^3 \over 3!} + {x^5 \over 5!} - {x^7 \over 7!} + {x^9 \over 9!} - \cdots$ , expanded around the origin. x is in radians.
$\cos (x) = 1 - {x^2 \over 2!} + {x^4 \over 4!} - {x^6 \over 6!} + {x^8 \over 8!} - \cdots$ , expanded around the origin. x is in radians.
$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + {x^5 \over 5!} + \cdots$ , expanded around the origin.

In comparison with the above example of ln(x), these Taylor series are perhaps more straightforward to derive, even though they look slightly more complicated. Because the derivatives of sine, cosine and ex are all defined and easily evaluable at x = 0, we can center their respective Taylor series at 0 from the outset. As noted above, these series converge for all x (although a given Taylor polynomial for some finite n may not be accurate, particularly for values of x that are not close to the base point; see error bound).

Note that the powers of each successive term in the Taylor series for sine and cosine increase by 2, and each term alternates between positive and negative; this makes sense when we consider the nature of successive derivatives of sin (x) and cos(x) at x = 0. Their derivatives cycle through 1, 0, -1, and 0, so we obtain a pattern like that observed above, where every other term is zero and the remaining terms alternate in signs.

The Taylor series for ex follows from the fact that the derivative of ex is itself. ex will be derived in Approximating e. Let the derivation of Taylor series for sine and cosine using Eq. 2 be left to the reader.

These days, Taylor series are not often used directly to approximate the trigonometric functions, since it is easy enough to approximate the trigonometric functions using a calculator. They are, however, used in various indirect ways. For instance, we can compute the Taylor series of the function composition sin (2x2) by substituting 2x2 for x into the Taylor series for sin(x):

$\sin (2x^2) = 2x^2 - {(2x^2)^3 \over 3!} + {(2x^2)^5 \over 5!} - {(2x^2)^7 \over 7!} + \cdots = 2x^2 - {8x^6 \over 3!} + {32x^{10} \over 5!} - {128x^{14} \over 7!} + \cdots$

More complicated composition is also possible; for instance, to find the Taylor series for $e^{\sin x}$ one may substitute the whole Taylor series of sin(x) for x in the Taylor series for ex. In physics, it is often useful to make approximations using the first few terms of compositions of a Taylor series. The Rope around the Earth problem is one instance where this technique is necessary.

It is also possible to compose other objects into Taylor series . For instance, if we have a square matrix A, the operation eA is not defined by the normal rules of exponents. What does it mean, anyway, to put something to the power of a matrix? However, we can compose the matrix A into the Taylor series for e:

$e^A = I + A + {1 \over 2!}A^2 + {1 \over 3!}A^3 + {1 \over 4!}A^4 + {1 \over 5!}A^5 + \cdots$, where I is the identity matrix of the same size as A.

This composition is necessary for solving some systems of linear differential equations. Hopefully these brief examples give you an idea of how powerful Taylor series can be when applied to other branches of mathematics!

Consider another example:

$\lim_{x \rightarrow 0} {\sin(x) \over x}$

It is clear that when x = 0, the quotient in this limit expression is undefined, so one cannot evaluate the limit by evaluating the quotient at 0. One way to evaluate the limit of an expression whose numerator and denominator both go to 0 is by using l'Hôpital's rule:

$\lim_{x \rightarrow 0} {\sin(x) \over x} = \lim_{x \rightarrow 0} {(\sin(x))' \over (x)'} = \lim_{x \rightarrow 0} {\cos(x) \over 1} = 1$

Alternatively, one can use Taylor series! Substitute the Taylor series for sin(x) in:

$\lim_{x \rightarrow 0} {\sin(x) \over x} = \lim_{x \rightarrow 0} {{x - {x^3 \over 3!} + {x^5 \over 5!} - \cdots} \over x} = \lim_{x \rightarrow 0} ({1 - {x^2 \over 3!} + {x^4 \over 5!} - \cdots}) = 1$

We have obtained the same limit.

Taylor series also help us understand the derivatives of these functions. Above it was mentioned that each derivative of ex is itself. More generally, for any real c, the arbitrary kth derivative of ecx is given by:

${d^k \over dx^k}e^{cx} = c^k e^{cx}$

If we substitute cx for x in our Taylor series for ex, we get:

$e^{cx} = 1 + cx + {(cx)^2 \over 2!} + {(cx)^3 \over 3!} + {(cx)^4 \over 4!} + \cdots = 1 + cx + {c^2 \over 2!} x^2 + {c^3 \over 3!} x^3 + {c^4 \over 4!} x^4 + \cdots$

Differentiating this, we get:

${d \over dx} e^{cx} = c + c^2 x + {c^3 \over 2!} x^2 + {c^4 \over 3!} x^3 + {c^5 \over 4!} x^4 + \cdots$
$= c(1 + cx + {c^2 \over 2!} x^2 + {c^3 \over 3!} x^3 + {c^4 \over 4!} x^4 + \cdots)$
$=ce^{cx}$

Each differentiation of the Taylor series will multiply ecx by c, as expected.

## Error Bound of a Taylor Series

Throughout this page so far, we have often made reference to the accuracy of our Taylor polynomial approximations...

Throughout this page so far, we have often made reference to the accuracy of our Taylor-polynomial approximations. Recall that accuracy is the closeness of an approximation to its true value. It would be practical to be able to quantify the closeness of our approximations so that we can know how much we can rely on them, or so that we may add more terms if our approximation is not sufficiently accurate. In other words, we want to understand how much error there might be for a given Taylor approximation so that the approximation is usable.

We should not expect to be able to calculate the exact error. If that were possible, then we would be able to find an exact "approximation" by adding the "error" to our Taylor polynomial. Similarly, we cannot directly compare the approximate value to the actual value because we don't know the actual value! What we can do is bound the error; we can find how accurate our approximation is at worst.

Consider a function $f (x)$ for which we have a Taylor polynomial $P_n (x)$ centered at a. We would like to find a formula to bound our approximation. We define the remainder $R_n (x)$ as:

$R_n (x) = f (x) - P_n (x)$, or
$f (x) = P_n (x) + R_n(x)$

A useful characterization of $R_n (x)$ happens to be:

Eq. 4        $|R_n (x)| \leq {M \over (n+1)!} (x-a)^{n+1}$ where M is the upper bound for the (n+1)th derivative of f on the interval [a, x].

It is not obvious how Eq. 4 is derived from our definition of remainder; the proof is rather complex and unintuitive. You can choose to skip the derivation and go on to learn how to use the above equation to bound the error of a Taylor-polynomial approximation.

Recall that we constructed our Taylor polynomial Pn(x) such that f(x) and Pn(x) have the same first n derivatives at a. We also defined
$R_n(x) = f(x) - P_n(x)$.
It must hold that
$R_n(a) = f(a) - P_n(a) = 0$
$R'_n(a) = f'(a) - P'_n(a) = 0$
$R''_n(a) = f''(a) - P''_n(a) = 0$
$\vdots$
$R^{(n)}_n(a) = f^{(n)}(a) - P^{(n)}_n(a) = 0$
Since Pn(x) is an nth-degree polynomial, its (n + 1)th derivative is 0:
$P^{(n+1)}_n(x) = 0$
so
$R^{(n+1)}_n(x) = f^{(n+1)}(x)$.
We bound f (n + 1) (x) on the interval [a, x]. In particular, we choose M so that
$|f^{(n+1)}(x)| = |R^{(n+1)}_n(x)| \leq M$.
So
$-M \leq R^{(n+1)}_n(x) \leq M$
and
$- \int_a ^x M dx \leq \int_a ^x R^{(n+1)}_n(x) dx \leq \int_a ^x M dx$
$-M(x-a) \leq R^{(n)}_n(x) - R^{(n)}_n(a) \leq M(x-a)$.
As established above,
$R^{(n)}_n(a) = 0$,
so
$-M(x-a) \leq R^{(n)}_n(x) \leq M(x-a)$.
We can integrate this again:
$-\int_a^x M(x-a) dx \leq \int_a^x R^{(n)}_n(x) dx \leq \int_a^x M(x-a) dx$.
Examine the integral:
\begin{align} \int_a^x (Mx-Ma)dx &= \left[ {Mx^2 \over 2} - Max \right]_a^x \\ &= {Mx^2 \over 2} - Max - {Ma^2 \over 2} + Ma^2 = {Mx^2 \over 2} - Max + {Ma^2 \over 2} \\ &= {M \over 2}(x^2 - 2ax + a^2) \\ &= {M \over 2}(x - a)^2 \end{align}
So we now have:
$-{M \over 2}(x-a)^2 \leq R^{(n-1)}_n(x) \leq {M \over 2}(x-a)^2$
It might be intuitively evident that, integrating this inequality n - 1 more times, we will obtain Eq. 4. We will now demonstrate this by induction.
Above we established the base case. We now assume that Eq. 4 holds for some integer k < n and will demonstrate that it therefore holds for k + 1.
$-{M \over k!}(x-a)^k \leq R^{(n+1-k)}_n(x) \leq {M \over k!}(x-a)^k$
Again, we examine the integral:
$\int_a^x {M \over k!}(x-a)^k dx = \left[ {M \over (k+1)!}(x-a)^{k+1} \right]_a^x = {M \over (k+1)!}(x-a)^{k+1} - {M \over (k+1)!}(a-a)^{k+1} = {M \over (k+1)!}(x-a)^{k+1}$
As established previously, the first n derivatives of Rn(x) evaluated at x = a are 0, so we obtain:
$-{M \over (k+1)!}(x-a)^{k+1} \leq R^{(n-k)}_n(x) \leq {M \over (k+1)!}(x-a)^{k+1}$
Therefore, if we continue integrating, we obtain:
$-{M \over (n+1)!}(x-a)^{n+1} \leq R_n(x) \leq {M \over (n+1)!}(x-a)^{n+1}$, or
$|R_n(x)| \leq {M \over (n+1)!}(x-a)^{n+1}$.

How might one use Eq. 4 to check the accuracy of a Taylor polynomial? M is an upper bound on the (n+1)th derivative of f on the interval [a, x] (that is, on the interval between where the Taylor polynomial is centered and where it is being evaluated). This seems fairly arbitrary but may make more sense in practice.

Figure 4
A comparison between the actual error and the upper error bound computed using Eq. 4 for increasing values of n.
Figure 5
A comparison of the Taylor polynomial with the actual function sin(x) at two x values for successive approximations.

Modified from KeyCurriculum Taylor series activity on Sketchpad.

Imagine that we are trying to find an error bound for sin(x). All derivatives of sin(x) are one of:

$\pm \sin(x), \pm \cos(x)$.

In other terms,

$-1 \leq f^{(k+1)}(x) \leq 1$ $\forall$ $x,k$,

so

$-1 \leq M \leq 1$.

Then we can say that, for any Taylor polynomial for sin(x) evaluated at any x,

$R_n(x) \leq \left |{x^{n+1} \over (n+1)!} \right|$

This is straightforward to evaluate. Since the factorial growth in the denominator outpaces the exponential growth in the numerator, it is evident that, as expected, the error becomes smaller for larger n.

In Figure 4, the "flattened" part in the center of the graph is where our approximation is "good". To the naked eye, at least, the error appears to be very close to 0.

Notice, in Figure 5, that the approximation becomes sufficiently close to 0 for the lower x value much more quickly than it does for higher x values. But by including enough terms, we can make our approximation as accurate as we would like at either point. In this figure, it is also noteworthy that, although the error eventually displays a 0 in each decimal place, the error at any value never actually reaches 0, so long as n is finite. Finally, note that Rn in this graphic is actual error, the difference between the Taylor polynomial and the original function, not the error bound computed by boundingf (k + 1)(c).

As Figure 4 shows, the error bound is rarely equal to actual error; it is usually greater, often much greater, than the actual error. For instance,

$P_5(1) - \sin (1) = 0.000196 \cdots$

but

$R_5 (1) = {1 \over 6!} = 0.00138 \cdots$

As we can see, even at a point where the difference between the Taylor polynomial and original function could not be distinguished by the naked eye, the actual error is often much smaller than the bounded error. This should make us especially confident in using our approximations. In Figure 4, the red curve is almost always less than or equal to the blue curve (with a small exception when n = 1). This is desirable when approximating error: we would like to be certain that the actual error is less than our approximation.

Suppose that we would like to make an approximation of the value of $f(x) = e^{2x}$ at x = 0.25. Say we choose to make a 3rd-degree Taylor approximation using the Taylor polynomial centered at 0. The Taylor polynomial is:

$P_3 (0.25) = 1 + {2(0.25) \over 1!} + {4(0.25)^2 \over 2!} + {8(0.25)^3 \over 3!} = 1.6458333\cdots$

The error is:

$R_3 (0.25) = {M \over 4!} (0.25)^{4}$

How do we bound M on the interval [0, 0.25]? We know that in general,

${d^k \over dx^k}e^{px} = p^k e^{px}$

Evaluating this initially seems to be problematic. In our example, p = 2, and pk can be calculated easily. But we don't know what e2x is at most for the interval [0, 0.25]; that is why we are making a Taylor polynomial approximation in the first place! However, we just need to recall that we are looking for an error bound, which does not to be exact. We know:

$e^{2 \cdot 0.25} = e^{0.5} = \sqrt{e}$.

Moreover,

$e < 4$,

so

$\sqrt{e} < \sqrt{4}$.

Thus we are certain that on the interval [0, 0.25], $e^{2x} < 2$. Each differentiation doubles this bound, so

$M = 2 \cdot 2^{n+1}$.

We can now finish calculating the error:

$R_3 (0.25) \leq {2 \cdot 2^4 \over 4!} (0.25)^{4} = 0.00521$

This gives us a good idea of how accurate our approximation is. The actual value of the function is less than 0.00521 away from the third-degree Taylor approximation:

$P_3(0.25) - R_3(0.25) < f(0.25) < P_3(0.25) + R_3(0.25)$
$1.640623 < e^{0.5} < 1.651043$

Suppose that we desire greater accuracy. Say, specifically, that we would like to know what degree Taylor polynomial would be necessary to have error less than 10-4. We must solve for N where:

${2 \cdot 0.5^{N+1} \over (N+1)!} < {1 \over 10^4}$

By substituting in various values of N, we find that the lowest integer for which this inequality holds is N = 5, so if we want to be sure our approximation has an error of less than 10^-4, we should use a 5th degree Taylor polynomial.

# Why It's Interesting

Figure 6
A modern TI calculator

Have you ever wondered how calculators determine square roots, sines, cosines, and exponentials? For instance, if you were to type $\sin{\pi \over 2}$ or $e^2$ into your calculator, how does it determine which value to spit out? The number must be related to our input in some way, but what exactly is the relationship? Does the calculator just read from an index of known values? Is there a more mathematical and precise way for the calculator to evaluate these functions?

The answer to this latter question is yes. There are algorithms that give an approximate value of sine, for example, using only the four basic operations (+, -, x, /)[2]. Before the age of electronic calculators, mathematicians studied these algorithms in order to approximate these functions manually. The Taylor series, named after English mathematician Brook Taylor, is one such way of making these approximations. Basically, Taylor said that there is a way to expand any infinitely differentiable function into a polynomial series about a certain point. The strength of the Taylor series is its ability to approximate certain functions that cannot otherwise be calculated.

The calculator's algorithm for many functions uses this method to efficiently find a suitable approximation in the form of a polynomial series. Expanding enough terms for several digits of accuracy is easy for a computing device, even though Taylor series may look daunting and tedious to the naked eye. This algorithm is built in the permanent memory (ROM) of electronic calculators, and is triggered when a function like sine or cosine is called[3].

As is shown in the More Mathematical Explanation, Taylor series can be used to derive many interesting and useful series. Some of these series have helped mathematicians to approximate the values of important irrational constants such as $\pi$ and $e$.

### Approximating π

$\pi$, or the ratio of a circle's circumference to its diameter, is one of the oldest, most important, and most interesting mathematical constants. The earliest documentation of $\pi$ can be traced back to ancient Egypt and Babylon, in which people used empirical values of $\pi$ such as 25/8 = 3.1250, or (16/9)2 ≈ 3.1605[4].

Figure 7a
Archimedes' method to approximate π

The first recorded algorithm for rigorously calculating the value of $\pi$ was a geometrical approach using polygons, devised around 250 BC by the Greek mathematician Archimedes. Archimedes computed upper and lower bounds of $\pi$ by drawing regular polygons inside and outside a circle, and calculating the perimeters of the outer and inner polygons. He proved that 223/71 < $\pi$ < 22/7 by using a 96-sided polygon, which gives us 2 accurate decimal digits: π ≈ 3.14[5].

Mathematicians continued to use this polygon method for the next 1,800 years. The more sides their polygons had, the more accurate their approximations would be. This approach peaked at around 1600, when the Dutch mathematician Ludolph van Ceulen used a 260 - sided polygon to obtain the first 35 digits of $\pi$[6]. He spent a major part of his life on this calculation. In memory of his contribution, sometimes $\pi$ is still called "the Ludolphine number".

However, mathematicians have had enough of trillion-sided polygons. Starting in the 17th century, they devised much better approaches for computing $\pi$, using calculus rather than geometry. Mathematicians discovered numerous infinite series associated with $\pi$ , and the most famous one among them is the Leibniz series:

${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$

We will explain how Leibniz got this amazing result and how it allowed him to approximate $\pi$.

This amazing series comes directly from the Taylor series of arctan(x)...

This amazing series comes directly from the Taylor series of arctan(x):

Eq. 5a        $\arctan (x) = x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots$

We can get Eq. 5a by directly computing the derivatives of all orders for arctan(x) at x = 0, but the calculation involved is rather complicated. There is a much easier way to do this if we notice the following fact:

Eq. 5b        ${d \over dx} \arctan (x) = {1 \over {1 + x^2}}$

Recall that we gave the summation formula of geometric series in the More Mathematical Explanation section :

${ 1 \over {1 - r}} = 1 + r + r^2 + r^3 + r^4 \cdots$ , $-1 < r < 1$

If we substitute r = - x2 into the summation formula above, we can expand the right side of Eq. 5b into an infinite sequence:

Figure 7b
Gottfried Wilhelm Leibniz
Discoverer of Leibniz series
${ 1 \over {1 + x^2}} = 1 - x^2 + x^4 - x^6 + x^8 \cdots$

So Eq. 5b changes into:

${d \over dx} \arctan (x) = 1 - x^2 + x^4 - x^6 + x^8 \cdots$

Integrating both sides gives us:

$\arctan (x) = C + x - {x^3 \over 3} + {x^5 \over 5} - {x^7 \over 7} + {x^9 \over 9} \cdots$

Let x = 0. This changes the equation to 0 = C . So the integrating constant C vanishes, and we get Eq. 5a.

One may notice that, like Taylor series of many other functions, this series is not convergent for all values of x. It only converges for -1 ≤ x ≤ 1. Fortunately, this is just enough for us to proceed. Substituting x = 1 into it, we can get the Leibniz series:

${\pi \over 4} = 1 - {1 \over 3} + {1 \over 5} - {1 \over 7} + {1 \over 9} \cdots$

The Leibniz series gives us a radically improved way to approximate $\pi$: no polygons, no square roots, just the four basic operations. However, this particular series is not very efficient for computing $\pi$, since it converges rather slowly. The first 1,000 terms of Leibniz series give us only two accurate digits: π ≈ 3.14. This is horribly inefficient, so most mathematicians would prefer not to use this algorithm.

Fortunately, we can get series that converge much faster if we substitute smaller values of x , such as $1 \over \sqrt{3}$ , into Eq. 5a:

$\arctan {1 \over \sqrt{3}} = {\pi \over 6} = {1 \over \sqrt{3}} - {1 \over {3 \cdot 3 \sqrt{3}}} + {1 \over {5 \cdot 3^2 \sqrt{3}}} - {1 \over {7 \cdot 3^3 \sqrt{3}}} \cdots$

which gives us:

$\pi = \sqrt{12}(1 - {1 \over {3 \cdot 3}} + {1 \over {5 \cdot 3^2}} - {1 \over {7 \cdot 3^3}} + \cdots)$

This series is much more efficient than the Leibniz series, since there are powers of 3 in the denominators. The first 10 terms of it give us 5 accurate digits, and the first 100 terms give us 50. Leibniz himself used the first 22 terms to compute an approximation of π, which is correct to 11 decimal places: 3.14159265358.

However, mathematicians were still not satisfied with this efficiency. They kept substituting smaller x values into Eq. 5a to get more convergent series. Among the mathematicians who did this was Leonhard Euler, one of the greatest mathematicians in the 18th century. In his attempt to approximate $\pi$, Euler discovered the following non-intuitive formula:

Eq. 5c        $\pi = 20 \arctan {1 \over 7} + 8 \arctan {3 \over 79}$

Although Eq. 5c looks really weird, it is indeed an equality, not an approximation. The following hidden section shows how it is derived in detail.

Eq. 5c comes from the trigonometric identity of the tangent of two angles. Suppose we have 3 angles, $\alpha$, $\beta$, and $\gamma$ that satisfy:
$\gamma = \alpha - \beta$
Then the trigonometric identity gives us:
$\tan \gamma = \tan (\alpha - \beta) = {{\tan \alpha - \tan \beta} \over {1 + \tan \alpha \cdot \tan \beta}}$
Let $\tan \alpha = a$ , $\tan \beta = b$, and substitute into the equation above:
$\tan \gamma = {{a - b} \over {1 + a \cdot b}}$ , or $\gamma = \arctan {{a - b} \over {1 + a \cdot b}}$
Recall that we have the relationship:
$\alpha - \beta = \gamma$
Change the angles into arctan functions:
$\arctan(a) - \arctan (b) = \arctan {{a - b} \over {1 + a \cdot b}}$
If we move arctan(b) to the right side, we will get Euler's arctangent addition formula, which is the most important formula in this hidden section:
Eq. 5d        $\arctan(a) = \arctan (b) + \arctan {{a - b} \over {1 + a \cdot b}}$
What Eq. 5d does is that, it takes a large angle, arctan(a), and divides it into two smaller angles, as shown in Figure 7c. From our previous discussion, we know that the series we use to estimate $\pi$ gets more convergent when we plug in smaller angles. So this formula helps us to get more efficient algorithms.

Figure 7c
Dividing an angle

Euler himself used this formula to get his algorithm for estimating $\pi$. He started from a simple fact:
Step 1        ${\pi \over 4} = \arctan 1$
To divide this angle into smaller angles, we can plug a = 1 and b = 1/2 into Eq. 5d:
$\arctan 1 = \arctan {1 \over 2} + \arctan {1 \over 3}$
So it turns out that the angle is arctan (1/3). Substituting this into Step 1 yields:

Figure 7d
Euler's approximation of $\pi$

Step 2        ${\pi \over 4} = \arctan {1 \over 2} + \arctan {1 \over 3}$
Next, let's focus on the angle arctan (1/2). Plug a = 1/2 and b = 1/3 into Eq. 5d:
$\arctan {1 \over 2} = \arctan {1 \over 3} + \arctan {1 \over 7}$
Substitute this into Step 2:
Step 3        ${\pi \over 4} = 2\arctan {1 \over 3} + \arctan {1 \over 7}$
We can keep doing this, using the Euler's arctangent addition formula to get smaller and smaller angles:
$\arctan {1 \over 3} = \arctan {1 \over 7} + \arctan {2 \over 11}$ (a = 1/3 , b = 1/7)
Step 4        ${\pi \over 4} = 3\arctan {1 \over 7} + 2\arctan {2 \over 11}$
$\arctan {2 \over 11} = \arctan {1 \over 7} + \arctan {3 \over 79}$ (a = 2/11 , b = 1/7)
Step 5        ${\pi \over 4} = 5\arctan {1 \over 7} + 2\arctan {3 \over 79}$
This is Eq. 5c, the formula that Euler used to approximate $\pi$. Figure 7d shows a graphic representation of these 5 steps.
We can certainly carry on to keep dividing it into even smaller angles, or try different values for a and b to get different series, but Euler stopped here because he thought these angles were small enough to give him an efficient algorithm.

The next step is to expand Eq. 5c using Taylor series, which allows us to do the numeric calculations:

$\pi = 20 ({1 \over 7} - {1 \over 3 \cdot 7^3} + {1 \over 5 \cdot 7^5} - {1 \over 7 \cdot 7^7} \cdots)$
$+ 8 ({3 \over 79} - {3^3 \over 3 \cdot 79^3} + {3^5 \over 5 \cdot 79^5} - {3^7 \over 7 \cdot 79^7} \cdots)$

This series converges so fast that each term of it gives more than 1 digit of $\pi$. Using this algorithm, it will not take more several days to calculate the first 35 digits of $\pi$ with pencil and paper, which Ludolph spent most of his life on.

Although Euler himself never undertook the calculation, this idea was developed and used by many other mathematicians at his time. In 1789, the Slovene mathematician Jurij Vega calculated 140 decimal places for $\pi$, 126 of which were correct. This record was broken in 1841, when William Rutherford calculated 208 decimal places, 152 of which were correct. By the time of the invention of electronic digital computers, $\pi$ had been expanded to more than 500 digits. All of these efficient approximations began with the Taylor series of trigonometric functions!

Acknowledgement: Most of the historical information in this section comes from this article[7].

### Approximating e

The mathematical constant $e$, approximately equal to 2.71828, is also called Euler's Number. This important constant appears in calculus, differential equations, complex numbers, and many other branches of mathematics. It's also widely used in other disciplines like physics and engineering. So we would really like to know its exact value as accurately as possible.

Figure 8a
Definition of $e$

One way to define $e$ is:

$e = \lim_{n \to \infin} (1 + {1 \over n}) ^n$

In principle, we can approximate e using this definition. However, this method is slow and inefficient. For example, let n = 100 and substitute it into the definition. We get:

$e \approx (1 + {1 \over 100}) ^{100} = 2.70481 \cdots$

This is only accurate to 2 digits. This is horrible accuracy for an approximating algorithm, so we have to find an alternative. One such alternative approximation can be found using Taylor series. Using calculus, we can derive the Taylor series for ex and use it to make our approximation.

ex has the very convenient property...

ex has a very convenient property:

$\frac{d}{dx} e^x = e^x$

The proof of this property can be found in almost every calculus textbook. It tells us that all derivatives of the exponential function are equal:

$f(x) = f'(x) = f''(x) = f ^{(3)}(x) = \cdots = e^x$,

and:

$f(0) = f'(0) = f''(0) = f ^{(3)}(0) = \cdots = 1$

Substitute these derivatives into Eq. 2, the general formula of Taylor Series. We get:

$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + {x^4 \over 4!} + \cdots$

Let x = 1 to approximate $e$:

$e = 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots$

This sequence converges quickly, since there are factorials in the denominators of each term, and factorials grow really fast as n increases. Just take the first 10 terms and we can get:

Figure 8b
Two approximations of ex. The Taylor series approximates e much more quickly.

$e \approx 1 + 1 + {1 \over 2!} + {1 \over 3!} + {1 \over 4!} + \cdots + {1 \over 9!} = 2.718281801 \cdots$

The real value of $e$ is 2.718281828··· , so we have obtained 7 accurate digits! Compared to the approximation by definition, which gives us only two accurate digits at order 100, this algorithm is incredibly fast and efficient.

In fact, we can get the same conclusion if we plot the function ex and its two approximations together, and see which one converges faster. We already have the Taylor series approximation:

$e^x = 1 + x + {x^2 \over 2!} + {x^3 \over 3!} + \cdots + {x^n \over n!}$

In Figure 8b, these two approximations are graphed together with the original function ex. As we can see in the animation, the Taylor series approximates the original function much faster than the definition does.

### Small-Angle Approximation

Taylor series are useful in physics for approximating the trigonometric values of small angles. Consider sin(0.1):

$\sin (0.1) = 0.1 - {0.1^3 \over 3!} + {0.1^5 \over 5!} - \cdots$

It is straightforward to evaluate both P1(0.1) = 0.1 and P3(0.1) = 0.099833···. The calculator evaluates sin(0.1) = 0.0998334166. For small angles like 0.1 radians, the third term in the Taylor-series approximation is substantially smaller than the first term, which, in the case of sine, is equal to the argument of the function. (The second term is 0.) It is often suitable, then, to take the first-order term of the Taylor series for sin(x) as its small-angle approximation:

$\sin (x) \approx x$ for small x

By a similar token, we may obtain small-angle approximations for the other trigonometric functions. In the case of cosine, we go out to the second-order term, since that is the first term that includes x:

$\cos (x) \approx 1 - {x ^2 \over 2!}$ for small x

Then

$\tan (x) = {\sin (x) \over \cos (x)} \approx {x\over 1-{x^2 \over 2}} \approx {x\over 1} = x$ for small x,

because for small x we only need the first-order approximations and the first-order approximation of cos(x) is 1.

 Figure 9aComparison of sin(x) with its small-angle approximation. Figure 9bComparison of cos(x) with its small-angle approximation. Figure 9cComparison of tan(x) with its small-angle approximation.

What is the small-angle approximation good for? In the simplest respect, the small-angle approximation is "close enough," and it's quicker than evaluating more terms of a Taylor series. However, the small-angle approximation has an additional utility in that it can allow us to solve certain differential equations in closed form. The prime example of this is the derivation of the closed-form pendulum formula, which involves solving a second-order differential equation. Substituting in the small-angle approximation makes the derivation much simpler and gives us a cleaner result, although, since it is an approximation, it is not perfect and only holds for small angles.

#### How Small is Small?

Figure 10a
The absolute error of the various small angle approximations.

It is, of course, important to know when a small-angle approximation is appropriate and at what values the small-angle approximation ceases to be accurate. (Recall, again, that accuracy is the closeness of an approximation to the actual value.) There is not a universal answer to this concern. Physicists will often use an approximation as long as it can be used to represent whatever they need to model. If an approximation is not useful, then they will not use it.

In any case, it is necessary to have some idea of how accurate an approximation is. Here, we will try to at least get a sense of just how accurate these small-angle approximations are.

Figure 10b
The relative error (the absolute error divided by the actual function value) of the various small angle approximations. The horizontal, black curve represents 1% error.

One way to do this would be to bound the error of our approximation as we do above in error bound of a Taylor series, but, for reasons explained in that section, this would necessarily be an overestimation of the error, which is helpful in practical circumstances but not for the point we are trying to make in this section. We can simply compare our small-angle approximations to the actual values of the functions that they approximate.

Figure 10a plots the actual error of these functions; that is, the absolute value of the difference between the small-angle approximation and the original function. Figure 10b plots the relative error, or the actual error divided by the value of the actual function (this represents accuracy in the truest sense). The horizontal line represents 1% of relative error; where the curves intersect with this horizontal line is where the approximations begin to exceed 1% of relative error.

Cosine's small-angle approximation is the most accurate, while tangent is the least accurate. This makes sense when we consider the nature of each of the small-angle approximations. Sine and tangent are both first-order approximations, while cosine must be a second-order approximation, since its first-order Taylor polynomial is always 1. We would expect it, then, to be the most accurate.

On the other hand, in making our small-angle approximation for tangent, we lose accuracy because we assume that the cosine is essentially 1. One could improve the tangent approximation's accuracy by using the second-order small-angle approximation for cosine instead of 1, but then the tangent approximation would lose its simplicity, which is the appeal and utility of a small-angle approximation in the first place!

# Teaching Materials

There are currently no teaching materials for this page. Add teaching materials.

# References

1. Colin Maclaurin. Wikipedia.
2. How does the calculator find values of sine, from homeschoolmath. This is an article about calculator programs for approximating functions.
3. Calculator, from Wikipedia. This article explains the structure of an electronic calculator.
4. Pi, from Wolfram MathWorld. This article contains some history of Pi.
5. Archimedes' Approximation of Pi. This is a thorough explanation of Archimedes' method.
6. Digits of Pi, by Barry Cipra. Documentation of Ludolph's work is included here.
7. How Euler Did It, by Ed Sandifer. This articles talks about Euler's algorithm for estimating π.

Have questions about the image or the explanations on this page?