Matlab code, approximate an integral using Monte-Carlo method.

236 Views Asked by At

so i have to program the approximation of these two integrals using Monte-Carlo method: $$\int\int_D e^{x^2+y^2} \, dy \, dx $$ $$D=\{(x,y) \in \Bbb R \mid x^2+y^2\le9\}$$ and: $$\int_0^2 \int_{-1}^1\int_0^1 2x+3y+z \,dz \, dy \, dx$$ Can someone help me please? I don't know where to start because I can't understand my teacher.

1

There are 1 best solutions below

0
On

The integral $\int\int_Ae^{x^2+y^2}dA$ gives the volume of a solid. It's easy to see that this solid is contained in the cylinder centered at the origin of radius $3$ with height $e^9$.

The Monte Carlo method challenges us to find a way to sample points uniformly from the interior of this cylinder. The fraction of these points which also happen to fall within our solid will then tell us what fraction of the cylinder's volume does our solid take up. Then to get the solid's volume we need only multiply this fraction by the cylinder's volume (which is easy to find).

Probably the most straightforward way to sample points uniformly from this cylinder would be to use rejection sampling.