{VERSION 2 3 "SGI IRIS UNIX" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 92 " The following worksheet solves Problem 1.5 in Griffiths Introduction to Quantum Mechanics" }} {PARA 0 "" 0 "" {TEXT -1 89 "by Monte Carlo methods. We simulate by \+ random number generation the dropping of a stick" }}{PARA 0 "" 0 "" {TEXT -1 91 "of unit length onto a floor of parallel lines with unit s pacing. The question asks what is" }}{PARA 0 "" 0 "" {TEXT -1 95 "the probability that the stick crosses a line. To illustrate the interes ting final answer, the" }}{PARA 0 "" 0 "" {TEXT -1 96 "routine stick_t oss(n) returns 2/probability of crossing a line. For a large enough \+ statistical" }}{PARA 0 "" 0 "" {TEXT -1 92 "sample (n>1000 or so), thi s number starts to resemble a very interesting one in mathematics." }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 " Include the statistics pack age:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(stats);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#7*%&anovaG%)describeG%$fitG%+importdat aG%'randomG%*statevalfG%*statplotsG%*transformG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 " Start the random number generator with a 'rand om' seed:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "randomize;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#%*randomizeG" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 89 " Construct the routine stick_toss(n). Here x is th e distance of one end of the stick" }}{PARA 0 "" 0 "" {TEXT -1 83 "fro m an arbitrary line. It is chosen as a random number from 0 to 1 acco rding to a" }}{PARA 0 "" 0 "" {TEXT -1 86 "uniform distribution. The angle theta specifies the orientation of the stick. It is" }}{PARA 0 "" 0 "" {TEXT -1 79 "chosen at random from a uniform distribution be tween 0 and Pi. The stick is of" }}{PARA 0 "" 0 "" {TEXT -1 91 "unit \+ length, so the top of the stick is sin(theta) above the bottom (at x) \+ in the direction" }}{PARA 0 "" 0 "" {TEXT -1 100 "perpedicular to the \+ parallel lines on the floor. The stick intersects a line if x + sin(t heta) > 1." }}{PARA 0 "" 0 "" {TEXT -1 86 "The routine simply counts t he number of times this occurs in the variable ave and then" }}{PARA 0 "" 0 "" {TEXT -1 91 "divides by the total number of samples to obtai n the probability P. However, it prints out" }}{PARA 0 "" 0 "" {TEXT -1 60 "2/P for reasons that you will discover by playing with this." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "stick_toss := proc(n)" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "local i, ave, x, theta;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "ave := 0;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "for i from 1 to n do:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "x := r andom[uniform[0,1]]();" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "theta := \+ random[uniform[0,Pi]]();" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "if sin( theta) + x > 1 then" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "ave := ave + 1;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "fi;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "od:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "evalf(2*n/av e);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 " Simply giving the stick_toss command at this point for a given sample size will return 2/P," }}{PARA 0 "" 0 "" {TEXT -1 73 "where P is the probability that the stick hits one of the parallel lines." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "stick_toss(100); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+D&)oyK!\"*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "9 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }