How to find Simpson's rule

101 Views Asked by At

Can anyone help me find my mistake?

$$I = \int_0^2 f(x) ~ dx, \qquad f(x)=\frac {3^x}{x+1}$$

I got $f(0)=1$

$f(0)=1$

$f(1/2)=\frac{2(3^{1/2})}3$

$f(1)=3/2$

$f(3/2)=\frac{6(3^{1/2})}5$

$f(2)=3$

Calculation $I = \frac16[1+2(\frac{2(3^{1/2})}3)+4(3/2)+2(\frac{6(3^{1/2})}5)+3]$ when I used and substituted in the formula then I am getting $2.7$.....

But, the actual answer is $3.32$....

2

There are 2 best solutions below

0
On BEST ANSWER

If you are using Simpson's rule over two unit intervals it should be $$\frac 16[f(0)+4f(\frac 12)+2f(1)+4f(\frac 32)+1f(2)]$$ That gives $$\frac 16\left[1+4\cdot \frac 23\sqrt 3+2\cdot \frac 32+4\cdot \frac 65\sqrt 3+3\right]=\frac 16(7+\frac {112}{15}\sqrt 3)\approx 3.32$$ If the length of each interval were different from $1$ we would have to multiply by it. The $2$ in the center comes from adding $1$ from each interval.

0
On

Let $$I = \int_0^2 f(x) ~ dx \quad\&\quad f(x)=\frac {3^x}{x+1}. \tag{1}$$

Simpson's rule on the interval $[0,1]$ gives $$\int_0^1 f(x) ~ dx \approx \frac{1-0}{6} \left[ f(0) + 4f\left(\frac12\right) + f(1) \right]. \tag{2}$$ Similarly, on the interval $[1,2]$, $$\int_1^2 f(x) ~ dx \approx \frac{2-1}{6} \left[ f(1) + 4f\left(\frac32\right) + f(2) \right]. \tag{3}$$

To approximate $(1)$, we sum $(2)$ and $(3)$: $$I \approx \frac16 \left[ f(0) + 4f\left(\frac12\right) + f(1) \right] + \frac16 \left[ f(1) + 4f\left(\frac32\right) + f(2) \right].$$ Combining & simplifying, $$I \approx \frac16 \left[ f(0) + 4f\left(\frac12\right) + 2f(1) + 4f\left(\frac32\right) + f(2) \right].$$

Compare with your calculations: $$\require{cancel} I \approx \frac16 \left[ f(0) + \cancel{2f\left(\frac12\right)} + \cancel{4f(1)} + \cancel{2f\left(\frac32\right)} + f(2) \right].$$ (I have sticken out the parts of the calculation that are incorrect.)