I would like to calculate $\int_0^1 \cos(x^2)dx$ with an error smaller than $10^{-6}$ (this error should be proven.).
I have a strategy, but I am not quite sure if this is a valid one. Here is what I did:
I know that the series representation of the cosine is:$$\cos(x) = \sum_{k=0}^\infty (-1)^k \frac{x^{2k}}{(2k)!}$$ Since the integral boundaries I want to calculate only range from $0$ to $1$, I can use the fact that $a_k :=\frac{x^{2k}}{(2k)!}$ is a falling sequence for $x \in [0,1]$. Then I would use the estimation from the Leibnitz criterion, that for positive falling $a_k$ with
$$s_n := \sum_{k=1}^n (-1)^k a_k$$ the inequality $|s - s_n|\le a_{n+1}$ holds, whereas $s$ denotes the limit of $s_k$.
Then I could say that for $n=9$:
$$|\cos(x)-s_9| \le \frac{1}{(2\cdot 10)!}$$
Then I would calculate $\int_0^1 \sum_{k=0}^9 (-1)^k \frac{x^{4k}}{(2k)!}dx$
The estimate I get seems to be correct, however I am not sure whether or not my prove above is sufficient. Any help would be greatly appreciated!
You need to change the order of what what you're doing. First integrate, then bound the series:
$$\int_0^1 \cos(x^2) \; dx = \int_0^1 \sum_{k=0}^{\infty} \frac{(-1)^k x^{4k}}{(2k)!} \; dx =\sum_{k=0}^{\infty} \frac{(-1)^k}{(4k+1)(2k)!}. $$
So the error in $s_n$ is bounded by $$\frac{1}{(4(n+1)+1)(2(n+1))!}.$$ And $n=4$ suffices.