$\int_0^1 e^{-x^2}dx$ a clever way to get an answer

156 Views Asked by At

So I am working on a problem, in that I need to integrate $\int_0^1 e^{-x^2}dx$.

So I did it in this way:

$$\int_0^1 e^{-x^2} dx=\int_0^1 \sum_{n=0}^\infty \frac{(-x^2)^{n}}{n!} = \sum_{n=0}^\infty \int_0^1 \frac{(-x^{2})^n}{n!} = \sum_{n=0}^\infty \frac{(-1)^{2n+1}}{(2n+1)n!}.$$

And then I need to calculate the $\sum_{n=0}^3 \frac{(-1)^{2n+1}}{(2n+1)n!}$ and it has to be equal to $1 - 1/3+1/10-1/42 = \frac{26}{35}$ ( this is the answer to the Problem !! )

Now to my Problem: I need to have $\sum_{n=0}^3 \frac{(-1)^{n}}{(2n+1)n!}$ such that I get my desired result.

I will be very happy, if you could tell me what i did wrong and how to get the result I want.

3

There are 3 best solutions below

1
On BEST ANSWER

Your solution is confusing and incorrect due to no use of brackets. Here's my solution.

We start by applying the power series expansion of $e^{-x^2}$.

$$\begin{align} \int_0^1 e^{-x^2}\, \mathrm dx &= \int_0^1 \left(\sum_{k=0}^{\infty}\dfrac{(-x^2)^k}{k!}\right)\, \mathrm dx \\ &= \sum_{k=0}^{\infty}\frac{(-1)^k}{k!}\int_0^1 x^{2k}\, \mathrm dx \\ &= \sum_{k=0}^{\infty}\dfrac{(-1)^k}{k!(2k+1)}\end{align}$$

Now, you can truncate the series till whatever value you want.

2
On

When you expand $e^{-x^2}$, you should get $(-x^2)^n = (-1)^n (x^2)^n = (-1)^n x^{2n}$ instead of $-x^{2n}$.

(By the way, the notation $-x^{2n}$ means $-(x^{2n})$. Maybe you actually mean $(-x)^{2n}$, but that's wrong too.)

(And by the way too, don't forget to write $dx$ in your integrals!)

0
On

A statistical approach: The Importance Sampling

Let's use the function $e^{-x}$ to approximate $p(x)=e^{-x^2}$

First let's derive a density function that is the normalized function of $e^{-x}$

$$f_X(x)=\frac{e}{e-1}e^{-x}\cdot\mathbb{1}_{(0;1)}(x)$$

with CDF

$$F_X(x)=y=\frac{e}{e-1}[1-e^{-x}]$$

Second, let's invert y finding

$$x=-\log\left[1-\frac{e-1}{e}y \right]$$

Now $y$ is a uniformly distributed in $(0;1)$ thus it is easy with any tool (also Excel is good for that) do to a random sampling from the uniform and our result will be the average of the ratios $\frac{p(x)}{f(x)}$

This is the result of a random sampling with size $n=1,000$

enter image description here

the result is very close to the correct value that is

$$\int_0^1 e^{-x^2}dx=\sqrt{\pi}\left[ \Phi(\sqrt{2})-\frac{1}{2} \right]\approx 0.7468$$