How do I approximate the following integral value by numerical methods.

353 Views Asked by At

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.

3

There are 3 best solutions below

1
On BEST ANSWER

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:

$$\int_{-1}^{1} (e^{-x^{2}})dx \approx 1.493663921 \dots$$

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.

3
On

As far as I can see, your work is correct, though I didn't check the arithmetic. You do have to compute the integral numerically, so far as I know. I don't think there's any way to get a closed-form formula. Wolfram Alpha gives $1.49365.$ If you haven't run across Wolfram Alpha yet, you should get acquainted with it. It's a valuable tool for checking your work.

1
On

This is not related to the approach you are asked to follow to approximate $J=\int_{0}^{1}e^{-x^2}\,dx=\frac{\sqrt{\pi}}{2}\text{Erf}(1)$, but an effective approach is given by Beuker-type integrals. By integration by parts

$$ \int_{0}^{1}x^4(1-x)^4 e^{-x^2}\,dx = -16+\frac{93}{16 e}+\frac{297}{16}J\tag{1} $$ where the LHS is clearly bounded between $0$ and $\frac{1}{4^4}$. It follows that $$ J \approx \frac{1}{297} \left(256-\frac{93}{e}\right) = \color{green}{0.746}758\ldots \tag{2} $$ where the absolute error of this approximation does not exceed $2.2\cdot 10^{-4}$.