Monte Carlo methods: Difference between revisions

→‎{{header|jq}}: give pc to three decimal places
(→‎{{header|jq}}: give pc to three decimal places)
Line 1,515:
<lang jq>def lpad($len): tostring | ($len - length) as $l | (" " * $l)[:$l] + .;
 
def percent: "\(10000100000 * . | round / 1001000)%";
 
def pi: 4* (1|atan);
Line 1,541:
Iterations -> Approx Pi -> Error
---------- ---------- ------
10 2.48 2310.61873%
100 3.2 28 14.86406%
1000 3.192172 10.6968%
10000 3.10121456 10.29128%
100000 3.14772 13316 0.2268%
1000000 3.141632 139956 0.052%
</pre>
 
2,479

edits