Approximating infinite series
In this post, I’ll derive the Euler-Maclaurin summation formula, which allows you to closely approximate a summation over a function by its integral.
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 how Euler was able 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
How well this method works depends greatly on how fast goes to 0.
TODO: examples here
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 :
TODO: examples
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:
Gathering the shaded segments on the left, we can see that the shaded areas look a lot like triangles:
We can therefore estimate the shaded area on the interval with the formula for the area of a triangle:
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.
TODO: examples
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 is a better approximation to than .
General case
In the previous section we saw that adding the term cancels the terms involving first order derivatives in the Taylor expansion of . This idea generalizes in a straightforward way: We’ll now try to 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 this relation for gives . For it gives
Substituting gives . Now, we can set and substitute the values for and to find . We can continue this strategy to compute all the coefficients we need.
The first 10 coefficients are:
Demonstration
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