Series

Taylor and Maclaurin Series: Formula and Examples

Taylor and Maclaurin Series: Formula and Examples — CalculusCalc cover image

A Taylor series rewrites a smooth function as an infinite polynomial built from its derivatives at one point \( a \):

$$\begin{aligned} f(x) &= \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 \end{aligned}$$

When \( a = 0 \), it’s called a Maclaurin series. Stopping after the degree \( n \) term gives the Taylor polynomial \( P_n(x) \), a finite approximation you can actually compute.

This guide explains where the formula comes from, builds several series step by step, shows how to measure the error, and covers the mistakes students make most often.

Why it works

A polynomial \( P(x) = c_0 + c_1(x-a) + c_2(x-a)^2 + \dots \) matches \( f \) as closely as possible at \( a \) if every derivative matches. Differentiating \( k \) times and setting \( x = a \) gives \( P^{(k)}(a) = k!\,c_k \), so \( c_k = \frac{f^{(k)}(a)}{k!} \). The first two terms are just the tangent line; each extra term also matches the curve’s bending.

Picture it on a graph. The degree 1 polynomial is a straight line that touches the curve at \( a \). Degree 2 is a parabola that also bends the same way. Degree 3 matches how the bending changes, and so on. Each new term keeps the curve and the polynomial glued together over a wider stretch around \( a \).

The \( n! \) in the denominator is not decoration. Differentiating \( (x-a)^n \) a total of \( n \) times produces the factor \( n! \), and dividing by it cancels that growth so the coefficient comes out right.

