Taylor and Maclaurin Series

Theory

The Taylor series of a function ff about x=ax=a is

n=0f(n)(a)n!(xa)n=f(a)+f(a)(xa)+f(a)2!(xa)2+\sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \cdots

The nn-th Taylor polynomial Pn(x)P_n(x) is the partial sum of the first n+1n+1 terms of the Taylor series and is used to approximate f(x)f(x) near x=ax=a.

If a=0a=0, the Taylor series is called a Maclaurin series.

Because Taylor polynomials are finite truncations of an infinite series, approximations involve a truncation error, which decreases as nn increases.

Exercises

Exercise 1
Question

Find the Maclaurin polynomial for f(x)=exf(x)=e^x.

Show solution ↓
Solution

For f(x)=exf(x)=e^x,

f(n)(x)=exf(n)(0)=1 for all n.f^{(n)}(x)=e^x \quad \Rightarrow \quad f^{(n)}(0)=1 \text{ for all } n.

Thus, the Maclaurin polynomial is

Pn(x)=1+x+x22!+x33!++xnn!.P_n(x)=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots+\frac{x^n}{n!}.
Exercise 2
Question

Find the 3rd Taylor polynomial of f(x)=sinxf(x)=\sin x about x=π3x=\frac{\pi}{3}.

Show solution ↓
Solution

Compute derivatives:

f(x)=sinx,f(x)=cosx,f(x)=sinx,f(x)=cosx.f(x)=\sin x, \quad f'(x)=\cos x, \quad f''(x)=-\sin x, \quad f'''(x)=-\cos x.

Evaluate at x=π3x=\frac{\pi}{3}:

sinπ3=32,cosπ3=12.\sin\frac{\pi}{3}=\frac{\sqrt{3}}{2}, \quad \cos\frac{\pi}{3}=\frac{1}{2}.

The 3rd Taylor polynomial is

P3(x)=  f(a)+f(a)(xa)+f(a)2!(xa)2+f(a)3!(xa)3=  32+12 ⁣(xπ3)34 ⁣(xπ3)2112 ⁣(xπ3)3.\begin{aligned} P_3(x) =\;& f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \frac{f'''(a)}{3!}(x-a)^3 \\[4pt] =\;& \frac{\sqrt{3}}{2} + \frac{1}{2}\!\left(x-\frac{\pi}{3}\right) - \frac{\sqrt{3}}{4}\!\left(x-\frac{\pi}{3}\right)^2 - \frac{1}{12}\!\left(x-\frac{\pi}{3}\right)^3. \end{aligned}