Monte Carlo methods: Difference between revisions

→‎{{header|REXX}}: added a scale to show the number of (true) decimal digits of pi; added expanded output.
m (→‎{{header|REXX}}: updated the running output for the program.)
(→‎{{header|REXX}}: added a scale to show the number of (true) decimal digits of pi; added expanded output.)
Line 1,511:
<lang rexx>/*REXX program computes and displays the value of pi÷4 using the Monte Carlo algorithm*/
pi=3.141592653589793238462643383279502884197169399375105820974944592307816406 /*true pi.*/
say ' 1 2 3 4 5 6 7 '
say 'scale: 1·234567890123456789012345678901234567890123456789012345678901234567890123'
say /* [↑] a two-line scale for showing pi*/
say 'true pi='pi"+" /*we might as well brag about true pi.*/
numeric digits length(pi) - 1 /*this program uses these decimal digs.*/
Line 1,539 ⟶ 1,542:
'''output''' &nbsp; when using the default inputs:
<pre>
1 2 3 4 5 6 7
true pi=3.141592653589793238462643383279502884197169399375105820974944592307816406+
scale: 1·234567890123456789012345678901234567890123456789012345678901234567890123
 
10,000 repetitions: Monte Carlo pi is accurate to 3 places.
20,000 repetitions: Monte Carlo pi is accurate to 4 places.
Line 1,546 ⟶ 1,551:
20,950,000 repetitions: Monte Carlo pi is accurate to 8 places.
26,130,000 repetitions: Monte Carlo pi is accurate to 10 places.
Error 4 running "c:\montecpi.rex", line 1518: Program interrupted
</pre>