How to build a Taylor polynomial

  1. Choose the center \( a \) and the degree \( n \).
  2. Compute \( f, f', f'', \dots, f^{(n)} \).
  3. Evaluate each at \( x = a \).
  4. Divide the \( k \)th value by \( k! \) and attach \( (x-a)^k \).
  5. Add the terms. A table with columns for \( k \), \( f^{(k)}(a) \) and the coefficient keeps things organized.

Example 1: Maclaurin series of eˣ

Every derivative of \( e^x \) is \( e^x \), and \( e^0 = 1 \). So every coefficient is \( \frac{1}{n!} \):

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

At \( x = 1 \), the terms through degree 5 give \( 1 + 1 + \frac12 + \frac16 + \frac1{24} + \frac1{120} \approx 2.71667 \), already close to \( e \approx 2.71828 \). This is one of the fastest ways to compute \( e \).

Example 2: Maclaurin series of cos x

Derivatives of \( \cos x \) cycle: \( \cos, -\sin, -\cos, \sin, \cos, \dots \). At 0 they are \( 1, 0, -1, 0, 1, \dots \). So

$$\begin{aligned} \cos x &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots \\ &= \sum_{n=0}^\infty\frac{(-1)^nx^{2n}}{(2n)!} \end{aligned}$$

Check at \( x = 0.5 \): \( P_4(0.5) = 1 - 0.125 + 0.0026042 = 0.8776042 \), while \( \cos 0.5 = 0.8775826 \). Three nonzero terms, error 0.00002.

The same cycling for \( \sin x \) gives \( x - \frac{x^3}{6} + \frac{x^5}{120} - \cdots \). At \( x = 0.1 \) those three terms give 0.0998334167, matching \( \sin 0.1 \) to about ten decimal places.

Common Maclaurin series

Function Series Converges for
\( e^x \) \( \sum\frac{x^n}{n!} = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \cdots \) all \( x \)
\( \sin x \) \( x - \frac{x^3}{6} + \frac{x^5}{120} - \cdots \) all \( x \)
\( \cos x \) \( 1 - \frac{x^2}{2} + \frac{x^4}{24} - \cdots \) all \( x \)
\( \frac{1}{1-x} \) \( 1 + x + x^2 + x^3 + \cdots \) \( \lvert x\rvert < 1 \)
\( \ln(1+x) \) \( x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots \) \( -1 < x \le 1 \)
\( \arctan x \) \( x - \frac{x^3}{3} + \frac{x^5}{5} - \cdots \) \( \lvert x\rvert \le 1 \)

The \( \frac{1}{1-x} \) row is the geometric series.

Building new series from old ones

You rarely need to differentiate from scratch:

  • Substitute: \( e^{-x^2} = 1 - x^2 + \frac{x^4}{2} - \cdots \) (replace \( x \) by \( -x^2 \) in \( e^x \)).
  • Multiply: \( x\sin x = x^2 - \frac{x^4}{6} + \cdots \)
  • Integrate: integrating \( \frac{1}{1+x^2} = 1 - x^2 + x^4 - \cdots \) term by term gives the \( \arctan x \) series.

Example 3: a Taylor series not centered at 0

\( \ln x \) around \( a = 1 \): the derivatives at 1 are \( 0, 1, -1, 2, -6, \dots \), giving

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

You can’t center \( \ln x \) at 0 because \( \ln 0 \) is undefined, which is why \( a = 1 \) is the natural choice.

Example 4: estimating √4.2 by hand

Center at \( a = 4 \), where the square root is easy. With \( f(x) = \sqrt{x} \):

  • \( f(4) = 2 \)
  • \( f'(x) = \frac{1}{2\sqrt x} \), so \( f'(4) = \frac14 \)
  • \( f''(x) = -\frac{1}{4x^{3/2}} \), so \( f''(4) = -\frac{1}{32} \), and the coefficient is \( -\frac{1}{64} \)

$$P_2(x) = 2 + \frac{x - 4}{4} - \frac{(x-4)^2}{64}$$

At \( x = 4.2 \), \( P_2 = 2 + 0.05 - 0.000625 = 2.049375 \). The true value is 2.0493902, so the error is about 0.000015.

How accurate is a Taylor polynomial?

Lagrange error bound: the error of the degree-\( n \) polynomial is at most

$$|R_n(x)| \le \frac{M}{(n+1)!}|x - a|^{n+1}$$

where \( M \) bounds \( |f^{(n+1)}| \) between \( a \) and \( x \). For \( \cos 0.5 \) with \( n = 4 \) (really up to degree 5, since the \( x^5 \) coefficient is zero) the bound is \( \frac{0.5^6}{720} \approx 0.0000217 \), and the true error (about 0.0000216) is just under it.

For Example 4, \( f'''(x) = \frac{3}{8x^{5/2}} \) is largest at \( x = 4 \), where it equals \( \frac{3}{256} \). The bound is \( \frac{3/256}{6}(0.2)^3 \approx 0.0000156 \), just above the true error.

Example 5 (exam-level): an integral with no elementary antiderivative

Estimate \( \int_0^1 e^{-x^2}\,dx \). Integrate the substituted series term by term:

$$\begin{aligned} \int_0^1 e^{-x^2}dx &= \int_0^1\left(1 - x^2 + \frac{x^4}{2} - \frac{x^6}{6} + \frac{x^8}{24} - \cdots\right)dx \\ &= 1 - \frac13 + \frac1{10} - \frac1{42} + \frac1{216} - \cdots \end{aligned}$$

Five terms give about 0.747487. The true value is 0.746824. Because the series alternates with shrinking terms, the error is below the next term, \( \frac{1}{1320} \approx 0.00076 \). This is how the Gaussian integral and the normal distribution are computed in practice.

Common mistakes

  • Forgetting the factorial. The coefficient is \( \frac{f^{(n)}(a)}{n!} \), not \( f^{(n)}(a) \). Without it, the \( x^2 \) term of \( \cos x \) would be \( -x^2 \) instead of \( -\frac{x^2}{2} \).
  • Writing \( x^n \) when \( a \ne 0 \). Centered at 4, the powers are \( (x - 4)^n \). Using \( x^n \) silently changes the center.
  • Confusing degree with number of terms. \( P_4 \) for \( \cos x \) has only three nonzero terms, because the odd coefficients are zero.
  • Using a series outside its interval. The \( \ln(1+x) \) series diverges at \( x = 2 \), so it cannot compute \( \ln 3 \) directly, no matter how many terms you add.
  • Dropping alternating signs. Derivatives of sine and cosine cycle through negatives. Write the table of values before writing the series.

Uses

  • Calculators and computers evaluate \( \sin \), \( e^x \) and \( \ln \) this way.
  • Limits: \( \frac{\sin x - x}{x^3} \to -\frac16 \) instantly from the series, often faster than L’Hôpital’s rule. Likewise \( \frac{e^x - 1 - x}{x^2} \to \frac12 \).
  • Integrals with no antiderivative, like Example 5.
  • Physics approximations such as \( \sin\theta \approx \theta \), which makes a pendulum’s small swings nearly regular. It is the same fact as the limit of sin x over x equaling 1.

Where a Taylor series stops working

Every Taylor series has a radius of convergence \( R \): it converges for \( |x - a| < R \) and diverges for \( |x - a| > R \). For \( e^x \), \( \sin x \) and \( \cos x \), \( R \) is infinite. For \( \frac{1}{1-x} \), \( R = 1 \), because the function blows up at \( x = 1 \) and the series cannot see past that point.

A useful rule of thumb: the radius is often the distance from the center to the nearest point where the function misbehaves. For \( \ln x \) centered at 1, that point is 0, so \( R = 1 \) and the series works for \( 0 < x \le 2 \). To find \( R \) formally, apply the ratio test to the series with \( x \) left in.

Taylor polynomial calculator

Choose \( f \), the center \( a \) and the degree \( n \). The gadget computes exact coefficients and tests the polynomial at a point. The full Taylor series calculator page has more room for longer polynomials.

Series & Limits#19

Taylor Polynomial Generator

Degree-\(n\) Taylor/Maclaurin polynomial centered at \(a\), with error check.

Practice problems

Try these before checking the answers.

  1. Maclaurin series of \( e^{2x} \) up to \( x^3 \)
  2. Maclaurin series of \( x\cos x \) up to \( x^5 \)
  3. \( \lim_{x\to0}\frac{\sin x - x}{x^3} \) using series
  4. Degree 2 Taylor polynomial of \( \frac1x \) at \( a = 1 \)
  5. Estimate \( e^{0.1} \) with three terms of the Maclaurin series
  6. The interval of convergence of the Maclaurin series of \( \frac{1}{1+x^2} \)

Answers: (1) \( 1 + 2x + 2x^2 + \frac43x^3 \); (2) \( x - \frac{x^3}{2} + \frac{x^5}{24} \); (3) \( -\frac16 \); (4) \( 1 - (x-1) + (x-1)^2 \), since the derivatives at 1 are \( 1, -1, 2 \); (5) \( 1.105 \), versus the true 1.10517; (6) \( -1 < x < 1 \).

FAQ

What’s the difference between Taylor and Maclaurin series?

A Maclaurin series is a Taylor series centered at \( a = 0 \).

Does every function equal its Taylor series?

No. The series may converge only on an interval (like \( \ln(1+x) \)), and a few smooth functions don’t match their series at all. For \( e^x \), \( \sin x \) and \( \cos x \) it works everywhere. The ratio test finds the radius of convergence.

What’s the difference between a Taylor polynomial and a Taylor series?

The polynomial stops at a chosen degree and is an approximation. The series continues forever and, inside its interval of convergence, equals the function exactly.

How many terms do I need?

Use the Lagrange error bound: increase \( n \) until the bound is smaller than the accuracy you need. Points close to the center need far fewer terms than points far away.

Why choose a center other than 0?

A center near the point you care about makes \( |x - a| \) small, so the terms shrink quickly. It is also required when the function or its derivatives are undefined at 0, as with \( \ln x \) and \( \sqrt x \).

Further reading

Calculators for this topic

Leave a comment

Your email address will not be published. Required fields are marked *