Approximating infinite series

In this post, I’ll derive the Euler-Maclaurin summation formula, which allows you to closely approximate a infinite series.

For infinite series that are hard to evaluate analytically, we can sometimes resort to numeric evaluation, that is, we find a close approximation of the series.

For example, Euler famously applied this to the Basel problem, which asks for the value of . Before finding the analytical value , Euler found that

Euler found the first 20 fractional digits of the expression, and it is commonly believed that this convinced him that , which he subsequently proved.

In this post, I’ll explain the method Euler used to find such an accurate approximation. We’ll start with a naive approximation method and figure out more accurate methods step-by-step.

Infinite sums, the naive way

Suppose we want to numerically evaluate . In order for this sum to converge, must be a function that satisfies . By definition, we have

So, as a first approximation to , we can take some and evaluate the partial sum of the first terms. We expect the approximation to get better as gets larger.

This gives us our first, naive way of approximation : For large , we have

This method only works well for series with terms that go to zero very rapidly (e.g. exponentially).

Estimating the tail

We can write split the series explicitly in the partial sum of the first terms, and the other terms:

By approximating an infinite series with a partial sum, we essentially drop the infinite “tail” . Evaluating this sum directly is as hard as evaluating the original (complete) sum, but we can improve the accuracy of our initial approximation by adding an approximation to the infinite sum.

For this, we can use the approximation

This gives us an improved formula for approximating :

A geometric improvement

Now, again, we want to improve the accuracy of the approximation

Using we can write the error explicitly as . We now have

Let’s visualize this and draw , , and in a single graph:

We can see that the shaded areas look a lot like triangles. If we approximate the shaded area on the interval with the formula for the area of a triangle, we get:

If we plug this into , we get

Setting , and using that gives us

If we plug this into , we get

This is again an improvement over the previous approximation formula.

A natural question is now if we can further improve this method. Intuitively you’d expect a connection with the first derivative of , and it feels like you might be able to generalize this to higher-order derivatives. However, geometrically it’s not clear exactly how this would generalize.

Analysis with Taylor series

Let’s try to see what’s going on through the lens of Taylor series.

If we take and set , , the summation is just over a single term. Using we get

Using the Taylor expansion of at , we get

We can substitute the Taylor series both in and :

Substituting these expressions back in gives

In other words, the term serves as a correction that cancels the term involving in the Taylor expansion of . The rest terms now only derivatives of at least second order. For smooth functions we expect that the magnitude of higher derivatives is much smaller than that of lower derivatives, which explains why adding the correction actually improves the approximation.

General case

In the previous section we saw that adding the term cancels the terms involving first order derivatives in the Taylor expansion of . We’ll now try to generalize this idea and cancel the terms involving the first derivatives.

That is, we try to find , , …, such that

contains no terms involving , , …, . This happens exactly when the coefficients of in the Taylor expansions of and match for .

Using the Taylor expansion of at we get

So the coefficient of in the Taylor expansion of is .

Likewise we have and

So the coefficient of in the Taylor expansion of is .

Equating the two gives

Evaluating at , we can turn this into an equation for :

So we have found:

with

is the number of terms of the approximation, and is the order of the approximation.

The first 10 coefficients are:

We can see that all the even terms except are zero.

Demonstration

This plots the error of the approximation for the following series:

    Relation to the Bernoulli numbers

    Taking and multiplying it by we get

    We have , so let’s substitute so we can simplify. We get

    This is a recurrence relation for the Bernoulli numbers , , … However, the recurrence relation doesn’t account for the first Bernoulli number . If we boldly extend the summation to and set we get , which is indeed correct. For we have

    So we have found the following recurrence relation for the Bernoulli numbers:

    Here, is defined as