So, I came across a pretty neat trick on the internet the other day, called the Buffon’s Needle problem. The way the problem goes is, if you set up a various amount of vertical lines that are 2 match lengths apart, and then randomly spread out the matches, then take the total number of matches and divide that number by the number of matches that cross one of the aforementioned vertical lines, the result should be close to pi. I’m not going to go into the underlying calculus regarding how the trick works on this post, but I thought it was an interesting enough problem that I wanted to see how accurate the idea was through programming.

After a few hours, I created an interactive application in HTML5 and javascript which does all of the math involved in the problem, and allows you to adjust the amount of matches to see how much more accurate the pi estimation gets when you increase or decrease the number.

The project can be seen here.

### Like this:

Like Loading...