parPi code

February 17, 2009

The current code for the Parallel Pi program:

#include <stdio.h>
int main(){
 double numOfSteps=1000000000;
 double deltaX=2/numOfSteps;
 double x;
 double piSum=0;
 for(x=-1;x<=1;x=x+deltaX){
  piSum=piSum+deltaX*sqrt(1-x*x);
 }
 piSum=piSum*2;
 printf(“%.30f\n”,piSum);
 return 0;
}

The program uses Euler’s method to evaluate the integral

 2*(1-x^2)^(1/2)dx from x=-1 to 1, which equals pi.

The output of the program is 3.141592621098947990532224139315 which is accurate to 8 decimal places and took 7 seconds to run (without parallel processing).

Goals for project

February 17, 2009

My goals for project #1:
a) switch from “Java” to “c” programming
b) learn to use multiple processors in parallel for large calculations
This program will calculate the number Pi as quickly and accurately as possible.

Purpose

February 17, 2009

The purpose of this blog is to show current progress in my CSUMS project.


Follow

Get every new post delivered to your Inbox.