Using the Monte Carlo method to find a volume

641 Views Asked by At

Use the Monte Carlo method to find the volume of intersection of, three cylinders, all of radius 3 units and infinite in length,with the axis of the first cylinder being the x-axis, the axis of the second cylinder being the y-axis and the axis of the third cylinder being the line with points (1; 1; z) where z belongs to R(any real number).

I have no idea how to do this on MATLAB. Any help, hints would be appreciated. Thank you so much!

1

There are 1 best solutions below

0
On

See my comment above and check my math below. The bounding inequalities $y^2+z^2\leq 9,$ $x^2+z^2\leq 9,$ and $(x-1)^2 + (y-1)^2 \leq 9.$, taken together imply your region lies in a sphere $(x-0.5)^2 + (y-0.5)^2 + z^2 \leq 13.$ This means the region lies within a box, say $[-3.5,4.5] \times [-3.5,4.5] \times [-4,4]$ (I used a radius of 4 rather than $\sqrt{13}$) Draw uniform random numbers (one each for x,y,z) in this box. If they satisfy all three bounding inequalities, then the point lies in the region.

One further hint: $r=a+(b-a)*rand()$ generates a uniformly distributed pseudo random number between $a$ and $b$