# Taylor Expansion

- Page ID
- 558

The special type of series known as Taylor series, allow us to express any mathematical function, real or complex, in terms of its n derivatives. The Taylor series can also be called a power series as each term is a power of \(x\), multiplied by a different constant

\[ f(x) = a_0x^0 +a_1x^1 +a_2x^2 +a_3x^3 +... a_nx^n \]

\(a_0, \; a_1,\dots,a_n\) are determined by the functions derivatives. For example the constant \(a_3\) is based on the function's third derivative, \(a_6\) on the sixth derivative or \(f^{(6)}x\) and so on.

It is obvious that a function with a finite number of derivatives would have a finite number of terms, as \(f(x)=x^4,\; f'(x)=4x^3, \; f''(x)=12x^2, \; f'''(x)=24x, \; f^{(4)}(x)=24\). On the other hand, infinitely differentiable functions such as exponential and trigonometric functions would be expressed as an infinite series, whose accuracy in expressing the function would be determined by the number of terms of the series used.

The proof of Taylor's Theorem involves a combination of the Fundamental Theorem of Calculus and the Mean Value Theorem, where we are integrating a function, \(f^{(n)}(x)\) to get \(f(x)\). These two theorems say:

\[\begin{align} & \text{F.T.C:}\; &\int_{a}^{x}f^{(n)}(x) \cdot \Delta x&=f^{(n-1)}(x)-f^{(n-1)}(a) \\& \text{M.V.T:}\; &\int_{a}^{x}f^{(n)}(x) \cdot \Delta x&=f^{(n)}(c)\cdot(x-a) .\end{align}\]

A quick review of the mean value theorem tells us that:

\[\int_{a}^{x} f'(x) \cdot \Delta x =f'(c)\cdot (x-a).\]

.

We therefore know:

\[ f^{(n)}(c)\cdot(x-a)=\int_{a}^{x}f^{(n)}(x)\cdot \Delta (x) = f^{(n-1)}(x)-f^{(n-1)}(a)\]

or

\[f^{(n)}(c)\cdot(x-a)=f^{(n-1)}(x)-f^{(n-1)}(a). \]

We can now integrate the function \(f=f^{(n)}(x)\) once. Integrating the left side gives us:

\[\int_{a}^{x}f^{(n)}(c)\cdot(x-a)\cdot \Delta x =f^{(n)}(c)\int_{a}^{x} (x-a)=f^{(n)}(c)\dfrac{(x-a)^2}{2} .\]

\(f^{(n)}(x)\) is just a constant, and is equal to the \(n\)th derivative evaluated at some point \(c\), between \(a\) and \(x\).

And integrating the right side:

\[\begin{align} \int_{a}^{x}f^{(n-1)}(x)\cdot \Delta x-\int_{a}^{x}f^{(n-1)}(a) \cdot \Delta x &= \left[ f^{(n-2)}(x)-f^{(n-2)}(a) \right]-f^{(n-1)}(a)\int_{a}^{x} \Delta x \\ &\text{(Remembering $f^{(n-1)}(a)$ is a constant)} \\ &=\left[f^{(n-2)}(x)-f^{(n-2)}(a)\right]-f^{(n-1)}(a)(x-a). \end{align}\]

Combining the two results gives us:

\[f^{(n)}(c)\dfrac{(x-a)^2}{2}=f^{(n-2)}(x)-f^{(n-1)}(a)(x-a).\]

If we integrate once again, third time, we get on the left side:

\[\int_{a}^{x}f^{(n)}(c) \dfrac{(x-a)^2}{2}\cdot \Delta x = f^{(n)}(c)\dfrac{(x-a)^3}{3\cdot 2 \cdot 1} \;\;\; \text{or} \;\;\; f^{(n)}(c)\dfrac{(x-a)^3}{3!}. \]

On the right side we get:

\[\int_{a}^{x}f^{(n-2)}(x) \cdot \Delta x - \int_{a}^{x}f^{(n-2)}(a)\cdot \Delta x - \int_{a}^{x} f^{(n-1)}(a)(x-a)\cdot \Delta x \\ =\left[f^{(n-3)}(x)-f^{(n-3)}(a)\right]-f^{(n-2)}(a)\int_{a}^{x}1 \cdot \Delta x - f^{(n-1)}(a)\int_{a}^{x}(x-a) \cdot \Delta x \]

Combining the two sides:

