Monte Carlo methods: Difference between revisions
Content added Content deleted
(→{{header|jq}}: give pc to three decimal places) |
|||
Line 1,515: | Line 1,515: | ||
<lang jq>def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .; |
<lang jq>def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .; |
||
def percent: "\( |
def percent: "\(100000 * . | round / 1000)%"; |
||
def pi: 4* (1|atan); |
def pi: 4* (1|atan); |
||
Line 1,541: | Line 1,541: | ||
Iterations -> Approx Pi -> Error |
Iterations -> Approx Pi -> Error |
||
---------- ---------- ------ |
---------- ---------- ------ |
||
10 2. |
10 2.8 10.873% |
||
100 |
100 3.28 4.406% |
||
1000 3. |
1000 3.172 0.968% |
||
10000 3. |
10000 3.1456 0.128% |
||
100000 3. |
100000 3.13316 0.268% |
||
1000000 3. |
1000000 3.139956 0.052% |
||
</pre> |
</pre> |
||