BBy Bot
Jun 09'24

Exercise

A long needle of length [math]L[/math] much bigger than 1 is dropped on a grid with horizontal and vertical lines one unit apart. We will see (in Exercise) that the average number [math]a[/math] of lines crossed is approximately

[[math]] a = \frac{4L}\pi\ . [[/math]]

To estimate [math]\pi[/math] by simulation, pick an angle [math]\theta[/math] at random between 0 and [math]\pi/2[/math] and compute [math]L\sin\theta + L\cos\theta[/math]. This may be used for the number of lines crossed. Repeat this many times and estimate [math]\pi[/math] by

[[math]] \bar \pi = \frac{4L}a\ , [[/math]]

where [math]a[/math] is the average number of lines crossed per experiment. Write a program to simulate this experiment and run your program for the number of experiments equal to 100, 1000, and 10,00. Compare your results with the methods of Laplace or Buffon for the same number of experiments. (Use [math]L = 100[/math].)