Example 1.  Use Monte Carlo simulation to approximate the number  [Graphics:Images/MonteCarloPiMod_gr_31.gif].

Solution 1.

The following additions to the subroutine include print and graphics statements for the answer.

[Graphics:../Images/MonteCarloPiMod_gr_32.gif]

Explore what happens with  [Graphics:../Images/MonteCarloPiMod_gr_33.gif]  points.

 

 

 

[Graphics:../Images/MonteCarloPiMod_gr_34.gif]

[Graphics:../Images/MonteCarloPiMod_gr_35.gif]

[Graphics:../Images/MonteCarloPiMod_gr_36.gif]

 

 

 

[Graphics:../Images/MonteCarloPiMod_gr_37.gif]

[Graphics:../Images/MonteCarloPiMod_gr_38.gif]

[Graphics:../Images/MonteCarloPiMod_gr_39.gif]

 

 

 

[Graphics:../Images/MonteCarloPiMod_gr_40.gif]

[Graphics:../Images/MonteCarloPiMod_gr_41.gif]

[Graphics:../Images/MonteCarloPiMod_gr_42.gif]

 

 

 

[Graphics:../Images/MonteCarloPiMod_gr_43.gif]

[Graphics:../Images/MonteCarloPiMod_gr_44.gif]

[Graphics:../Images/MonteCarloPiMod_gr_45.gif]

 

 

 

[Graphics:../Images/MonteCarloPiMod_gr_46.gif]

[Graphics:../Images/MonteCarloPiMod_gr_47.gif]

[Graphics:../Images/MonteCarloPiMod_gr_48.gif]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2005