Pi Day – approximation in R

To celebrate pi day with my school I created a function to compute an approximation for pi.  It seems R has a maximum digit preference of 16 digits by default.  Here is my code:



I used the format command to control how many digits were produced by the approximation, but the maximum output seems to be 16.  I used the following command to run the program and find the first 16 correct digits of pi.

This computation took miliseconds to compute in R.  It took mathematicians without computer capabilities years to compute this approximation accurately.  I wonder if there is some way to make R compute this more precisely?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s