# Having trouble applying the formula for simpson's rule.

My professor provided following formula for simpson's rule:

$$\int_a^b f(x)\;dx \approx \frac{h}{3} \sum_{j=0}^{n-1} ( f(x_{2j}) + 4f(x_{2j+1}) + f(x_{2j+2}))$$

Okay so my problem lies when solving the following question:

Use simpson's rule with 2n=8 to approximate $\int_0^4 \frac{2x}{1+x^2}\;dx$ to 6 decimal places.

Okay so , n = 4 and $\Delta h = \frac{4-0}{4}=1$ . So

$$x_0=0$$ $$x_1=1$$ $$x_2=2$$ $$x_3=3$$ $$x_4=4$$

and we solve:

$$\int_a^b f(x)dx \approx \frac{1}{3} \sum_{j=0}^{3} ( f(x_{2j}) + 4f(x_{2j+1}) + f(x_{2j+2}))$$ Then using the formula ( the confusing part) :

$$\int_0^4 f(x)dx \approx \frac{1}{3} ( \, [f(x_0)+4f(x_1) + f(x_2)] \, + [ f(x_2) + 4f(x_3) + f(x_4) ] + [ f(x_4) + 4f(x_5) + f(x_6)] + [f(x_6)+4f(x_7)+f(x_8)] )$$

And as you can see, I have grouped the terms in the order of j=0,1,2,3. However, $x_j | \, \,j>4$, that does not exist.

The proper approximation is when we evaluate the above formula only for j=0 and j=1.

What did I do wrong?

Thank you.

It seems you were assuming $nh=b-a$. Evaluating the sum for $f(x)=1$ yields $2nh$, so you should have $2nh=b-a$. Then everything works out.
(I disagree with Alex' comment; the limits on the sum are OK as they are; if the upper limit had been $n/2-1$, there would have been no reason to specify $2n$ instead of specifying $n$.)
• So I would have $n=0.5$ ? Jul 12 '15 at 5:09
• Yes.    Jul 12 '15 at 5:11