


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Purpose The purpose of this assignment is to familiarize you with the Monte Carlo Method of Integration, as well as 3-D plotting in MATLAB. This homework has two parts. Note that you need to hand in three MATLAB functions. You also should print out the figure generated and hand it in as a written part of the homework. Make sure that your figure includes the appropriate settings described below and that you do not rotate/translate your final graph in any way. Assignment In this assignment you are asked to use the Monte Carlo method to compute the volume of the interior of a surface given as follows:
(1 − x^2 )(4 − x^2 ) + y^2 + z^2 = 0 (1)
In order to complete the assignment you need to construct a 3-dimensional box surrounding the surface, and generate n random points in the box. Next, you approximate the volume of the interior by computing the fraction of points which lie inside the surface and multiplying this fraction by the volume of the entire box. Once you have computed this volume, you are asked to provide a plot of your work. Part 1: Code You need to write and turn in the following 3 functions:
Part 2: Generating Output Test your volume function using n = 1000 points on a 3D square box where − 2 ≤ x ≤ 2, − 1. 5 ≤ y ≤ 1 .5, and − 1. 5 ≤ z ≤ 1 .5. Your figure should display the shape, the box, and the points inside and outside the shape as stated above. In the window displaying the figure, click on “Save as”, and in the dialog that pops up make sure that in “Save as type” is set to “Portable Network Graphics file (*.png)”, and name the file as {your NetID}.png. Email this file
Place it in the same directory in which your three function files are located. Run the checker from inside MATLAB by typing CheckMP7 at the command prompt.
The checker will test your volume function, and if it is correct, it will submit an email containing your three functions to the TA. You should get a vacation response email from the TA’s mail account confirming that the email was received. Multiple submissions are now perfectly fine, and the maximum grade of all submissions will be counted. The function must work exactly to our specifications; no partial credit will be given.
And lastly, don’t forget to email a PNG file of your figure to [email protected] (do NOT send it to any other account). You should receive two confirmation mails: one for the code, and one for the graph.