What is the Taylor series?

A Taylor series is a mathematical representation of a function as an infinite sum of terms, where each term is calculated based on the function’s derivatives at a specific point. It is a powerful tool in calculus and analysis that allows us to approximate complex functions with simpler polynomial functions.

Introduction

Given f(x)f(x), smooth function, if we expand it at point x=cx = c:

Note: A smooth function means that the function is continuous, and its derivatives (including the first derivative, second derivative, and so on) exist and are continuous over the entire interval.

In this series, f(c)f(c) represents the value of the function at the point cc, f(c)f'(c) represents the first derivative of the function at cc, f(c)f''(c) represents the second derivative, and so on. The terms (xa)n(x−a)^n are the powers of (xa)(x−a) raised to increase positive integer values.

The general formula for the nthnth term in the Taylor series is:

Where f(n)(a)f^{(n)}(a) represents the nthnth derivative of f(x)f(x) evaluated at aa.

If we use the summation sign, the function looks like the following:

This is called the Taylor series of f at the point c.

A special case, when c=0c = 0, is called the Maclaurin series.

The Maclaurin series is used when dealing with functions that can be more easily expressed as infinite series centered around the origin. It’s a special case of the Taylor series that simplifies calculations by focusing on the behavior of the function near x=0x=0:

If we use the summation sign, the function looks like the following:

Examples

The sin(x)sin(x) and cos(x)cos(x) functions are closely linked through their Taylor series expansions. The derivative of sin(x)sin(x) is cos(x)cos(x) , while the derivative of cos(x)cos(x) is sin(x)-sin(x), reflecting their alternating patterns of odd and even powers in their Taylor series.

Use of the Taylor series in computers

Computers extensively utilize the Taylor series for mathematical calculations, particularly when approximating transcendental functions like the exponential function exe^x.

For instance, if you wish to compute ee to 6-digit accuracy, a computer can employ a finite number of terms from the Taylor series expansion:

12!=0.5\frac{1}{2!} = 0.5

13!=0.166667\frac{1}{3!} = 0.166667

14!=0.041667\frac{1}{4!} = 0.041667

· · ·

19!=0.0000027\frac{1}{9!}= 0.0000027 (can stop here)

Summing up, we have:

e1+1+12!+13!+14!+15!+19!=2.71828e ≈ 1 + 1 +\frac{1}{2!} +\frac{1}{3!} +\frac{1}{4!} +\frac{1}{5!} + · · ·\frac{1}{9!} = 2.71828

The number of terms can be adjusted to attain the desired level of accuracy. As more terms are added, the accuracy of the answer increases. Computers employ efficient algorithms to decide when to stop adding terms based on precision requirements or a predefined limit. This computational approach enables computers to approximate various functions swiftly, significantly enhancing their capacity for scientific simulations, numerical analysis, and engineering computations.

Error and convergence

In the context of the Taylor series, error and convergence are essential concepts. The error in a Taylor series approximation measures the difference between the actual function value and its approximation using a finite number of series terms. This error is often quantified by the remainder term, which represents how closely the approximation matches the function’s value at a specific point.

Convergence, on the other hand, indicates whether a Taylor series approaches the true function value as more terms are added. A convergent series provides increasingly accurate approximations within a certain interval around its center point, while a divergent series fails to approach the actual function value, no matter how many terms are included.

Assume f(k)(x)f^{(k)}(x) (0kn)(0\leq k \leq n) are continuous functions.

If we call the first n+1n+1 terms in the Taylor series, the error is:

where ξξ is some value between xx and cc. For the sum up to infinity, this holds true. The first term dominates the sum if it converges. If xx is near the value of cc, the series converges swiftly, whereas it either converges slowly or doesn’t converge at all if xx is at a significant distance from the value of cc.

A special case, when n=0n=0, is called the Mean value Theorem.

According to this theorem, there must be at least one point cc in the open interval (a,b)(a,b) where the derivative of the function equals the average rate of change of the function over the interval (a,b)(a,b) if a function f(x)f(x) is continuous on a closed interval [a,b][a,b] and differentiable on the open interval (a,b)(a,b).

If ff is smooth on the interval(a,b)(a,b), then,f(a)f(b)=(ba)f(ξ),f(a)-f(b)=(b-a)f'(ξ), for some ξξ in (a,b)(a,b).

Mean value theorem
Mean value theorem

This implies:

So, if the values of aa and bb are close together, the theorem can be used to approximate ff'.

Given h>0h>0 but is significantly small, this implies:

Another way of writing the Taylor series is as follows:

where

for some ξξ that lies between xx and x+hx+h. The above equations can be used as the baseline formulas for deriving the error estimates.

Here's a basic coding example to calculate the Taylor series of a function, like exe^x, around the point 0 (Maclaurin series).

Let's use Python for this example:

import math
def factorial(n):
"""Calculate the factorial of a number."""
return 1 if n == 0 else n * factorial(n - 1)
def taylor_series_exponential(x, n_terms=10):
"""Calculate the Taylor series approximation of e^x."""
return sum((x**i) / factorial(i) for i in range(n_terms))
# Example usage
x = 1 # Calculate e^x for x = 1
approximation = taylor_series_exponential(x)
print('Approximation of e^x:', approximation)
print('Actual value of e^x:', math.exp(x))

In this example, the function taylor_series_exponential calculates the Taylor series approximation ofexe^xusing the first n_terms of the series. The factorial function calculates the factorial of a number, which is used in the denominator of each term in the series.

The example usage calculates the approximation of exe^x (as e1e^1) and compares it with the actual value from Python's math.exp function. The more terms you include (n_terms), the more accurate the approximation will be.

Conclusion

Taylor series approximates a function by expressing it as an infinite sum of terms based on its derivatives at a specific point. It’s a powerful tool in mathematics, allowing us to represent complex functions with simpler polynomial expressions. By using more terms in the series, we can achieve increasingly accurate approximations of the original function, making it invaluable in various fields, from physics and engineering to computer science and numerical analysis.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved