"My computer tells me that π is *approximatively*"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.141592653589793\n"
]
}
],
"source": [
"from math import *\n",
"print(pi)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Buffon’s needle"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Applying the method of <a href=\"https://en.wikipedia.org/wiki/Buffon%27s_needle_problem\" target=\"_blank\">Buffon's needle</a>, we get the approximation."
"A method that is easier to understand and does not make use of the sin function is based on the\n",
"fact that if $X\\sim U(0,1)$ and $Y\\sim U(0,1)$, then $P[X^2 + Y^2 \\leq 1] = \\pi/4$ (see <a href=\"https://en.wikipedia.org/wiki/Monte_Carlo_method\" target=\"_blank\">\"Monte Carlo method\"\n",
"on Wikipedia</a>). The following code uses this approach: "