Trapezoidal and Simpson’s rule for a function

calculusintegration

Approximate $\int _0^1\: \sqrt{2-x^2}dx$ using the trapezoidal and simpson's rule for 4 intervals.

Now I can determine the simpson rule is
$$\frac{h}{3} \big(f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + f(x_4) \big)$$
and the trapezoidal rule is

$$\frac{h}{2} \big(f(x_0) + 2f(x_1) + 2f(x_2) + 2f(x_3) + f(x_4) \big)$$

and $h= \frac{b-a}{n}$ which I assume is $\frac{1-0}{4}$

But what I don't understand is in knowing this how you add it all together?

Best Answer

Take the Simpson rule as an example.

Pick the equally-spaced points at 0, 0.25, 0.5, 0.75 and 1. Let $f(x) = \sqrt{2-x^2}$. Then, the Simpson expression becomes,

$$\frac{1}{12}(\sqrt 2 + 4 \sqrt{ 2-0.25^2} +2\sqrt{2-0.5^2}+4\sqrt{2-0.75^2}+1)$$ $$= \frac {1}{12}(\sqrt 2 + \sqrt{31} + \sqrt 7 + \sqrt{23} +1) = 1.2853$$

Compared with the exact integral result

$$\int_0^1\sqrt{2-x^2}= \frac{2+\pi}{4}=1.2854$$

the 4-point Simpson numerical integration is very accurate.

The similar procedure can be carried out for the Trapezoidal rule.