Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: Compute the Value of Pi Write a parallel program to calculate using the Monte Carlo method. The process is as follws: randomly located

Problem 2: Compute the Value of Pi
Write a parallel program to calculate using the Monte Carlo method. The process is as follws:
randomly located points are generated within a 22 square which has a circle inscribed within it.
The algorithm generates a large number of points and checks to see if the coordinates, x and y, of
each point are inside the circle- x2+y21. The ratio, P, of points inside the circle to the total number
of points tried is calculated. Using this ratio, the approximation of can be computed by assuming
that P approaches the value of ratio of the area of the circle to the area of the square when the
number of points, niter, is large. Thus we can say: P= (r)/4r = /4 and solve for . To do this, P
is multiplied by 4 and the result is an approximation of .
Use a total number of iterations N=10000000. In your program, the iterations are divided among
the available processes such that each process will run a subset of these iterations in parallel. Each
process will compute the number of points that it has found inside the circle and report the results
back to the master. The master will aggregate the results to compute the approximate value of pi.
Hint:
To generate a random number in the range [0,1] in C:
//First set the seed for the random number generator (Each
process should have a different seed)
srand(rank+1);
//Next generate a random number in the range [0,1]
Double x=((double)rand())/RAND_MAX;

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 Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

How owners select and procure their construction services

Answered: 1 week ago

Question

What is a break-even point?

Answered: 1 week ago