# Integration using Monte-Carlo method

1. May 13, 2012

### Pzi

1. The problem statement, all variables and given/known data
Integrate using Monte-Carlo method and evaluate absolute error.
$$\int\limits_1^{ + \infty } {\frac{{\sqrt {\ln (x)} }}{{{x^5}}}dx}$$

2. Relevant equations
Everything about Monte-Carlo integration I guess.

3. The attempt at a solution
$$I = \int\limits_1^{ + \infty } {\frac{{\sqrt {\ln (x)} }}{{{x^5}}}dx} = \int\limits_{\pi /4}^{\pi /2} {\frac{{\sqrt {\ln (\tan (t))} }}{{{{(\tan (t))}^5} \cdot {{(\cos (t))}^2}}}dt}$$

I define random variable Y so that its mean would be equal to my integral I.
$${y_k} = \left( {\frac{\pi }{2} - \frac{\pi }{4}} \right) \cdot \frac{{\sqrt {\ln (\tan ({t_k}))} }}{{{{(\tan ({t_k}))}^5} \cdot {{(\cos ({t_k}))}^2}}} = \frac{{\pi \sqrt {\ln (\tan ({t_k}))} }}{{4{{(\tan ({t_k}))}^5} \cdot {{(\cos ({t_k}))}^2}}}$$
$${t_k} = \left( {\frac{\pi }{2} - \frac{\pi }{4}} \right) \cdot {r_k} + \frac{\pi }{4} = \frac{\pi }{4}\left( {{r_k} + 1} \right)$$
r_k - equally likely random numbers between 0 and 1.

I then proceed using 55 random numbers to calculate my approximation.
$${\hat I_n} = \frac{1}{n}\sum\limits_{k = 1}^n {{y_k}}$$
$$I \approx {\hat I_{55}} = \frac{1}{{55}}\sum\limits_{k = 1}^{55} {{y_k}} = 0.{\rm{113481}}$$

What about absolute error? It is meant to be like "it is very likely (probability over 0.9 or whatever) that our approximation missed the actual value by no more than *ERROR NUMBER*".
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. May 13, 2012

### Dickfore

$$t = \sqrt{\ln x} \Rightarrow x = e^{t^2}, dx = 2 \, t \, e^{t^2} \, dt$$
$$\frac{\sqrt{\ln x}}{x^5} \, dx = t \, e^{-5 t^2} \, 2 \, t \, e^{t^2} \, dt = 2 \, t^2 \, e^{-4 t^2} \, dt$$
$$x = 1 \Rightarrow t = 0, \ x \rightarrow \infty \Rightarrow t \rightarrow \infty$$
So, your integral is equivalent to:
$$I = 2 \, \int_{0}^{\infty}{t^2 \, e^{-2 t^2} \, dt} = -2 \, \frac{d}{d a} \left(\int_{0}^{\infty}{e^{-a t^2} \, dt} \right) \vert_{a = 4} = - 2 \, \frac{d}{d a} \left( \frac{1}{2} \, \pi^{\frac{1}{2}} \, a^{-\frac{1}{2}} \right) \vert_{a = 4} = \frac{1}{2} \, \pi^{\frac{1}{2}} \, 4^{-\frac{3}{2}} = \frac{\sqrt{\pi}}{16} \approx 0.110778\ldots$$

EDIT:
See exact result:
http://www.wolframalpha.com/input/?i=Integrate[Sqrt[Log[x]]%2Fx^5%2C{x%2C1%2CInfinity}]

Last edited: May 13, 2012
3. May 13, 2012

### Pzi

It is necessary for me to use Monte-Carlo method for this one.

4. May 13, 2012

### Dickfore

Because your integrand is given by the estimation of the mean:
$$I = \mu_{Y}$$
of a random variable:
$$Y(X) = \frac{\sqrt \ln \tan X}{\tan^{5} X \, \cos^{2} X}$$
when $X \in \mathcal{U}(\pi/4, \pi/2)$ is uniformly distributed, by taking the arithmetic average:
$$\mu_{Y} \approx \frac{1}{n} \, \sum_{k = 1}^{n}{f(X_k)}$$
you may esitmate your error by the error propagation formula:
$$\sigma^{2}_{\mu_Y} = \sum_{k = 1}^{n}{\left( \frac{\partial \mu_Y}{\partial X_k} \right)^{2} \, \sigma^{2}_{X_k}}$$
where the derivative is:
$${\partial \mu_Y}{\partial X_k} = \frac{1}{n} \, f'(X_k)$$

1. Find the derivative $dY/dX$, and estimate it at $E(X) = \frac{\frac{\pi}{4} + \frac{\pi}{2}}{2} = \frac{3 \pi}{8}$. Let us call it A;

2. What is the variance of X $\sigma^{2}_{X}$, when $X \in \mathcal{U}(\pi/4, \pi/2)$ is uniformly distributed with the given limits. Let us call this number $\sigma^2$.

3. Then, using the above values, your error propagation formula becomes:
$$\sigma^{2}_{\mu_Y} = \sum_{k = 1}^{n}{\left( \frac{A}{n} \right)^{2} \, \sigma^{2}} = \frac{A^2 \, \sigma^2}{n}$$

The error in the mean is then $\sigma_{\mu_Y}$. This is a very general formula that holds for any Monte-Carlo evaluation. Notice that it is inversely proportional to the square root of the number of sample points. It is proportional to both the absolute value of the derivative $A = \vert Y'(X = E X) \vert$, and the standard deviation of the independent variable $\sigma_{X}$.