\[f^{(n)}(c)\dfrac{(x-a)^3}{3!}=\left[f^{(n-3)}(x)- f^{(n-3)}(a) \right]-f^{(n-2)}(a)(x-a)- f^{(n-1)}(a)\dfrac{(x-a)^2}{2} . \]

Integrating this entire mass a fourth time, where we started with the function \(y=f^{(n)}(x)\), gives as you may have already guessed from the pattern:

\[ f^{(n)}(c)\dfrac{(x-a)^4}{4!}=\left[f^{(n-4)}(x)- f^{(n-4)}(a) \right]-f^{(n-3)}(a)\dfrac{(x-a)}{1!}- f^{(n-2)}(a)\dfrac{(x-a)^2}{2!}- f^{(n-1)}(a)\dfrac{(x-a)^3}{3!}.\]

By now the pattern should be clear. If we integrate \(n\) successive times to eventually find \(f(x)\) we arrive at a remarkable conclusion:

\[ f^{(n)}(c)\dfrac{(x-a)^n}{n!}=f(x)-f(a)-f'(a)\dfrac{(x-a)}{1!}-f''(a)\dfrac{(x-a)^2}{2!}-f'''(a)\dfrac{(x-a)^3}{3!} \dots \dots -f^{(n-2)}\dfrac{(x-a)^{(n-2)}}{(n-2)!} -f^{(n-1)}\dfrac{(x-a)^{(n-1)}}{(n-1)!} \]

which simplifies to:

\[f(x)=\sum_{k=0}^{n-1} f^{(k)}(a)\dfrac{(x-a)^k}{k!}+f^{(n)}(c)\dfrac{(x-a)^n}{n!}. \]

What this is saying is that any function can be expressed as a series of its \((n-1)\) derivatives, each evaluated at any point, \(a\), plus its \(n\)th derivative evaluated at a point between \(a\) and \(x\). Since the terms of the series are:

\[ f(x)=f(a)+f'(a)(x-a)+f''(a)\dfrac{(x-a)^2}{2!}+f'''(a)\dfrac{(x-a)^3}{3!}+ \dots \dots + f^{(n)}(c)\dfrac{(x-a)^n}{n!} .\]

One needs to not only know the value of \(f(x)\) at \(f(a)\) but also at \(f'(a)\), \(f''(a)\), \(f'''(a)\) etc... in order to find \(f(x)\),where \(x\), is any number other than \(a\).

The last term of the Taylor series differs slightly from its preceding terms. One needs to be able to calculate \(f^{(n)}(c)\dfrac{(x-a)^n}{n!}\) for a \(c\) somewhere in between \(a\) and \(x\).

In a faintly differentiable function such as \(f(x)=\dfrac{x^4}{8}\) the \(n\)th derivative is always a constant so that \(f^{(n)}(c)\) is that particular constant regardless of \(c\) in \(f^{(n)}(c)\). For example:

\[f(x)=\dfrac{x^4}{8}, \; f'(x)=\dfrac{x^3}{2}, \; f''(x)=\dfrac{3x^2}{2}, \; f'''(x)=3x, \;f^{(4)}(x)=3.\]

In this case, \(f^{(n)}(c)=f^{(4)}(x)=3\), which will always be 3 no matter what you input in the function. Remember \(n\)th derivative refers to the last derivative of the function.

In order to write or calculate a Taylor series for \(f(x)=\dfrac{x^4}{2}\) we first need to calculate its \(n\) -derivatives, which we have already done above. The Taylor Series is defined as:

