Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wikipedia says the midpoint formula for numerical integration has error of order $h^3 f''(\xi)$. I am trying to replicate this result.

I'm guessing that I want to use Lagrange's formulation of the remainder for Taylor series. Let $x_0=\frac{a+b}{2}$ (i.e. the midpoint).

The midpoint method says $\int_a^b f(x)dx \approx (b-a)f(\frac{a+b}{2})$, so to get the error I find $(b-a) f(\frac{a+b}{2}) - \int_a^bf(x)dx$. If I expand this using Taylor's theorem I get:

$ \begin{aligned} error & =(b-a) f(x_0) - \int_a^bf(x_0)+\frac{f'(\xi)(x-x_0)}{2}dx \\ & =\frac{f'(\xi)}{2}\int_a^b(x-x_0)dx \\ & =\frac{f'(\xi)}{2}\int_a^b(x-\frac{a+b}{2})dx \\ & = 0 \end{aligned}$

So apparently I have just proven that it has zero error? Any hints as to what I did wrong? (I realize that since wikipedia gives it in terms of $f''$ I probably want to take the expansion one level further to match them, but I don't understand why this doesn't work.)

share|cite|improve this question
Since $\xi$ depends on $x$, you can't take $f'(\xi)$ outside of the integral. – Hans Lundmark Dec 22 '10 at 21:20
up vote 3 down vote accepted

You are right that you need one more term in your Taylor series. If you write $f(x)=f(x_0)+(x-x_0)f'(x_0)+(x-x_0)^2f''(\xi)/2$ and plug that into the midpoint method, the term in $f''$ will survive. What you have done essentially shows that if $f$ is linear, the method is exact.

share|cite|improve this answer
But why doesn't this work? Shouldn't I be able to write any $f$ as $f(x_0)+f'(\xi)$, regardless of whether it's linear or not? – Xodarap Dec 22 '10 at 21:21
But it hides the fact that $\xi$ depends upon $x$, so you can't factor it out of the integral as you did unless $f$ is linear and $f'(\xi)$ is constant. – Ross Millikan Dec 22 '10 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.