3
$\begingroup$

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.)

  • 3
    Since $\xi$ depends on $x$, you can't take $f'(\xi)$ outside of the integral.2010-12-22

2 Answers 2

4

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.

  • 0
    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?2010-12-22
  • 4
    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.2010-12-22
0

Well, i don't think you need to use any specific remainder for Taylor series, $O(h^n)$ would do as well.

The rule: $\int_a^{a+h} f(x)dx \approx hf(a+h/2).$

$$\begin{equation} \int_a^{a+h} f(x)dx = hf(a) +h^2f'(a)/2 + h^3f''(a)/6 + \dots \tag{1}\end{equation}$$ because $\int_a^a f(x)dx = 0.$

$$\begin{equation} hf(a+h/2) = h\Big[f(a) + \frac{h}{2}f'(a) + \frac{h^2}{2^22!} f''(a) + \dots \Big]. \tag{2}\end{equation}$$

First term that differs is near $h^3$, so error is of order $O(h^3).$ Though, of course that's not an accurate answer. You need another approach to get an accurate one.