[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]


Problem DescriptionThe other day someone told me that the probability that any randomly
chosen pairs of integers are relatively prime is an interesting number. Background & TechniquesI can't remember where I ran across this hypothesis. Nor have I been able to find the math, or even a rationale as to why it might be true. But it does appear to be. We'll get a number of random pairs to check from the user and then loop that many times counting the number that are relatively prime. At the end of the loop, the Pi estimate is calculated as the SQRT(6*NbrPairs / NbrPairsRelativelyPrime). Saying that two numbers are relatively prime is the same as saying that their greatest common divisor is 1. We'll use a simple GCD function to check for relative primeness. For more info you can check this GCD Math Topic The usual features of my programs with potentially long loops are here:
And in case you want to try several million samples, results are accumulated and the cumulative estimate also displayed with each run. Running/Exploring the Program
Suggestions for Further ExplorationsCheck out series summing methods which give much better estimates much faster than random sampling methods. The best of the known algorithms for calculating Pi is the Borwein quartically convergent algorithm and has been used to calculate the first 200 billion digits of Pi. Each iteration adds several hundred digits of accuracy. The whole "Pi digits" exercise may be mathematically pleasing but probably has little real world application. The first 39 digits of PI were calculated 350 years ago. That is accurate enough to calculate the circumference of a circle 40 billion light years in diameter with a error of less than the width of one hydrogen atom! I'd say that 39 digits is sufficient for all practical purposes. 
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 20002017, Gary Darby All rights reserved. 