Application Center - Maplesoft

App Preview:

Multi-Threaded Monte-Carlo Calculation of Pi

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


Image 

 

Multi-Threaded Monte-Carlo  

Calculation of Pi 

Introduction 

 

 

This worksheet calculates the value of Pi via a multi-threaded (and a single-threaded) Monte-Carlo algorithm.  Ntotal darts are randomly thrown at a unit square inscribed with a circle, and the number N that land within the circle  are counted.  The value of Pi is  

 

The fractional speed-up of the multi-threaded version over the single-threaded version is calculated.  Typically on a dual core computer, the speedup is about 30%. 

 

This application was created in Maple 13.02, and uses features that may not be available with earlier versions of Maple. 

Image 

 

>
 

Number of darts 

>
 

Generate random points in the unit square. 

>
 

>
 

Algorithm 

This procedure tallies the number of darts that land within the circle. 

>







 

Single-Threaded Timing 

>
 

 

 

 

 

78545
2.962
3.141800000 (3.1)
 

Multi-Threaded Extension and Timing 

>
 

>






 

>
 

 

 

 

 

78545
1.892
3.141800000 (4.1)
 

Speedup of Multi-Threaded Version over the Single-Threaded Version 

>
 

.3612424038 (5.1)
 

>  
 

 

 

Legal Notice: ? Maplesoft, a division of Waterloo Maple Inc. 2009. Maplesoft and Maple are trademarks of Waterloo Maple Inc. This application may contain errors and Maplesoft is not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact Maplesoft for permission if you wish to use this application in for-profit activities