
-----------------------------------
PaulButler
Tue Jul 10, 2007 11:07 am

Approximation of pi
-----------------------------------
I was playing around in C++ and decided to write a program to approximate pi using a Riemann sum for the area of a semicircle (it's easier than it sounds; a simple explanation is below the code)


#include 
#include 
#include 
#include 

using namespace std;

double pi_approx(int accuracy){
	double area = 0.;
	double h = (1. / accuracy);
	
	for(int x = 1; x  i;
	assert(i >= 10);
	double pi = pi_approx(i);
	cout 