Taylor and Maclaurin Series with Examples

Calculus Tutorial: Polynomial Approximations and Power Series Expansions

The use of Taylor and Maclaurin series to expand and approximate functions as a power series at given values of \( x \) is presented. These series provide useful polynomial approximations of generating functions which are easier to program on calculators. Examples, questions, and their solutions are included.

In what follows, \( C \) represents the constant of integration where applicable.

Definition of Taylor and Maclaurin Series

For a function \( f \) with derivatives of all orders defined in an interval containing \( a \), the Taylor series of function \( f \) at \( x = a \) is given by [1]:

\[ \sum_{k=0}^{\infty} \frac{f^{(k)}(a)}{k!} (x-a)^k = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \dots + \frac{f^{(n)}(a)}{n!}(x-a)^n + \dots \]

where \( f'(a), f''(a), \dots, f^{(n)}(a), \dots \) are the derivatives of \( f \) evaluated at \( x = a \).

The Maclaurin series of function \( f \) is the Taylor series centered at \( x = 0 \) and is given by:

\[ \sum_{k=0}^{\infty} \frac{f^{(k)}(0)}{k!} x^k = f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \dots + \frac{f^{(n)}(0)}{n!}x^n + \dots \]

Taylor and Maclaurin series are infinite, but they may be truncated to \( n \) terms to yield a Taylor polynomial given by:

\[ P_n(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \dots + \frac{f^{(n)}(a)}{n!}(x-a)^n \]

An Online Taylor Series Calculator is available and may be used to check many of the examples and exercises presented below as well as generate new problems.

Examples of Taylor and Maclaurin Series Expansion

Example 1

a) Find the Taylor polynomial \( P_4(x) \) (of order 4) generated by \( f(x) = \sin(x) \) at \( x = \pi/2 \).
b) Graph \( \sin(x) \) and \( P_4(x) \) in an interval containing \( \pi/2 \) and compare the two graphs.

Show Solution to Example 1

a) The Taylor polynomial of order 4 is given by:

\[ P_4(x) = f(\pi/2) + f'(\pi/2)(x-\pi/2) + \frac{f''(\pi/2)}{2!}(x-\pi/2)^2 + \frac{f^{(3)}(\pi/2)}{3!}(x-\pi/2)^3 + \frac{f^{(4)}(\pi/2)}{4!}(x-\pi/2)^4 \]

Calculating the first 4 derivatives of \( f(x) = \sin(x) \):

  • \( f(x) = \sin(x) \implies f(\pi/2) = 1 \)
  • \( f'(x) = \cos(x) \implies f'(\pi/2) = 0 \)
  • \( f''(x) = -\sin(x) \implies f''(\pi/2) = -1 \)
  • \( f^{(3)}(x) = -\cos(x) \implies f^{(3)}(\pi/2) = 0 \)
  • \( f^{(4)}(x) = \sin(x) \implies f^{(4)}(\pi/2) = 1 \)

Substituting into \( P_4(x) \):

\[ P_4(x) = 1 + 0 - \frac{1}{2}(x-\pi/2)^2 + 0 + \frac{1}{24}(x-\pi/2)^4 = 1 - \frac{1}{2}(x-\pi/2)^2 + \frac{1}{24}(x-\pi/2)^4 \]

b) Comparing the graphs of \( \sin(x) \) and its Taylor polynomial of order 4, the two curves match closely near \( x = \pi/2 \), confirming that \( P_4(x) \) provides an accurate local approximation.

Graphs comparing sin(x) and its Taylor expansion example 1
Figure 1. Comparison of \( \sin(x) \) and \( P_4(x) \)

Example 2

a) Find the Taylor polynomial \( P_5(x) \) (of order 5) generated by \( f(x) = \ln(x) \) at \( x = 1 \).
b) Graph \( \ln(x) \) and \( P_5(x) \) in an interval containing \( 1 \) and compare the two graphs.
c) Evaluate \( P_5(x) \) and \( \ln(x) \) in the table below and compare the corresponding values.

\( P_5(x) \)\( \ln(x) \)
\( P_5(1.01) \)\( \ln(1.01) \)
\( P_5(0.99) \)\( \ln(0.99) \)
\( P_5(1.1) \)\( \ln(1.1) \)
\( P_5(0.9) \)\( \ln(0.9) \)
\( P_5(1.5) \)\( \ln(1.5) \)
\( P_5(0.5) \)\( \ln(0.5) \)
\( P_5(1.8) \)\( \ln(1.8) \)
\( P_5(0.2) \)\( \ln(0.2) \)
Show Solution to Example 2

