MPI Trapezoidal - 79135

Request Posted by
sdave92

sdave92

Rating : No Rating
Earned: $0
Request Detail
Price: $10
  • From: Computer Science, Programming
  • Due on: Mon 05 Dec, 2016 (02:35pm)
  • Asked on: Mon 28 Nov, 2016
  • Due date has passed, but you can still Post Solution.
Description
  1. Supposewetossdartsrandomlyatasquaredartboard,whosebullseyeisatthe origin, and whose sides are 2 feet in length. Suppose also that there’s a circle inscribed in the square dartboard. The radius of the circle is 1 foot, and it’s area is ? square feet. If the points that are hit by the darts are uniformly distributed (and we always hit the square), then the number of darts that hit inside the circle should approximately satisfy the equation

    number in circle = ? , total number of tosses 4

    since the ratio of the area of the circle to the area of the square is ?/4.
    We can use this formula to estimate the value of
    ? with a random number

    generator:

    number in circle = 0;
    for (toss = 0; toss < number of tosses; toss++) {

    x = random double between 1 and 1;
    y = random
    double between 1 and 1;
    distance squared = x
    ?x + y?y;
    if (distance squared <= 1) number in circle++;

    p} i estimate = 4?number in circle/((double) number of tosses);

page168image19888 page168image20048 page168image20208 page168image20368 page168image20528 page168image20688 page168image20848 page168image21008 page168image21168 page168image21328 page168image21488 page168image21648 page168image21808 page168image21968 page168image22128 page168image22288 page168image22448

This is called a “Monte Carlo” method, since it uses randomness (the dart tosses).

Write an MPI program that uses a Monte Carlo method to estimate ?. Process 0 should read in the total number of tosses and broadcast it to the other processes. Use MPI Reduce to find the global sum of the local variable number in circle, and have process 0 print the result. You may want to use long long ints for the number of hits in the circle and the number of tosses, since both may have to be very large to get a reasonable estimate of ?

1 Solution for MPI Trapezoidal
Title Price Category solution By purchased  
MPI_Toss as discussed
$1.00 Computer Science, C++ mariatutor 0 time(s)
Please Login or Register to Submit the Solution for the Request