\[\begin{align} f(x)&=\sum_{k=0}^{n-1}f^{(n)}(a)\dfrac{(x-a)^n}{n!}+f^{(n)}(c)\dfrac{(x-a)^n}{n!} \\ f(x)&=f(a)+f'(a)\dfrac{(x-a)!}{2!}+\dots + f^{(4)}(c)\dfrac{(x-a)^4}{4!} \\ \dfrac{x^4}{2}&=\dfrac{a^4}{2}+2a^3(x-a)+6a^2\dfrac{(x-a^2)}{2!}+12a\dfrac{(x-a)^3}{3!}+12\dfrac{(x-a)^4}{4!} . \end{align}\]

Simplifying it we get:

\[\dfrac{x^4}{2}=\dfrac{a^4}{2}+2a^3(x-a)+3a^2(x-a)^2+2a(x-a)^3+\dfrac{(x-a)^4}{12} . \]

The easiest number to choose for \(a\) is probably 1, though you can choose whatever number you want to for \(a\), so long as its \(n\) derivatives are all defined at \(a\).

Substituting \(a\) for 1 gives:

\[f(x)=\dfrac{x^4}{2}=\dfrac{1}{2}+2(x-1)+3(x-1)^2+2(x-1)^3+\dfrac{(x-1)^4}{2}.\]

Now let us evaluate \(f(x)\) at \(x=6\) using the Taylor Series:

\[\begin{align} f(6)&=\dfrac{6^4}{2}=\dfrac{1}{2}+2(5)+3(5)^2+2(5)^3+\dfrac{(5)^4}{2} \\ &=\dfrac{6^4}{2}=0.5+10+75+250+312.5 \\ &=\dfrac{1296}{2}=648\\ &=648 \end{align}\]

The sum of the series of terms corresponds exactly; however, as you can see, writing a Taylor Series for a faintly differentiable function is not a practical thing to do. For example in this series we had to calculate in the last term \(\dfrac{(5)^4}{2}\) in order to find \(f(6)\) or \(\dfrac{(6)^4}{2}\). Now if we were able to calculate \(5^4\) with ease then would it not be much easier to find \(6^4\) directly without having to go through a series of calculations and summations?

The answer is yes and thus the life of finite Taylor Series is short-lived.

## Infinitely Differentiable Functions

The situation is a bit more complex when dealing with infinitely differentiable functions such as \(f(x)=x^{\frac{1}{2}}\) or \(3x^{-2}\). In this case one can easily go on differentiating the function as many times as you desire to create an infinite Taylor series where each term is evaluated at some point a. The problem is that no matter how many terms you use, there will always be that last term \(f^{(n)}(c)\dfrac{(x-a)^n}{n!}\) that needs to be evaluated at an unknown point \(c\), between \(a\) and \(x\). Even if we use an infinite number of terms for our Taylor series to be evaluated at some known point \(a\), how de we know that our infinite plus one, or last term \(f^{(n)}(c)\dfrac{(x-a)^n}{n!}\) does not completely throw off our answer? From the definition of Taylor Series:

\[ f(x)=\sum_{k=0}^{n-1} f^{(k)}(a)\dfrac{(x-a)^k}{k!}+f^{(n)}(c)\dfrac{(x-a)^n}{n!} \]

\(f(x)\) is expressed as a series of consecutive positive integer powers of \(x\) from \(f(a)x^0\) to \(f^{(n-1)}(a)x^{(n-1)}\). The last term is hence:

\[f^{(n)}(c)\dfrac{(x-a)^n}{n!} \;\;\; \text{or} \;\;\; c_n\dfrac{(x-a)^n}{n!}.\]

Here we have replaced the unknown constant \(f^{(n)}(c)\) with \(c_n\). In the case where \(a=0\), our last term of the Taylor series becomes:

\[c_n\dfrac{(x-0)^n}{n!} \;\;\; \text{or} \;\;\; c_n\dfrac{x^n}{n!}. \]

Taking the limit as \(n\) goes to infinity:

\[\lim_{n\rightarrow \infty} c_n \cdot \dfrac{x^n}{n!} =c_n\left( \lim_{n\rightarrow \infty} \dfrac{x^n}{n!} \right). \]

The limit in the brackets is zero as the factorial grows much faster than the exponential, remember \(x\) can take on any value but it can never be larger than infinity or \(n\).

\[\lim_{n\rightarrow \infty} c_n \cdot \dfrac{x^n}{n!}= c_n \left(\lim_{n\rightarrow \infty} \dfrac{x^n}{n!}\right) =c_n \cdot 0 =0. \]

No matter what value of \(f^{(n)}(c)\) the last term will always be zero provided an infinite number of terms are used in the series. The same is true of:

\[\lim_{n\rightarrow \infty} a_n\dfrac{(x-a)^n}{n!}=0 . \]

As \(a\) is only a constant; however, the closer \(x\) is to a the more accurate your answer will be using fewer terms. To conclude the Taylor Series for a function of \(x\) is:

\[ f(x)=\sum_{k=0}^{n-1} f^{(k)}(a)\dfrac{(x-a)^k}{k!}+f^{(n)}(c)\dfrac{(x-a)^n}{n!}. \]

Where the last term for a function of finite derivatives is some constant, independent of \(c\), multiplied by \(\dfrac{(x-a)^n}{n!}\). In a function of infinite derivatives the last term goes to zero after an infinite number of preceding terms. The closer \(x\) is to a then the few the terms needed to obtain an accurate answer Therefore Taylor Series hold true for all functions so long as one is able to evaluate its \(n\) derivatives at a point \(a\).

Let us move on to an important example of such infinitely differentiable functions such as \(f(x)=\sqrt{x}\). This is an infinitely differentiable function and as we shall see the infinite Taylor series provides an important way of relating square roots of a number through a series of terms than can be easily evaluated. The answer can be obtained from the Binomial expansion, but let us use Taylor series to show the relation between the binomial theorem and Taylor series.

We will first use eight terms by differentiating the function seven times:

\[ \begin{align} &f(x)=\sqrt{x}, &f'(x)=\dfrac{1}{2\sqrt{2}}, &&f''(x)=-\dfrac{1}{4^2\sqrt{x}^3}, &&f'''(x)= \dfrac{3}{8x^{\frac{5}{2}}} \\ &f^{(4)}(x)=-\dfrac{15}{16x^{\frac{7}{2}}}, &f^{(5)}(x)=-\dfrac{105}{32x^{\frac{9}{2}}}, &&f^{(6)}(x)=-\dfrac{945}{64x^{\frac{11}{2}}}, &&f^{(7)}(x)=\dfrac{10395}{128x^{\frac{13}{2}}}. \end{align}\]

Now writing the Taylor Series:

\[\begin{align} f(x)=\sqrt{x}&=a^{\frac{1}{2}}+\dfrac{1}{2a^{\frac{1}{2}}}(x-a)-\dfrac{1}{4a^{\frac{3}{2}}}\dfrac{(x-a)^2}{2!}+ \dfrac{3}{8a^{\frac{5}{2}}}\dfrac{(x-a)^3}{3!} - \dfrac{15}{16a^{\frac{7}{2}}}\dfrac{(x-a)^4}{4!} \\&+ \dfrac{105}{32a^{\frac{9}{2}}}\dfrac{(x-a)^5}{5!} - \dfrac{945}{64a^{\frac{11}{2}}}\dfrac{(x-a)^6}{6!} + \dfrac{10395}{128a^{\frac{13}{2}}}\dfrac{(x-a)^7}{7!}+\dots. \end{align}\]

Since we can evaluate each of the \(n\)-derivatives at \(x=1\), then we will let \(a=1\), which simplifies the series to:

\[ \begin{align}f(x)=\sqrt{x}&=1+\dfrac{1}{2}(x-1)-\dfrac{1}{8}(x-1)^2+\dfrac{1}{16}(x-1)^3-\dfrac{5}{128}(x-1)^4\\ &+\dfrac{7}{256}(x-1)^5-\dfrac{21}{1024}(x-1)^6+\dfrac{231}{14336}(x-1)^7+\dots . \end{align} \]

Take note of how the fraction preceding each term gets smaller and smaller. This is a check, that tells us that the last terms get closer and closer to zero, and hence the Taylor series will be defined for all \(x\).

\[\sqrt{x}\approx 1+\dfrac{(x-1)}{2}-\dfrac{(x-1)^2}{8}+\dfrac{(x-1)^3}{16}-\dfrac{5(x-1)^4}{128}+\dfrac{7(x-1)^5}{256}-\dfrac{21(x-1)^6}{1024}+\dfrac{231(x-1)^7}{14336} \]

Let us use this series to find the square root of 2 or \(\sqrt{2}\).

\[\sqrt{x}\approx 1+\dfrac{(1)}{2}-\dfrac{(1)^2}{8}+\dfrac{(1)^3}{16}-\dfrac{5(1)^4}{128}+\dfrac{7(1)^5}{256}-\dfrac{21(1)^6}{1024}+\dfrac{231(1)^7}{14336} \]

\[\sqrt{x}\approx 1+\dfrac{1}{2}-\dfrac{1}{8}+\dfrac{1}{16}-\dfrac{5}{128}+\dfrac{7}{256}-\dfrac{21}{1024}+\dfrac{231}{14336} \]

After a few simple calculations we arrive at:

\[\sqrt{2}\approx 1.421386719. \]

From the calculator the square root of two is:

\[1.414213562.\]

Therefore using eight terms we found the square root of two to an error of only .50% or half a percent. Had we used more terms the error would have been even less. With an infinite amount of terms the error would be zero or next to nothing.

## Contributors

- Faraz Hussain, Copied in whole or part from UnderstandingCalculus.com

Integrated by Justin Marshall.