Alternate formulas for calculating area of a circle??

Discussion in 'Physics & Math' started by Jason.Marshall, Dec 15, 2014.

  1. Jason.Marshall Banned Banned

    Messages:
    654
    I apologize for the violation of the rules now I am aware, there is an apparent importance to this "H" I though you would seen it already...
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. danshawen Valued Senior Member

    Messages:
    3,951
    You don't need a formula at all to calculate the area of a circle with "shotgun integration". Just plot enough truly random, normalized pairs of coordinates within a square area surrounding the circle. The ratio of the number falling inside the circle to the total number of points is proportional to the circle's area. Not accurate enough? Just use more points. Provided the points are randomized enough and you use enough of them, you can easily exceed any general formula estimate given here that does not include using pi to a greater degree of accuracy than the number of random data points.
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. rpenner Fully Wired Valued Senior Member

    Messages:
    4,833
    That's not calculation, but rather estimation, and you need on the order of \(100^n\) points to reduce the variance of your estimate until you have a degree of certainty of n digits.

    For example, if I make 10,000 trials I expect to get roughly \(7854 \pm 41\) successes which would estimate pi somewhere between 3.1252 and 3.1580 even with perfectly uniform and random numbers. 99% of the time, the number of successes would be between 7747 and 7959, which means about 1% of the time 10,000 trials my estimate of pi would not be constrained between 3.0988 and 3.1836.
     
    Last edited: Dec 24, 2014
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. leopold Valued Senior Member

    Messages:
    17,455
    a couple of fractions for an approximation of pi: (to 6 places)
    22/7=3.142857, not very accurate
    a more accurate fraction:
    355/113=3.141592, the next digit is 9
    accurate to .0000003
     
  8. rpenner Fully Wired Valued Senior Member

    Messages:
    4,833
    Correct -- both are as good as you can do with a denominator that size or smaller.

    That's because \(\pi = 3 + \frac{1}{7 + \frac{1}{15 + \frac{1}{1 + \frac{1}{292 + \frac{1}{1 + \frac{1}{1 + \frac{1}{1 + \frac{1}{2 + \dots}}}}}}}}\) and truncating this expansion gives you various "best-of-their-kind" rational approximations:

    \(3 \lt 3 + \frac{1}{7 + \frac{1}{15}} \lt 3 + \frac{1}{7 + \frac{1}{15 + \frac{1}{1 + \frac{1}{292}}}} \lt \pi \lt 3 + \frac{1}{7 + \frac{1}{15 + \frac{1}{1}}} \lt 3 + \frac{1}{7} \)
    or
    \(3 \lt \frac{333}{106} \lt \frac{103993}{33102} \lt \pi \lt \frac{355}{113} \lt \frac{22}{7} \)

    Since for non-negative x, the fraction \(\frac{a + b x}{c + d x}\) is intermediate between \(\frac{a}{c}\) and \(\frac{b}{d}\), we can make lots of intermediates between numbers that straddle pi and some will come even closer. And that's part of how these "continued fractions" work. Here's how that 292 indicates how to interpolate between \(\frac{333}{106}\) and \(\frac{355}{113}\):
    \(\frac{103993}{33102} = \frac{333 + 355 \times 292}{106 + 113 \times 292} \lt \pi \lt \frac{333 + 355 \times 293}{106 + 113 \times 293}\)

    This isn't calculating pi, but showing how the infinite continued fraction expansion can give successive approximations to pi just like the infinite decimal digit expansion can. As pi is irrational, both go on forever. Nor does either have an easy pattern to the sequence of numbers/digits.
     
  9. leopold Valued Senior Member

    Messages:
    17,455
    PI to 1.25 million places.
    open the page in firefox and scroll past all the mumbo jumbo.
    scrounged from the archive.
     

    Attached Files:

    • PI.zip
      File size:
      680.1 KB
      Views:
      0
    Last edited: Dec 24, 2014
  10. danshawen Valued Senior Member

    Messages:
    3,951
    I performed this calculation (shotgun integration) using FORTRAN on a Univac 1108 at the UofMD in the 1970s. I was impressed by how rapidly it converged to the value of pi. I only used 1,000 random data points, and already it came out to 3.142, as I recall. Of course the points actually need to be random. Later in my satellite telecom career, I became acquainted with the work of Donald Knuth when a complex statistical analysis surfaced that required us to determine if there was something wrong with our randomization algorithm. There wasn't, and we repaired the problem by running some new tests, with a new number as a seed. You need to do this if your sequences are only pseudorandom, and you use them for essentially the same tests more than just once.
     
  11. rpenner Fully Wired Valued Senior Member

    Messages:
    4,833
    Well your memory is wrong, your random number generator was faulty or you were very lucky.

    It's not clear how you got 3.142 since \(3.142 = 4 \times \frac{7855}{10000}\) which undermines your story that you ran only 1000 points and at some point you would have to divide a number less than 1000 by 1000 if you did the calculation as you said.

    In python, a scripting language that is vendor-supplied for many Unix and Macintosh systems and is free for most others, the test is simply written:
    Code:
    #!/usr/bin/python
    import random
    
    radius = 1
    side = 2 * radius
    area = side ** 2
    rnd = random.Random()
    n = 20
    m = 1000
    
    for s in xrange(n) :
      sum = 0
      for t in xrange(m) :
          x = rnd.uniform(-radius,radius)
          y = rnd.uniform(-radius,radius)
          if ( x**2 + y**2 <= 1 ) :
            sum += 1
      print area * float(sum) / m / radius ** 2
    which produces as output:
    Code:
    3.204
    3.116
    3.196
    3.224
    3.044
    3.188
    3.096
    3.132
    3.172
    3.076
    3.184
    3.26
    3.208
    3.176
    3.188
    3.06
    3.156
    3.148
    3.16
    3.128
    giving an estimate of pi of \(3.156 \pm 0.056\) which is in good agreement with the model prediction of \(\pi \pm \sqrt{\frac{\pi ( 4 - \pi)}{1000}} \approx 3.142 \pm 0.052\).
     
    Last edited: Dec 24, 2014
  12. rpenner Fully Wired Valued Senior Member

    Messages:
    4,833
    Of course, x**2 + y**2 <= 1 should read "x**2 + y**2 <= radius**2" in the above. I missed that in the edit to make the variables more descriptive. Since radius = 1, it's of no immediate consequence.
     
  13. leopold Valued Senior Member

    Messages:
    17,455
    the only true random number source would be a "white noise" generator.
    i'm not sure if such a thing was available in the 70s, and he DOES mention "pseudorandom".
     
  14. rpenner Fully Wired Valued Senior Member

    Messages:
    4,833
    Yes. But the python implementation used a famously well-tested pseudorandom number generator:
    https://docs.python.org/2.7/library/random.html
    http://en.wikipedia.org/wiki/Mersenne_twister
     

Share This Page