1 / 13

Lazzarini, Buffon’s needle, and Pi

Lazzarini, Buffon’s needle, and Pi. Buffon’s needle. From http://mathworld.wolfram.com/BuffonsNeedleProblem.html .

purity
Download Presentation

Lazzarini, Buffon’s needle, and Pi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lazzarini, Buffon’s needle, and Pi

  2. Buffon’s needle • From http://mathworld.wolfram.com/BuffonsNeedleProblem.html. • Buffon's needle problem asks to find the probability that a needle of length l will land on a line, given a floor with equally spaced parallel lines a distance d apart. The problem was first posed by the French naturalist Buffon in 1733, and reproduced with solution by Buffon in 1777.

  3. Buffon’s needle

  4. Buffon’s needle • It turns out that if we toss a needle of length ln times and count the h number of times that it touches a line, we find that this is related to Pi as follows:

  5. Buffon’s needle • This figure shows the result of 500 tosses of a needle of length parameter x=1/3, where needles crossing a line are shown in red and those missing are shown in green. 107 of the tosses cross a line, giving an estimate for Pi of 3.116.

  6. Lazzarini’s estimate(from http://en.wikipedia.org/wiki/Pi_through_experiment) Lazzarini's estimate Mario Lazzarini, an Italian mathematician, performed the Buffon's needle experiment in 1901. Tossing a needle 3408 times, he attained the well-known estimate 355/113 for π, which is a very accurate value, differing from π by no more than 3×10−7. This is an impressive result, but is something of a cheat. Lazzarini chose needles whose length was 5/6 of the width of the strips of wood. In this case, the probability that the needles will cross the lines is 5/3π. Thus if one were to drop n needles and get x crossings, one would estimate π as π ≈ 5/3 · n/x π is very nearly 355/113; in fact, there is no better rational approximation with fewer than 5 digits in the numerator and denominator.

  7. Rational approximation to Pi • π is very nearly 355/113; in fact, there is no better rational approximation with fewer than 5 digits in the numerator and denominator. • Given the above, how can we demonstrate that 355/113 is the best?

  8. Algorithm • Use an int variable for the numerator. • Initialize it to 1. • Use an int variable for the denominator. • Initialize it to 1. • Calculate • 1/1, 1/2, 1/3, …, 1/N • 2/1, 2/2, 2/3, …, 2/N • … • N/1, N/2, N/3, …, N/N • While doing the above, remember the best.

  9. /* * file : Lazzarini.java * author: george j. grevera, ph.d. * desc. : program to determine best rational * approximation to Pi. */ public class Lazzarini { public static void main ( String[] s ) { //declare variables final int N = 9999; for (int num=1; num<=N; num++) { for (int denom=1; denom<=N; denom++) { double temp = (double)num / denom; double diff = Math.abs( Math.PI-temp ); } } } }

  10. Algorithm • We need a way to remember the best numerator and denominator so far. • When we find something better, we need to update the best so far. • At the end, we need to report the best that we found.

  11. /* * file : Lazzarini.java * author: george j. grevera, ph.d. * desc. : program to determine best rational approximation to Pi. */ public class Lazzarini { public static void main ( String[] s ) { //declare variables final int N = 9999; int bestNum = 1; int bestDenom = 1; double best = Math.abs( Math.PI - (double)bestNum / bestDenom ); for (int num=1; num<=N; num++) { for (int denom=1; denom<=N; denom++) { double temp = (double)num / denom; double diff = Math.abs( Math.PI-temp ); } } System.out.println( "best = " + bestNum + "/" + bestDenom ); } }

  12. /* * file : Lazzarini.java * author: george j. grevera, ph.d. * desc. : program to determine best rational approximation to Pi. */ public class Lazzarini { public static void main ( String[] s ) { //declare variables final int N = 9999; int bestNum = 1; int bestDenom = 1; double best = Math.abs( Math.PI - (double)bestNum / bestDenom ); for (int num=1; num<=N; num++) { for (int denom=1; denom<=N; denom++) { double temp = (double)num / denom; double diff = Math.abs( Math.PI-temp ); //we need to do the update of best so far here } } System.out.println( "best = " + bestNum + "/" + bestDenom ); } }

  13. /* * file : Lazzarini.java * author: george j. grevera, ph.d. * desc. : program to determine best rational approximation to Pi. */ public class Lazzarini { public static void main ( String[] s ) { //declare variables final int N = 9999; int bestNum = 1; int bestDenom = 1; double best = Math.abs( Math.PI - (double)bestNum / bestDenom ); for (int num=1; num<=N; num++) { for (int denom=1; denom<=N; denom++) { double temp = (double)num / denom; double diff = Math.abs( Math.PI-temp ); if (diff < best) { best = diff; bestNum = num; bestDenom = denom; } } } System.out.println( "best = " + bestNum + "/" + bestDenom ); } }

More Related