## Solving Pi for delicious fun

For fans of all other kinds of logic puzzles

### Re: Solving Pi for delicious fun

.
Back to Pi, nobody seems to have mentioned the "Dartboard Method":

Assuming we have a floating-point random number generator that returns values < 1.0, we simply iterate with

• N = N + 1
• X = rand() * 2 - 1
• Y = rand() * 2 - 1
• D = sqrt(X*X + Y*Y)
• if (D <= 1.0) B = B + 1

The dartboard is a target circle of radius 1 (area PI) in a square of size 2 (area 4). So probability of random throws hitting the circle is PI/4, and thus (4B / N) is an approximation to PI for N sufficiently large.

Convergence is well, shall we say, a tad sluggish. But for algorithmic elegance, it's hard to beat!

Mathimagics
2017 Supporter

Posts: 1615
Joined: 27 May 2015
Location: Canberra

### Re: Solving Pi for delicious fun

Heres another food for thought idea, the radial Arm that's at the center of the polygonal lenght that I use where the polygonal straight line that determines circumference shrinks the more cords are added by a power function the shrinkage is where rounding errors occur. Instead of shrinking we can also expand the length of arm so that the side length remains constant but the number of folds increases as a circle expands to equate to the same side length of the polygon

Where folds = number of radial partitions in 90 degrees.

The trick then would be to have a starting point of an even number for cord length and polygon side length that have no rounding errors and expanding the cord length per fold increasing the Diameter of the circle infinity which is the same as zooming as expanding outward to see the object further gives the appearance it is 100% round..

Then we have a non rounding error calculation for a periodic fluctuation for nth folds in relation to its Diameter. If u figure out what I'm attempting to say....
Code: Select all
`--------------  \   |   /   \  |  /    \ | /     \ / `

Code: Select all
`{only difference in calculation is the length of the arm changed top straight edge remains the same} -------------- \    |    /  \   |   /   \  |  /    \ | /     \ / `
Some do, some teach, the rest look it up.

StrmCkr

Posts: 1205
Joined: 05 September 2006

Previous