Solving Pi for delicious fun

For fans of all other kinds of logic puzzles

Re: Solving Pi for delicious fun

Postby Mathimagics » Fri Dec 07, 2018 2:32 am

.
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!
User avatar
Mathimagics
2017 Supporter
 
Posts: 765
Joined: 27 May 2015

Re: Solving Pi for delicious fun

Postby StrmCkr » Fri Dec 07, 2018 11:23 am

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.
User avatar
StrmCkr
 
Posts: 889
Joined: 05 September 2006

Previous

Return to Other logic puzzles