For a time I am trying to solve this task:
Using Monte Carlo method, approximate the integral $\int_{-1}^{1}\int_{-1}^{1}x^{2}cos(y)dxdy$ using the given realizations of a random vector which has independent components uniformally distributed within the interval $[0;1]$: $$u_{1}=[0.90;0.36] \\ u_{2}=[0.66;0.08] \\u_{3}=[0.77;0.93] $$
I'm trying to solve this in the following way, knowing that the function in question is symmetric with respect to axes $x$ and $y$:
- I calculate the values of the function in points $u_{1}, u_{2}, u_{3}$: $$f(u_{1})=f(0.90,0.36)=0.758 \\ f(u_{2})=f(0.66,0.08)=0.434 \\ f(u_{3})=f(0.77,0.93)=0.354 $$
- I calculate the average value of the function $$f_{\phi}=0.515$$
- To get the value of the integral I multiply the average value with the area of the integration range $$\int_{-1}^{1}\int_{-1}^{1}f(x,y)dxdy=f_{\phi}*A=0.515*4=2.061$$
The result I get is wrong - it sgould be something around $1.12$. What am I doing wrong?
EDIT: I stumbled upon this kind of solution but have no idea where does it result from. We somehow change the variables of the integrated function with respect to the integration range. $$ u=\frac{x-a}{b-a}=\frac{x-(-1)}{1-(-1)} \to x=2u-1 \to \frac{du}{dx}=\frac{1}{2} \to dx=2du$$ $$ v=\frac{y-a}{b-a}=\frac{x-(-1)}{1-(-1)} \to y=2v-1 \to \frac{dv}{dy}=\frac{1}{2} \to dy=2dv$$
This leads to $$\int_{-1}^{1}\int_{-1}^{1}(2u-1)^{2}cos(2v-1)2du2dy$$ Following the same algorithmm as before, calculating values of the function $f(u,v)=(2u-1)^{2}cos(2v-1)$ in the points $u_{1}, u_{2}, u_{3}$, the avreage value multiplied by the area gives me the result of $1,164$ which is a good approximation of the integral.
