Monte-Carlo Method: Estimating Pi

 

 

 

The link below describes the steps involved in the computing the value of Pi using the Monte Carlo method:

 

·       http://polymer.bu.edu/java/java/montepi/MontePi.html

 

Write a program that estimates the value of Pi using the Monte Carlo method as described in the above link. You can assume the square (and the circle within) are located in the first quadrant of the X-Y coordinate system.

 

Inputs to your program:

·       The side of the square – a real number

·       The number of runs – an integer

 

Example:

Monte Carlo - Estimating Pi

Input the side of the square

1000

Input the number of trials

1000000

 

Value of Pi = 3.140824