3a4,7
> # Author: Mendel Cooper
> # License: Public Domain
> # Version 2.2, reldate 13oct08.
>
45c49,50
< M_PI=3.141592654 # Actual value of PI, for comparison purposes.
---
> declare -r M_PI=3.141592654
> # Actual 9-place value of PI, for comparison purposes.
66c71
< # This diminshes the accuracy of the simulation.
---
> # This decreases the accuracy of the simulation.
69a75
> # ==========================================================
70a77
> # "Main" code block, mimmicking a C-language main() function.
84,85c91,92
< hypotenuse $xCoord $yCoord # Hypotenuse of right-triangle =
< #+ distance.
---
> hypotenuse $xCoord $yCoord # Hypotenuse of
> #+ right-triangle = distance.
91,94c98,101
< printf "Distance = %5d " $distance # Distance from
< #+ center of lake --
< # the "origin" --
< #+ coordinate (0,0).
---
> printf "Distance = %5d " $distance # Distance from
> #+ center of lake
> #+ -- the "origin" --
> #+ coordinate (0,0).
113,115c120,124
< echo "After $shots shots, PI looks like approximately $Pi"
< # Tends to run a bit high . . .
< # Probably due to round-off error and imperfect randomness of $RANDOM.
---
> echo "After $shots shots, PI looks like approximately $Pi"
> # Tends to run a bit high,
> #+ probably due to round-off error and imperfect randomness of $RANDOM.
> # But still usually within plus-or-minus 5% . . .
> #+ a pretty good rough approximation.
117c126,128
< echo "Deviation from mathematical value of PI = $error"
---
> pct_error=$(echo "scale=2; 100.0 * $error / $M_PI" | bc)
> echo -n "Deviation from mathematical value of PI = $error"
> echo " ($pct_error% error)"
119a131
> # End of "main" code block.
120a133
> # ==========================================================
122c135
< exit 0
---
> exit