a) The Taylor polynomial of order 5 at \( x = 1 \) is:

\[ P_5(x) = f(1) + f'(1)(x-1) + \frac{f''(1)}{2!}(x-1)^2 + \frac{f^{(3)}(1)}{3!}(x-1)^3 + \frac{f^{(4)}(1)}{4!}(x-1)^4 + \frac{f^{(5)}(1)}{5!}(x-1)^5 \]

Calculating the first 5 derivatives of \( f(x) = \ln(x) \):

  • \( f(x) = \ln(x) \implies f(1) = 0 \)
  • \( f'(x) = \frac{1}{x} \implies f'(1) = 1 \)
  • \( f''(x) = -\frac{1}{x^2} \implies f''(1) = -1 \)
  • \( f^{(3)}(x) = \frac{2}{x^3} \implies f^{(3)}(1) = 2 \)
  • \( f^{(4)}(x) = -\frac{6}{x^4} \implies f^{(4)}(1) = -6 \)
  • \( f^{(5)}(x) = \frac{24}{x^5} \implies f^{(5)}(1) = 24 \)

Substituting into \( P_5(x) \) and simplifying:

\[ P_5(x) = (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 - \frac{1}{4}(x-1)^4 + \frac{1}{5}(x-1)^5 = \frac{1}{5}x^5 - \frac{5}{4}x^4 + \frac{10}{3}x^3 - 5x^2 + 5x - \frac{137}{60} \]

b) The graphs show that \( P_5(x) \) approximates \( \ln(x) \) well near \( x = 1 \).

Graphs comparing ln(x) and its Taylor expansion example 2
Figure 2. Comparison of \( \ln(x) \) and \( P_5(x) \)

c) Evaluation table comparison:

Approximate \( P_5(x) \)Exact \( \ln(x) \)
\( P_5(1.01) = 0.00995 \)\( \ln(1.01) = 0.00995 \)
\( P_5(0.99) = -0.01005 \)\( \ln(0.99) = -0.01005 \)
\( P_5(1.1) = 0.09531 \)\( \ln(1.1) = 0.09531 \)
\( P_5(0.9) = -0.10536 \)\( \ln(0.9) = -0.10536 \)
\( P_5(1.5) = 0.40729 \)\( \ln(1.5) = 0.40546 \)
\( P_5(0.5) = -0.68854 \)\( \ln(0.5) = -0.69314 \)
\( P_5(1.8) = 0.61380 \)\( \ln(1.8) = 0.58778 \)
\( P_5(0.2) = -1.45860 \)\( \ln(0.2) = -1.60943 \)

The polynomial \( P_5(x) \) provides an excellent approximation for values close to \( x = 1 \).

Example 3

a) Find the Maclaurin series generated by \( f(x) = e^x \).
b) Graph the Maclaurin series in an interval containing \( 0 \) with 2, 3, 4, 5, and 6 terms.

Show Solution to Example 3

a) The Maclaurin series is given by:

\[ \sum_{k=0}^{\infty} \frac{f^{(k)}(0)}{k!} x^k = f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \dots + \frac{f^{(n)}(0)}{n!}x^n + \dots \]

Since all derivatives of \( f(x) = e^x \) evaluated at \( x = 0 \) equal \( 1 \):

\[ 1 + x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3 + \dots + \frac{1}{n!}x^n + \dots = \sum_{n=0}^{\infty} \frac{x^n}{n!} \]

b) Polynomials of different orders:

  • \( P_1(x) = 1 + x \)
  • \( P_2(x) = 1 + x + \frac{1}{2}x^2 \)
  • \( P_3(x) = 1 + x + \frac{1}{2}x^2 + \frac{1}{6}x^3 \)
  • \( P_4(x) = 1 + x + \frac{1}{2!}x^2 + \frac{1}{6}x^3 + \frac{1}{24}x^4 \)
  • \( P_5(x) = 1 + x + \frac{1}{2!}x^2 + \frac{1}{6}x^3 + \frac{1}{24}x^4 + \frac{1}{120}x^5 \)
Graphs of Maclaurin series of different orders and function e^x
Figure 3. Graphs of Maclaurin polynomials of various orders for \( e^x \)

