DONE somepart of ittttttttttttttt!!!

parent 7100bd90
...@@ -14,40 +14,66 @@ ...@@ -14,40 +14,66 @@
"<h4 style=\"text-align: center;\"> March 28, 2019 </h4>" "<h4 style=\"text-align: center;\"> March 28, 2019 </h4>"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. A propos du calcul de $\\pi$\n",
"\n",
"### 1.1. En demandant à la lib maths \n",
"Mon ordinateur m'indique que $\\pi$ vaut *approximativement*\n"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 1,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"1\n" "3.141592653589793\n"
] ]
} }
], ],
"source": [ "source": [
"x=1\n", "from math import *\n",
"print(x)" "print(pi)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2. En utilisant la méthode des aiguilles de Buffon \n",
"\n",
"Mais calculé avec la **méthode** des [aiguilles de Buffon](http://fr.wikipedia.org/wiki/Aiguille_de_Buffon), on obtiendrait comme **approximation** :\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "data": {
"output_type": "stream", "text/plain": [
"text": [ "3.128911138923655"
"[1] 1\n" ]
] },
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"x=1\n", "import numpy as np \n",
"print(x)" "np.random.seed(seed=42) \n",
"N = 10000 \n",
"x = np.random.uniform(size=N, low=0, high=1) \n",
"theta = np.random.uniform(size=N, low=0, high=pi/2) \n",
"2/(sum((x+np.sin(theta))>1)/N)\n"
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment