Taylor and Maclaurin Series: Exercises and Solutions
Taylor series representation of a function
Notation:
$$f^{(n)}(x) = \frac{d^n f}{dx^n}(x)$$
Taylor series for \( f(x) \) about the point \( x_0 \):
$$f(x) = \sum_{n=0}^{\infty} \frac{(x - x_0)^n}{n!} f^{(n)}(x_0)$$
$$f(x) = f(x_0) + (x - x_0)\frac{df}{dx}(x_0) + \frac{(x - x_0)^2}{2}\frac{d^2 f}{dx^2}(x_0) + \frac{(x - x_0)^3}{3!}\frac{d^3 f}{dx^3}(x_0) + \dots$$
Maclaurin series (special case where \( x_0 = 0 \)):
$$f(x) = f(0) + x\frac{df}{dx}(0) + \frac{x^2}{2}\frac{d^2 f}{dx^2}(0) + \frac{x^3}{3!}\frac{d^3 f}{dx^3}(0) + \dots$$
Taylor series: interpretation
$$f(x_0 + \Delta x) \approx f(x_0) + \Delta x \, f^{(1)}(x_0) + \frac{1}{2}\Delta x^2 \, f^{(2)}(x_0) + \frac{1}{3!}\Delta x^3 \, f^{(3)}(x_0) + \dots$$
Finding the Maclaurin series for the exponential function
Function:
$$f(x) = e^x$$
Series:
$$f(x) = \sum_{n=0}^{\infty} \frac{x^n f^{(n)}(0)}{n!}$$
Table of Terms:
| n | \( f^{(n)}(x) \) | \( f^{(n)}(0) \) | \( \frac{x^n}{n!} \) |
|---|---|---|---|
| 0 | \( e^x \) | 1 | 1 |
| 1 | \( e^x \) | 1 | x |
| 2 | \( e^x \) | 1 | \( \frac{x^2}{2} \) |
| 3 | \( e^x \) | 1 | \( \frac{x^3}{3!} \) |
| ... | ... | ... | ... |
Put the terms together:
$$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{3!} + \dots$$
Visualising partial sums of Maclaurin series
$$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{3!} + \dots$$
Approximating a function using partial sums
Function:
$$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{3!} + \dots$$
Partial sum:
$$S_N(x) = \sum_{n=0}^{N} \frac{x^n f^{(n)}(x)}{n!}$$
Choose x=0.5 (for illustration)
Convergence of the Maclaurin series for the exponential function
$$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{3!} + \dots$$
Choose x=0.5
Matlab code:
x = .5;
for N=0:15
ss=0;
for n=0:N
ss = ss +
x.^n./factorial(n);
end
fprintf('%d, %f, %f,%e\n',N,ss,exp(x),exp(x)-ss)
end
| N | \( S_N \) | \( \exp(x) \) | \( \exp(x) - S_N \) |
|---|---|---|---|
| 0 | 1 | 1.648721 | 6.49E-01 |
| 1 | 1.5 | 1.648721 | 1.49E-01 |
| 2 | 1.625 | 1.648721 | 2.37E-02 |
| 3 | 1.645833 | 1.648721 | 2.89E-03 |
| 4 | 1.648438 | 1.648721 | 2.84E-04 |
| 5 | 1.648698 | 1.648721 | 2.34E-05 |
| 6 | 1.64872 | 1.648721 | 1.65E-06 |
| 7 | 1.648721 | 1.648721 | 1.03E-07 |
| 8 | 1.648721 | 1.648721 | 5.66E-09 |
| 9 | 1.648721 | 1.648721 | 2.82E-10 |
| 10 | 1.648721 | 1.648721 | 1.28E-11 |
| 11 | 1.648721 | 1.648721 | 5.30E-13 |
| 12 | 1.648721 | 1.648721 | 2.07E-14 |
| 13 | 1.648721 | 1.648721 | 1.11E-15 |
| 14 | 1.648721 | 1.648721 | 4.44E-16 |
| 15 | 1.648721 | 1.648721 | 4.44E-16 |
Approximation error
$$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{3!} + \dots$$
Truncation error:
$$E_N(x) = \lvert f(x) - S_N(x) \rvert$$
Truncation error from S15
$$E_{15}(0.5) \sim 10^{-16}$$
Examples of other Taylor series
$$\sin x = \sum_{n=0}^{\infty} (-1)^n \frac{x^{2n+1}}{(2n+1)!}$$
$$\cos x = \sum_{n=0}^{\infty} (-1)^n \frac{x^{2n}}{(2n)!}$$
$$\ln(1+x) = \sum_{n=1}^{\infty} (-1)^{n+1} \frac{x^n}{n}$$
$$\frac{1}{1-x} = \sum_{n=0}^{\infty} x^n$$
Solution of practice problems
Determine the Maclaurin series for cos(x)
Determine the Maclaurin series for ln(1+x)
Calculate the Taylor expansion of cos(x) around the point x0 = ℼ/2
The Taylor formula is
$$f(x) = \sum_{n=0}^{\infty} \frac{(x - \pi/2)^n}{n!} f^{(n)}\!\left(\frac{\pi}{2}\right)$$
View the solution
Use the Maclaurin series for ln((1+x) to calculate the limit limx→0 ln(1 + x)⁄x
View the solution4√17
View the solution3√26
View the solution