<s>[INST] 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}$ ?
 [/INST] 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.
$$
</s>