From c005bd82c84a2fdbc8eff7fe1542f99cf0be77bd Mon Sep 17 00:00:00 2001 From: Tommy Rushton Date: Wed, 10 Apr 2024 10:22:53 +0200 Subject: [PATCH] Bring things closer into line with target notebook. --- module2/exo1/toy_document_orgmode_python_en.org | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/module2/exo1/toy_document_orgmode_python_en.org b/module2/exo1/toy_document_orgmode_python_en.org index 52dc9e7..1184cc3 100644 --- a/module2/exo1/toy_document_orgmode_python_en.org +++ b/module2/exo1/toy_document_orgmode_python_en.org @@ -1,4 +1,4 @@ -#+TITLE: On the computation of pi +#+TITLE: On the computation of pi #+LANGUAGE: en #+HTML_HEAD: @@ -8,12 +8,10 @@ #+HTML_HEAD: #+HTML_HEAD: -# #+PROPERTY: header-args :eval never-export - -* Table of Contents +# #+PROPERTY: header-args :session :exports both * Asking the math library -My computer tells me that \pi is /approximatively/ +My computer tells me that $\pi$ is /approximatively/ #+begin_src python :results value :session :exports both from math import * @@ -24,8 +22,7 @@ pi : 3.141592653589793 * * Buffon's needle -Applying the method of -[[https://en.wikipedia.org/wiki/Buffon%2527s_needle_problem][Buffon's needle]] we get the *approximation* +Applying the method of [[https://en.wikipedia.org/wiki/Buffon%2527s_needle_problem][Buffon's needle]], we get the *approximation* #+begin_src python :results value :session :exports both import numpy as np @@ -42,10 +39,7 @@ theta = np.random.uniform(size=N, low=0, high=pi/2) * Using a surface fraction argument A method that is easier to understand and does not make use of the -$\sin$ function is based on the fact that if $X ~ U(0,1)$ and $Y ~ -U(0,1)$, then $P[X^2 + Y^2 \leq 1] = \pi/4$ (see -[[https://en.wikipedia.org/wiki/Monte_Carlo_method]["Monte Carlo -Method" on Wikipedia]]). The following code uses this approach: +$\sin$ function is based on the 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 [[https://en.wikipedia.org/wiki/Monte_Carlo_method]["Monte Carlo Method" on Wikipedia]]). The following code uses this approach: #+begin_src python :results output file :session :var matplot_lib_filename="figure_pi_mc2.png" :exports both import matplotlib.pyplot as plt -- 2.18.1