Trying to re-write Simpson's Rule: mistake?

248 Views Asked by At

Pre-Question (edited): Thanks Arthur

Orignal Problem: The standard form of Simpson's Rule requires an even value of n so that you can make a series of parabolas

Parabola 1 has area $$\frac{x_n-x_0}{n} * \frac{f(x_0) + 4f(x_1) + f(x_2)}{3}$$

Parabola 2 has area $$\frac{x_n-x_0}{n} * \frac{f(x_2) + 4f(x_3) + f(x_4)}{3}$$

And the entire sum becomes $$\frac{x_n-x_0}{n} * \frac{f(x_0) + 4f(x_1) + 2f(x_2) + … + 2f(x_{n-2}) + 4f(x_{n-1}) + f(x_n)}{3}$$

I wanted to see what this would look like if extra parabolas, these graphed with points of odd-even-odd values, were added to the existing series of even-odd-even parabolas.

Googling "overlapping Simpson's Rule," "Simpson's Rule variants," and the such only gave me A) a very messy combination of the standard and the 3/8 Rules, and B) the even higher order NC quadratures that apparently lose accuracy to a "Runge's phenomenon."

I tried to figure out a simpler one myself by starting with the series of f values:

$$f(x_0) + 4f(x_1) + 2f(x_2) + … + 2f(x_{n-2}) + 4f(x_{n-1}) + f(x_n)$$

=>

$$f(x_0) + 5f(x_1) + 6f(x_2) + … + 6f(x_{n-2}) + 5f(x_{n-1}) + f(x_n)$$

and then seeing how the $\frac{x_n-x_0}{n}$ term would need to change in response.

I figured that since there were now $n-1$ parabolas instead of the original $\frac{n}{2}$, and the new parabola would each have roughly the same area as the 2 originals nearby, I should multiply my new result by $\frac{n/2}{n-1}$ to account for the increased number of areas going into the sum.

$\frac{x_n-x_0}{n}$ now became $\frac{x_n-x_0}{2(n-1)}$, and I went to Excel to test this formula with $f(x) = cosx + 1$ with 10 and 100 subintervals from 0 to 3

(correct area: $_0∫^3 (cosx+1)dx = (sin3+3)-(sin0+0)≈3.14112$.)

At n=10, the standard 1424…4241 formula gave a relative error of 2*10-6 and my new 1566…6651 gave a relative error of 3*10-3.

At n=100, the "142" version gave a relative error of 2*10-10 and my "156" version gave a relative error of 4*10-4

Is this formula "correct" (but still useless, and I should stick to the established formulae), or did I make a mistake somewhere that I can fix to make mine more accurate?

1

There are 1 best solutions below

0
On BEST ANSWER

You did not calibrate the formula correctly, introducing extra multiplicative error. The factor in front of the sum should be such that the formula is exact for the constant function $f(x)\equiv 1$. Writing $n=2k$, we see that the sum $$f(x_0) + 5f(x_1) + 6f(x_2) + … + 6f(x_{n-2}) + 5f(x_{n-1}) + f(x_n)$$ evaluates to $$2+5k+6(k-1) = 11k-4 = \frac{11n-8}{2}$$ Since $\int_a^b 1\,dx = (b-a)$, the correct formula is $$\int_a^b f(x)\,dx \approx \frac{2(b-a)}{11n-8}\left[ f(x_0) + 5f(x_1) + 6f(x_2) + \dots + 6f(x_{n-2}) + 5f(x_{n-1}) + f(x_n)\right]$$

For $\int_0^3 (\cos x+1)\,dx$ with $n=10$ this gives $3.149554$, which is actually worse than your version. I think you got lucky there because using too small factor in front compensated for the fact that the formula overestimates.

So: your formula has error $O(n^{-1})$ (seen by testing on constant function); the corrected version above has error $O(n^{-2})$ (seen by testing on $f(x)=x^2$); both are far inferior to Simpson's rule.

Rule of thumb: if your formula is not exact for quadratic polynomials, it will perform worse than Simpson's rule.