TITLE: How to evaluate $\int_0^1 \mathrm e^{-x^2} \,\mathrm dx$ using power series?
QUESTION [8 upvotes]: I'm trying to evaluate 
$$\int_0^1 \mathrm e^{-x^2} \, \mathrm dx$$ 
using power series. 
I know I can substitute $x^2$ for $x$ in the power series for $\mathrm e^x$:
$$1-x^2+ \frac{x^4}{2}-\frac{x^6}{6}+ \cdots$$ 
and when I calculate the antiderivative of this I get 
$$x-\frac{x^3}{3}+ \frac{x^5}{5\cdot2}-\frac{x^7}{7\cdot6}+ \cdots$$ 
How do I evaluate this from $0$ to $1$?

REPLY [3 votes]: May be, your question could be : "How many terms need to be added to reach a given accuracy ?"
So, write $$\int_{0}^{1}e^{-x^2}=\sum_{n=0}^{p-1} \frac{(-1)^{n}}{(2n+1)n!}+ R_p$$ and you want $$R_p=\frac{1}{(2p+1)p!} \leq 10^{-k}\implies (2p+1)p! \geq 10^{k}\implies \log\left((2p+1)p!\right) \geq \log(10^{k})$$ If you look at the plot of the last rhs, you will notice that it looks like a power law and a very simpler regression will give (for $1 \leq p \leq 20$)
$$\log\left((2p+1)p!\right)\approx 0.831352\, p^{1.34007}$$ which will then give $$p \approx 2.13873\, k^{0.74623}$$ So, using for example, $k=6$, this would give $p=8.144$; then say $p=9$. Checking $$17 \times 8!=685440 <10^6$$ $$19 \times 9!=6894720 >10^6$$ So, computing the terms by the summation up to $p=8$,we should get $$\frac{1098032417}{1470268800}\approx 0.74682427$$ while the exact value would be $\frac{\sqrt{\pi }}{2}  \text{erf}(1)\approx 0.74682413$.