On this page
You have probably estimated a sum with an integral without naming the trick: the area under y = 1/x is close to 1 + 1/2 + 1/3 + … The Euler–Maclaurin formula makes that idea exact, one correction at a time. According to the Wikipedia article on the formula, Leonhard Euler and Colin Maclaurin discovered it independently around 1735.
What is the Euler–Maclaurin formula?
For a smooth function f and integers a < n, the NIST Digital Library of Mathematical Functions, §2.10 states it as:
f(a) + f(a+1) + … + f(n) = ∫ₐⁿ f(x) dx + ½f(a) + ½f(n) + Σ over s of (B₂ₛ/(2s)!)·[f⁽²ˢ⁻¹⁾(n) − f⁽²ˢ⁻¹⁾(a)] + R
Read it in three layers:
The integral: the area under the curve, your first guess.
Half of each end value: the sum counts both endpoints in full, while the area treats them as edges.
The corrections: each is a Bernoulli number times the change in an odd derivative of f between the two ends. R is a remainder, an integral involving the next even derivative.
The Bernoulli numbers are defined by the expansion t/(eᵗ − 1) = Σ Bₙtⁿ/n!, and the ones needed here are B₂ = 1/6, B₄ = −1/30 and B₆ = 1/42 (DLMF §24.2). So the first two correction coefficients are B₂/2! = 1/12 and B₄/4! = −1/720.
How does it give 1² + 2² + … + n² exactly?
Take f(x) = x² from a = 0 to n. Then f′(x) = 2x and f‴(x) = 0, so only the first correction survives and the remainder is zero.
Integral: ∫₀ⁿ x² dx = n³/3.
End terms: ½f(0) + ½f(n) = n²/2.
First correction: (1/12)·[f′(n) − f′(0)] = (1/12)·2n = n/6.
Add them: n³/3 + n²/2 + n/6 = n(n+1)(2n+1)/6.
Check with n = 10: 1000/3 + 50 + 10/6 = 385, and 1 + 4 + 9 + … + 100 is indeed 385. The same steps with f(x) = x³ give [n(n+1)/2]², the example the Wikipedia article works through.
How does it estimate 1 + 1/2 + … + 1/n?
Now take f(x) = 1/x from 1 to n. The corrections never stop, but for large n the first few are tiny, and the constant pieces collect into one number. That number is the Euler–Mascheroni constant γ, defined as the limit of 1 + 1/2 + … + 1/n − ln n, and equal to 0.5772156649… (DLMF §5.2). The expansion, as given in the Wikipedia article, reads:
1 + 1/2 + … + 1/n ≈ ln n + γ + 1/(2n) − 1/(12n²) + 1/(120n⁴) − …
Try n = 10. Since ln 10 = 2.3025851, four terms give 2.3025851 + 0.5772157 + 0.05 − 0.0008333 = 2.9289674. The exact sum is 7381/2520 = 2.9289683. The gap, about 0.0000008, is almost exactly the next term, 1/1,200,000.
One warning: this is an asymptotic series. The Wikipedia article notes that it "is usually not convergent": past some point the terms grow again, so you stop early. The same article records that Euler used only a few terms to compute 1 + 1/4 + 1/9 + … to 20 decimal places in 1735.
If Bernoulli numbers or asymptotic series are new to you, the Fermi Concept Library covers every concept in mathematics, each with its own lesson and its place in the map.
What does it have to do with the trapezoidal rule?
The expression ½f(a) + f(a+1) + … + f(n−1) + ½f(n) is the trapezoidal rule with strips of width 1, and the Wikipedia article describes the formula as an extension of the trapezoid rule by correction terms:
trapezoid − integral = (1/12)[f′(n) − f′(a)] − (1/720)[f‴(n) − f‴(a)] + …
Two consequences follow:
The trapezoid's leading error depends only on the slopes at the two ends. Subtract (1/12)[f′(n) − f′(a)] and your estimate usually improves sharply.
For a smooth periodic function integrated over a whole period, the end derivatives match and the corrections cancel. The same article says this explains the trapezoidal rule's superior performance on such functions.
How do you use it on a problem?
Spot a sum of a smooth f(k) with no short closed form, or a limit comparing a sum with an integral.
Write the integral plus half of each end value.
Add the 1/12 correction, then check how small the 1/720 term is.
For limits like 1 + 1/2 + … + 1/n − ln n, recognise γ.
For a polynomial, carry the corrections to the last nonzero derivative.
Try it on 1³ + 2³ + … + n³ or on 1/1² + 1/2² + … + 1/n² for large n. To check your working, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.



