---
tag: 9P839VB8S7
kind: statement
role: theorem
name: Euler–Maclaurin formula
msc: [65B15, 40A25, 26A42]
uses: [0RAS24E1R5, BXQKBJJGFG, 0QM4TXT3DR, 0JH4MN4K1C]
about: [0JH4MN4K1C, 0QM4TXT3DR]
sources:
  - url: https://en.wikipedia.org/wiki/Euler%E2%80%93Maclaurin_formula
same_as:
  wikidata: Q282023
  wikipedia: Euler–Maclaurin formula
---

## Statement

Let $m < n$ be integers, let $p \ge 1$ be an integer, and let $f \colon [m, n] \to \R$ have a continuous $p$-th derivative.
Let $B_k$ be the [[Bernoulli numbers|0RAS24E1R5]] with $B_2 = \frac16$, and let $P_p(x) = B_p(x - \floor{x})$, where $B_p(t)$ is the [[Bernoulli polynomial|BXQKBJJGFG]] of degree $p$.
Then
$$\sum_{i=m}^{n} f(i) = \int_m^n f(x)\, dx + \frac{f(m) + f(n)}{2} + \sum_{k=1}^{\floor{p/2}} \frac{B_{2k}}{(2k)!} \bigl(f^{(2k-1)}(n) - f^{(2k-1)}(m)\bigr) + R_p,$$
where
$$R_p = (-1)^{p+1} \int_m^n f^{(p)}(x) \, \frac{P_p(x)}{p!}\, dx.$$

## Remarks

The proof is repeated integration by parts on each interval $[i, i + 1]$, using $B_k'(t) = k B_{k-1}(t)$ and the fact that $B_k(0) = B_k(1)$ for $k \ge 2$.
For $p = 1$ the formula reads $\sum_{i=m}^{n} f(i) = \int_m^n f + \frac{f(m) + f(n)}{2} + \int_m^n f'(x) \bigl(x - \floor{x} - \frac12\bigr)\, dx$.
Example: for $f(x) = x^2$ on $[0, n]$ with $p = 3$, the remainder vanishes since $f''' = 0$, and the formula gives $\sum_{i=0}^{n} i^2 = \frac{n^3}{3} + \frac{n^2}{2} + \frac{1}{12} \cdot 2n = \frac{n(n+1)(2n+1)}{6}$.
The infinite series obtained by letting $p \to \infty$ usually diverges, so the formula is used with a fixed $p$ and an estimate of $R_p$.

## Explanations

### L1 human

The formula compares a sum of values $f(m) + \cdots + f(n)$ with the integral of $f$.
The difference is given by the end values of $f$ and its derivatives, with the Bernoulli numbers as coefficients, plus a small remainder.

### L2 human

In one direction it estimates sums by integrals: it gives [[Stirling's formula|0KC0F51T6A]] for $\ln n!$, asymptotics of harmonic numbers, and the values of power sums $\sum i^k$ as polynomials in $n$.
In the other direction it estimates integrals by sums: it describes the error of the trapezoidal rule, and it explains why that rule is very accurate for smooth periodic functions.
It is a quantitative link between [[series|0JH4MN4K1C]] and the [[Riemann integral|0QM4TXT3DR]].
