# Simpson's rule with precision?

I have an integral:

$$\int_0^1sinx^2dx$$

Task is to solve this integral using Simpson's rule with precision $\frac{1}{2}10^{-4}$.

I am not sure how should I do that. I have this formula for calculating error:

$$r(\frac{h}{2}) = \frac{I(h) - I(\frac{h}{2})}{k^2 - 1}$$ where $$I = f(x)dx$$ in this case would be: $$I = sinx^2dx$$

(So $I=sinx^2dx$ is same as $I=2xcosx^2$)

Should this be correct way to solution:

$a=0$ and $b=1$, so first I should take some initial $k$ and divide $[a,b]$ into $k$ equal pieces where $h$ would be step. Then plug $h$ and $k$ into formula and see the result. If result is greater then $\frac{1}{2}10^{-4}$ then increase $k$. Repeat until next criteria is satisfied:

$$r(\frac{h}{2}) \le \frac{1}{2}10^{-4}$$.

And at last, I have $h$, now I can simply calculate integral using Simpson's rule and get desired precision.

Use the error bound $\frac{(b-a)^5}{90 \cdot 2^5} f^{(4)}(\xi)$ for the one panel Simpson's rule instead.
• I found some article in my mother tongue language that solves same integral. Thing is I need to take some initial $h$ so I get odd number of pieces of $[a,b]$ and then calculate integral's value using Simpson's rule and step $h$. After I get value, I divide $h$ by half, increasing number of pieces and again calculating integral with Simpson's rule and step $\frac h 2$. After then I take these two values put in formula $\frac {|I_{h/2} - I_h|} {k^2 - 1}$ and if that is less then or equal desired precision then stop. Aug 22, 2015 at 20:26