Questions

Part A

Find the Taylor polynomial of order 4 generated by \( f \) at the given value of \( x \):

  1. \( f(x) = e^{-x} \), at \( x = 2 \)
  2. \( f(x) = \sin(x/2) \), at \( x = \pi \)

Part B

Find the Maclaurin series for the functions:

  1. \( f(x) = \cos(x + \pi/2) \)
  2. \( f(x) = e^x + e^{-x} \)
  3. \( f(x) = e^{-x^2} \)
  4. \( f(x) = \sin(x) \)
  5. \( f(x) = e^x - e^{-x} \)

Part C

Find the Taylor polynomial of order 5 generated by \( f(x) = \sin(x)e^x \) at \( x = 0 \) and graph \( f \) and the Taylor polynomial in the same coordinate system.

Solutions to the Above Questions

Part A

  1. \( f(x) = e^{-x} \implies f'(x) = -e^{-x}, \, f''(x) = e^{-x}, \, f^{(3)}(x) = -e^{-x}, \, f^{(4)}(x) = e^{-x} \). At \( x = 2 \):
    \[ P_4(x) = \frac{1}{e^2} - \frac{1}{e^2}(x-2) + \frac{1}{2e^2}(x-2)^2 - \frac{1}{6e^2}(x-2)^3 + \frac{1}{24e^2}(x-2)^4 \] \[ = \frac{x^4}{24e^2} - \frac{x^3}{2e^2} + \frac{5x^2}{2e^2} - \frac{19x}{3e^2} + \frac{7}{e^2} \]
  2. \( f(x) = \sin(x/2) \implies f'(x) = \frac{1}{2}\cos(x/2), \, f''(x) = -\frac{1}{4}\sin(x/2), \, f^{(3)}(x) = -\frac{1}{8}\cos(x/2), \, f^{(4)}(x) = \frac{1}{16}\sin(x/2) \). At \( x = \pi \):
    \[ P_4(x) = 1 - \frac{1}{8}(x-\pi)^2 + \frac{1}{384}(x-\pi)^4 \] \[ = \frac{x^4}{384} - \frac{\pi x^3}{96} - \frac{x^2}{8} + \frac{\pi^2 x^2}{64} + \frac{\pi x}{4} - \frac{\pi^3 x}{96} - \frac{48\pi^2 + \pi^4 + 384}{384} \]

Part B

  1. \( f(x) = \cos(x+\pi/2) = -\sin(x) \implies -x + \frac{1}{6}x^3 - \frac{1}{120}x^5 + \frac{1}{5040}x^7 - \frac{1}{362880}x^9 + \dots \)
  2. \( f(x) = e^x + e^{-x} \implies 2 + x^2 + \frac{1}{12}x^4 + \frac{1}{360}x^6 + \frac{1}{20160}x^8 + \dots \)
  3. \( f(x) = e^{-x^2} \implies 1 - x^2 + \frac{1}{2}x^4 - \frac{1}{6}x^6 + \frac{1}{24}x^8 + \dots \)
  4. \( f(x) = \sin(x) \implies x - \frac{1}{6}x^3 + \frac{1}{120}x^5 - \frac{1}{5040}x^7 + \frac{1}{362880}x^9 + \dots \)
  5. \( f(x) = e^x - e^{-x} \implies 2x + \frac{1}{3}x^3 + \frac{1}{60}x^5 + \frac{1}{2520}x^7 + \frac{1}{181440}x^9 + \dots \)

Part C

For \( f(x) = \sin(x)e^x \) at \( x = 0 \):

\[ P_5(x) = x + x^2 + \frac{1}{3}x^3 - \frac{1}{30}x^5 \]
Graphs of Taylor polynomial P_5(x) and function sin(x)e^x
Figure 4. Comparison of \( \sin(x)e^x \) and its Taylor polynomial \( P_5(x) \)

More References and Links

  1. University Calculus - Early Transcendental - Joel Hass, Maurice D. Weir, George B. Thomas, Jr., Christopher Heil - ISBN-13: 978-0134995540
  2. Calculus - Gilbert Strang - MIT - ISBN-13: 978-0961408824
  3. Calculus - Early Transcendental - James Stewart - ISBN-13: 978-0-495-01166-8
  4. Online Taylor Series Calculator
  5. Introduction to Polynomials
  6. Fourier Series Tutorial
  7. AnalyzeMath Home Page