Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

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 Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions