# approximate error between integral an sum

I am new here. My problem: There is an integral $I:=\int_0^1 f(x)\,dx$ for $f\colon [0,1]\to\mathbb{R}$ and I want to compute it by $H_n:=\frac{f\left(0\right)}{2n}+\frac{1}{n}\left[f\left(\frac{1}{n}\right)+f\left(\frac{2}{n}\right)+\dotsm + f\left(\frac{n-1}{n}\right)\right]+\frac{f\left(1\right)}{2n}$

Whats an easy way to prove the error $|I-H_n|\leq \frac{L}{4n}$?

The function $f$ suffices the lipsch. condition $\Vert f(x_1)-f(x_2) \Vert\leq L \vert x_1-x_2\Vert$?

I didn't attend any lecture about numerical analysis yet. I know how it looks like. I take equidistant steps an only compute the mean of these values. From the lip. condition I know that $\max_{x\in [0,1]} \frac{d}{dx}f(x)\leq L$.

Is there some literature or an EASY way to see this inequality? I think induction in $n$ won't make sense. I don't even know if this approximation has a name in the literature.

-

This approximation is called the trapezoid rule. Write $I - H_n = \sum_{j=1}^n E_j$ where $$E_j = \int_{(j-1)/n}^{j/n} f(x)\ dx - \frac{f((j-1)/n) + f(j/n)}{2n}$$ For convenience I'll write $(j-1)/n = a$, $j/n = b$, $1/n = b - a = \delta$, so $$E_j = \int_a^b f(x)\ dx - \frac{\delta}{2}(f(a) + f(b))$$ Given the Lipschitz condition and the values $f(a)$ and $f(b)$, for $a \le x \le b$ we have $$f(x) \le g(x) = \cases{f(a) + L(x-a) & for a \le x \le (a+b)/2\cr f(b) + L (b-x)) &for (a+b)/2 < x \le b\cr}$$ so $\int_a^b f(x)\ dx \le \int_a^b g(x)\ dx$, which works out to $$\frac{\delta^2}{4} L + \frac{\delta}{2} (f(a) + f(b))$$ Thus $E_j \le \dfrac{\delta^2}{4} L$. Similarly, we get a lower bound $E_j \ge -\dfrac{\delta^2}{4} L$. So $|E_j| \le \dfrac{\delta^2}{4} L = \dfrac{L}{4n^2}$ and $|I - H_n| \le \sum_{j=1}^n |E_j| \le \dfrac{L}{4n}$.
Simpson's rule should be better for large $n$ if your function is smooth. If all you have is a Lipschitz condition, it might not be better, in fact it might be worse. –  Robert Israel Nov 18 '12 at 6:07