I am asked to Find the first four terms of the Maclaurin series for f(x)= $$e^{-x^{2}}$$ and use this information to approximate $$\int_{-1}^{1} (e^{-x^{2}})dx$$ Then compare with the “actual” value (also obtained numerically).
I found the first 4 terms of the Maclaurin series to be $$1-x^2$$ (2nd and 3rd term for n=1 and n=3 went to 0). I used that to find the power series representation from comparing it to $e^x$ and subbing in $-x^2$ and got this to be $$\sum_{n=0}^\infty\frac{(-1)^n}{n!}(x^{2n})$$ It is from here which I am unsure of... I calculated the integral $$\int_{-1}^{1}\frac{(-1)^n}{n!}(x^{2n})dx$$ to get $$\sum_{n=0}^\infty\frac{(-1)^n-(-1)^{3n+1}}{n!(1+2n)}$$
I found the first few terms of this series: $2-\frac{2}{3}+\frac{1}{5}-\frac{1}{21}+\frac{1}{108}-\frac{1}{660}$=approximately 1.49
I am meant to approximate the value of $$\int_{-1}^{1} (e^{-x^{2}})dx$$ to compare with it's "actual" value? I tried subbing in x=0,1,2,3,4,5,6 into $$e^{{-x}^{2}}$$ and got an approximation of 1.39.
I need to know how I can find the exact value of $$\int_{-1}^{1} (e^{-x^{2}})dx$$ and it needs to be done numerically. I’m only in my first year of university maths so we may not have learned all the ways.
Five point Gauss-Legendre quadrature gives:
$$\int_{-1}^{1} (e^{-x^{2}})dx \approx \sum_{n=1}^5 w_n e^{-x_n^2}$$
$$w_n=\frac{2}{(1-x_n^2) (P_5'(x_n))^2}$$
$$P_5(x)=\frac{1}{8}(63 x^5-70 x^3+15 x)$$
$$P'_5(x)=\frac{5}{8}(63 x^4-42 x^2+3)$$
$$x_1=0 \\ x_{2,3}=\pm {\tfrac {1}{3}}{\sqrt {5-2{\sqrt {\tfrac {10}{7}}}}} \\ x_{4,5}=\pm {\tfrac {1}{3}}{\sqrt {5+2{\sqrt {\tfrac {10}{7}}}}} $$
All of the values can be obtained from the Wikipedia article I've linked.
As a result of very complicated calculation (done with any computer program you like) we get:
Note, that the function is even, so we only need to use three points (!), two of them twice.
The exact value of the integral is:
$$\int_{-1}^{1} (e^{-x^{2}})dx = \sqrt{\pi} \text{erf} (1)=1.493648266 \dots$$
We've got a very good approximation.
You could also compute your Maclaurin series approximation to more digits and see how it measures up.