1. Simpson Rule

Lets say the interval is [-4,4]
I am confused to choose the correct formula in given situations.

$\displaystyle \int_{a}^{b} f(x) \, dx \approx \frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right]$
AND
$\displaystyle \int_a^b f(x) \, dx\approx \frac{h}{3}\bigg[f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+ 4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n)$

I think the aobve is used for n+1 nodes but I am not sure how to get the nodes. Is the original interval [-4,4] has zero nodes?
Thanks

2. Originally Posted by charikaar
Lets say the interval is [-4,4]
I am confused to choose the correct formula in given situations.
$\displaystyle \int_{a}^{b} f(x) \, dx \approx \frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right]$
$\displaystyle \int_a^b f(x) \, dx\approx \frac{h}{3}\bigg[f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+ 4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n)$
The first is Simpson's rule with the interval divided into exactly two subintervals with the "break" at the midpoint: $\displaystyle x_0= a$, $\displaystyle x_1= \frac{a+ b}/2$, and $\displaystyle x_1= b$. The second is for any odd number of points (even number of subintervals). To find $\displaystyle x_i$, take $\displaystyle h= \frac{b- a}{n-1}$. Then $\displaystyle x_i= a+ hi$.