This is a neat application of a math puzzle that a teacher showed us in a college math class. The puzzle was to work out the probability of that toothpick intersecting a line when dropped. I was thrilled when I figured it out years later.

This is not a way of calculating pi. It is a way of estimating pi using a Monte Carlo-type method.

And yes, I am a grumpy pedant.

When Daddy steps on a toothpick and jams it up under his big toenail, you can learn new vocabulary too!

Everyone knows pi is 22/7. Donâ€™t need no toothpicks.

A much better pi is 355 / 113. Easy to remember: the inverse of 113/355. Good to more digits than youâ€™d expect.

Everyone knows pi is 245850922/78256779. Just as easy to remember as 3.14159265358979323846â€¦

I usually remember it as

3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 over 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.

Much easier to remember when the denominator is a clean power ten.

Probably would be a lot easier to simulate on a computer then. Of course, most of the library functions that would be called in such a simulation rely on M_PI in some way.

Came to this thread hoping to find someone reminding us this was a probabilistic approximation.

Was not disappointed

Usually one of the first things one does in a monte carlo class â€“ approximate pi.

Edit: first page of my monte carlo bookâ€¦

Hmm. I guess you donâ€™t really need more than sqrt(x).

Not if you use an infinite number of toothpicks, Mr Smarty.

3+ 1/(7 + 1/(15 +1/(1 +1/(292 +1/(1 +1/(1 +1/(1 +1/(2 +1/(1 +1/(3 +1/(1 +1/(14 +1/(2 +1/(1 +1/(1 +1/(2 +1/(2 +1/(2 +1/(2)))))))))))))) or thereaboutsâ€¦

I like this problem as an excellent example of a math problem that becomes easier when you generalize it. The more general problem is: if you have a curved piece of wire of length L, and you toss it on this floor (where the lines have spacing 1), whatâ€™s the expected number e(L) of lines crossed? First you argue that e(A+B)=e(A)+e(B), and from that and continuity, that e(A) = cA for some c. Then let L be a circle of diameter 1 to figure out that e(pi) = 2 (it crosses one line, twice). Hence e(1) = 2/pi, which was the original question.

Isnâ€™t a Monte Carlo a type of sandwich?

(*Monte Cristo, japhroaig!! Cristo!!*)

Thatâ€™s not a sandwich - thatâ€™s a heart-attack.

Donâ€™t we all agree here that you should be able to choose a death that is suitable for you?

A weapon of mass destruction that could be deployed in less than 45 minutes - let Tony Blair know.

A very good idea. I have decided that the most suitable death for me would be to die of a heart attack due to the sexual attentions of one of my many mistresses, while travelling on one of my sailing ships from one of the ports of my 2000-year-old empire to one of my holiday palaces, in or about the year 4016.

Perhaps I should start a kickstarter. Sandwich - lacks ambition.

and perfectly straight toothpicks and perfectly paralell lines. Possibly perfectly zero thickness too.

Oh, you can forget about pseudorandom generatorsâ€¦