Simpson's composite rule rate of convergence.

3.2k Views Asked by At

Hello I have wriiten a program in Matlab that determines an Integral using Simpsons rule and it also determines the rate of convergence.

I tried my program on the following examples: $f(x)=\sin{ x}$ for $x\in[0, 2\pi]$ and $x\in[0, \pi]$.

I get a good approximation of the real value for both Intervalls but the problem is for the Intervall $x\in[0, \pi]$ I get convergence rates equal to ~$4$ as it should be.

For the intervall $x\in[0, 2\pi]$ I get very random convergence rates: $$ \infty, -\infty, 0.3418, 2.6110, -0.8791, -1.2655, 4.0533, -1.7163, -4.7031, 1.1002$$

Why is this? Is there any explaination? Is it because the Integral for the first Intervall is $0$? Is it because the function has some negative values on $[\pi,2\pi]$? Any idea?

1

There are 1 best solutions below

0
On BEST ANSWER

Neglecting round-off errors, Simpson's rule is exact for the integral $\int_0^{2\pi} \sin x\,dx$: it yields exactly $0$. The reason is that it uses an even number of subintervals, so that the step size is of the form $\pi/n$. Thus, if $x \in (0,\pi)$ is a sample point, then $x+\pi$ is also a sample point (and it gets the same weight in the rule). Since the value at $x+\pi$ is the negative of the value at $x$, we have perfect cancellation. In theory.

In practice, round-off errors occur. These are typically much smaller than the errors of the quadrature formula. They are also pretty random, depending on how the particular floating point numbers were truncated. Hence, your method of error estimation, based on comparing $k$ vs $k-1$ points, gives nonsensical results.


Remark 1. A more robust error estimation approach is to take many values of $\log(\operatorname{errf}(k))/\log(1/2) $ and fit a line to them. The slope of that line is the order of error.

Remark 2. Integration of a smooth periodic function over its period is a special case, in which the common ideas of which rule is more exact do not apply. The humble Left Endpoint rule outperforms Gaussian integration on such functions.