Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the MATLAB Code that uses the Monte Carlo method to estimate pi and also determines the difference between estimate and true vale: a=10; %

Given the MATLAB Code that uses the Monte Carlo method to estimate pi and also determines the difference between estimate and true vale:

a=10; % the experiment event number r=1; %the circle radius c=0; % sucessful event number for i=1:a s=-r+1*r*rand(); t=-r+1*r*rand(); pi_sim(i)=4*c/a pi_diff(i)=pi-pi_sim(i) if ((s.^2+t.^2)<=r^2) c = c+1 end end

Question: Edit the code using a "while" loop to compute pi to a fixed level of precision (i.e. 2 significant figures, 3 significant figures, etc). Note how many steps are required for each level of precision. Your determination of the level of precision should NOT include a reference to the true value of pi.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. -2 dx 3/2 (4 ?)92

Answered: 1 week ago