0
$\begingroup$

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?

$\endgroup$
0
2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ I see, but where do the values for the equally-spaced points come from? $\endgroup$
    – DuncanK3
    Sep 27 '19 at 10:57
  • $\begingroup$ @DuncanK3 - since you decide to use 4 points within the integration range (0,1), you divide the range by 4 to get $(1-0)/4=0.25$. The values of those equally spaced points are just multiples of 0.25 $\endgroup$
    – Quanto
    Sep 27 '19 at 11:18
  • $\begingroup$ Ah ok that was the piece of the puzzle I was missing! $\endgroup$
    – DuncanK3
    Sep 28 '19 at 11:34
0
$\begingroup$

You need to actually find the values of $x_0$, $x_1$, $\ldots$, $x_4$ and then plug them into $f$ so that you get the values of $f(x_0)$, $f(x_1)$, $\ldots$, $f(x_4)$. Then you just plug them in and evaluate.

For example, $x_0=0$ and $x_1=0+\frac{1}{4}$, so $f(x_0)=\sqrt{2-0^2}=\sqrt{2}$ and $f(x_1)=\sqrt{2-\left(\frac{1}{4}\right)^2}=\frac{\sqrt{31}}{4}$. Then plug those in. For example, with Simpson, you get $$\frac{h}{3}\left(0+4\cdot \frac{\sqrt{31}}{4} +2f(x_2)+4f(x_3)+f(x_4)\right)$$ Now do it for $x_2$, $x_3$, and $x_4$, and you'll have done the Simpson's Rule part. The Trapezoid part is similar.

$\endgroup$
3
  • $\begingroup$ I did try and plug in using the formula but how did you get (x1) = 1/4? $\endgroup$
    – DuncanK3
    Sep 27 '19 at 10:55
  • $\begingroup$ @DuncanK3 Start with $x_0$ as the lower number in the interval ($0$ in this case) and then add $h$ each time to get $x_1,x_2,x_3$ etc. So we have $x_1=x_0+h=0+\frac{1}{4}=\frac{1}{4}$, then $x_2=x_1+h=\frac{1}{4}+\frac{1}{4}=\frac{1}{2}$, etc. $\endgroup$
    – Alexander Gruber
    Sep 28 '19 at 2:55
  • $\begingroup$ Thanks, I was able to use the formula correctly this time! $\endgroup$
    – DuncanK3
    Sep 28 '19 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.