Calculate $\int_{0}^{1} \sin(x^2)$ with an error $\le 10^{-3}$ Calculate $\int_{0}^{1} \sin(x^2)$ with an error $\le 10^{-3}$
Let $f(x)= \sin(x^2) $ continuous in [0,1] so by the MVT for integrals we know $\int_{0}^{1} \sin(x^2) = \sin(c^2) \; \text{for} \; c \in [0,1]$. I don't really know if this is of any help. Another thing that I know is that $\int_{0}^{1} \sin(x^2) \le \int_{0}^{1} x^2  \; \text{for} \; x \in [0,1]$. Any hints on how to resolve this ? Thanks in advance.
 A: Using the Taylor series representation of the sine function we have
$$\begin{align}
\int_0^1 \sin(x^2)\,dx&=\lim_{N\to\infty}\sum_{n=1}^N \frac{(-1)^{n-1}}{(4n-1)(2n-1)!}\\\\&=\sum_{n=1}^N \frac{(-1)^{n-1}}{(4n-1)(2n-1)!}+E_N
\end{align}$$
Inasmuch as this is an alternative series, we would like to choose $N$ such that $E_N<0.001$ or
$$(4N+3)(2N+1)!>1,000$$
For $N=2$, we have $(4N+3)(2N+1)!=1,320$
Hence, we find that
$$\left|\int_0^1 \sin(x^2)\,dx-\left(\frac13-\frac1{42}\right)\right|=\left|\int_0^1 \sin(x^2)\,dx-\left(\frac{13}{42}\right)\right|<0.001$$
A: Use the Maclaurin series for $\;\sin x^2\;$, which converges absolutely at every point and thus you can integrate/differentiate it termwise:
$$\sin x^2=\sum_{n=0}^\infty\frac{(-1)^n (x^2)^{2n+1}}{(2n+1)!}=\sum_{n=0}^\infty\frac{(-1)^n x^{4n+2}}{(2n+1)!}\implies$$
$$\int_0^1\left(\sum_{n=0}^\infty\frac{(-1)^n x^{4n+2}}{(2n+1)!}\right)dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\int_0^1 x^{4n+2}dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\cdot\frac1{4n+3}$$
The above is a Leibniz  series and we can estimate its value in a reasonably easy way:Leibniz theorem telss us that if $\;S\;$ is the series sum and $\;S_n\;$ the $\;n\,$- th term of its partial sums sequence,  and $\;a_n\;$ is its general term sequence, then
$$|S-S_n|<|a_{n+1}|=\frac1{(2n+3)!(4n+7)}\stackrel{\text{we want!}}<\frac1{1000}$$
Well, you can now even try a very few times and get the correct value of $\;n\;$
A: In the same spirit as the other answers but making the problem more general, consider
$$I=\int_0^t \sin(x^2)\,dx=
\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\int_0^t x^{4n+2}dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}$$ Writing
$$I=\sum_{n=0}^p\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}+\sum_{n=p+1}^\infty\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}$$ you then want to know the value of $p$ such that
$$\frac {t^{4p+7}}{(2p+3)!\,(4p+7)} \leq 10^{-k}$$ that is to say
$$(2p+3)!\,(4p+7) \geq t^{4p+7}\,10^{k}\tag 1$$ To simplify the problem we shall approximate the lhs $\big[(4p+7\sim 4p+8=2(2p+4)\big]$and rewrite $(1)$ as
$$ (2p+4)! \geq \left(t^2\right)^{2 p+4}\frac{10^k} {2t}\tag 2$$
If you look at this question of mine, you will see a magnificent approximation by @robjohn. Applied to your problem, this will give
$$\color{blue}{p \sim \frac 12  t^2\, e^{1+W(u)}-\frac 94} \qquad \text{where} \qquad \color{blue}{u=\frac 1{e\,t^2}\,\log \left(\frac{10^k}{2 t^2\sqrt{2 \pi } }\right)}\tag3$$ where $W(.)$ is Lambert function. For sure, after computing $p$ as a real, you will need to take $\lceil p\rceil$.
Applied to your case $t=1$ and $k=3$, this gives $p=0.90006$ then $p=1$.
Satrting from @DonAntonio's last equation (copy/paste)
$$|S-S_n|<|a_{n+1}|=\frac1{(2n+3)!(4n+7)}\stackrel{\text{we want!}}<\frac1{1000}$$ the exact solution would be $n=0.92604$. Checking with $n=1$
$$\frac1{5!11}=\frac 1{1320}$$
But now, suppose that you want a very high accuracy such as $k=20$ : using $(3)$, you would find $p=8.49617$ then $p=9$. The exact result for @DonAntonio's last equation would be $8.50041$.
