How to calculate approximation of integral by developing integrant into power series? How to calculate approximation $I = \int_{-1}^{1} e^{-x^{2}} $ by developing integrant into power series, and how many terms of series is needed, so error is smaller than  $\varepsilon = 10^{-3}$ ?
We can rewrite this $I = \int_{-1}^{1} e^{-x^{2}} $ as
$I = \int_{-1}^{1} \sum_{n=0}^{\infty}\frac{(-x)^{2n}}{n!}$
and when we integrate it we get
$2\sum_{n=0}^{\infty} \frac{1}{n!(2n+1)}$ .
How to calculate from here approximation and how many terms of series are needed, so error is smaller than  $\varepsilon = 10^{-3}$ ?
 A: You just need to understand which number $N\in\mathbb{N}$ ensures
$$ 2\sum_{n\geq N}\frac{1}{n!(2n+1)}\leq \frac{1}{10^3} $$
and since $\frac{1}{n!(2n+1)}\leq \frac{1}{n!}-\frac{1}{(n+1)!}$ it is enough to take $N=7$.
I will provide an alternative solution, just for fun. The recurrence relation fulfilled by the moments $a_n = \int_{0}^{1}x^n e^{-x^2}\,dx $ implies that our integral has a nice representation as a continued fraction:
$$ I = 2\int_{0}^{1}e^{-x^2}\,dx = \sqrt{\pi}\,\text{Erf}(1)=\sqrt{\pi}-\frac{1}{e}\cdot\cfrac{1}{1+\cfrac{1/2}{1+\cfrac{1}{1+\cfrac{3/2}{1+\cfrac{2}{1+\ldots}}}}}\tag{1}$$
Unfortunately, it is slowly convergent, so we switch to a Beuker-like approach.
On the interval $(0,1)$, the function $f(x)=x^4(1-x)^4 e^{-x^2}$ is positive and bounded by $\frac{1}{300}$.
Since
$$ \int_{0}^{1} f(x)\,dx = -16+\frac{93}{16 e}+\frac{297}{32} I \tag{2}$$
it follows that $\frac{32}{297}\left(16-\frac{93}{16e}\right)=\color{green}{1.493}51\ldots$ is an accurate approximation of $I$, with the correct green digits. If we replace the polynomial $x^4(1-x)^4$ with the shifted Legendre polynomial $P_4(2x-1)$, we get the even better and simpler approximation:
$$ I \approx \frac{10}{197}\left(32-\frac{7}{e}\right)=\color{green}{1.49364}6899\ldots\tag{3}$$
A: Since
$$
e^{-x^2}=\sum_{n=0}^\infty\dfrac{(-x^2)^n}{n!}=\sum_{n=0}^\infty\dfrac{(-1)^n}{n!}x^{2n},
$$
we have
$$
I=\int_{-1}^1e^{-x^2}\,dx=2\int_0^1e^{-x^2}\,dx=2\sum_{n=0}^\infty\frac{(-1)^n}{n!(2n+1)}\equiv \sum_{n=0}^\infty(-1)^nb_n
$$
with
$$
b_n=\dfrac{2}{n!(2n+1)}.
$$
Since the sequence $\{b_n\}$ is positive and decreasing, if we set
$$
s_n=\sum_{k=0}^n(-1)^kb_k, \quad r_n=\sum_{k=n+1}^\infty(-1)^kb_k,
$$
then
\begin{eqnarray}
|r_n|&=& \left|\sum_{k=n+1}^\infty (-1)^kb_k\right|=\left|\sum_{k=0}^\infty (-1)^{n+1+k}b_{n+1+k}\right|=\left|\sum_{k=0}^\infty (-1)^kb_{n+1+k}\right|\\
&=&\left|b_{n+1}-b_{n+2}+b_{n+3}-b_{n+4}+b_{n+5}-\ldots\right|\\
&=&b_{n+1}-b_{n+2}+b_{n+3}-b_{n+4}+b_{n+5}-\ldots\\
&=&b_{n+1}-(b_{n+2}-b_{n+3})-(b_{n+4}-b_{n+5})-\ldots\\
&\le&b_{n+1}.
\end{eqnarray}
Hence, if we approximate $I$ by $s_n$, then the error is
$$
|I-s_n|=|r_n|\le b_{n+1}
$$
We just have to find $n$ such that $b_n\le 10^{-3}$.  We have
$$
\begin{array}{l|c|c|c|c|c|c|c}
n& 0&1&2&3&4&5&6\\
\hline
b_n&2&\dfrac23&\dfrac15&\dfrac{1}{21}&\dfrac{1}{108}&\dfrac{1}{660}&\dfrac{1}{4680}
\end{array}
$$
We see that 
$$
|I-s_5|\le |r_6|\le b_6=\dfrac{1}{4680}<\dfrac{1}{1000},
$$
therefore we can approximate $I$ with $s_5$. Thus
$$
I\approx s_5=2-\dfrac23+\dfrac15-\dfrac{1}{21}+\dfrac{1}{108}-\dfrac{1}{660}=\dfrac{31049}{20790}=1.493458393.
$$
