{VERSION 3 0 "IBM INTEL NT" "3.0" } {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 Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 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 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Fixed Width" 0 17 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 0 0 0 0 0 0 0 0 3 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 17 0 }{PSTYLE "" 17 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 111 "Example: Use Maple to estimate the probability of throwing two points in a 1x1 squre having distance less than " }{XPPEDIT 18 0 "s; " "6#%\"sG" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 82 "The experiment: throwing two points. results: t wo \"locations\" (x1, y1), (x2, y2). " }}{PARA 0 "" 0 "" {TEXT -1 58 " To simulate: we need to get random number x1, x2, y1, y2. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 11 "Input: s, n" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 256 "" 0 "" {TEXT -1 745 "\ntwop oint:=proc(\n s::numeric,\n n::integer\n )\n local dis, x1, x2, y1, y2, count, i;\n\n if n < = 0 then\n print(`n should be a big, positive integer`);\n R ETURN():\n fi;\n\n count:=0;\n for i from 1 to n do\n\n # s imulation\n x1:=real_ran(0,1);\n y1:=real_ran(0,1);\n x 2:=real_ran(0,1);\n y2:=real_ran(0,1);\n\n # checking\n \+ dis:=sqrt( (x2-x1)^2 + (y2-y1)^2 );\n if dis < s then\n \+ count:=count+1;\n fi;\n\n od;\n\n evalf( count/n );\n\nend;\n \n#\n# function that output a random real number in [a,b]\n#\nreal_ran :=proc(\n a::numeric,\n b::numeric\n \+ )\n local x;\n x:=rand();\n evalf( a+ (b-a)*x/9999999999 99 );\nend;\n" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "read(`a:twopoint.txt`);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%)twopointGR6\$'%\"sG%(numericG'%\"nG%(integerG6)%\$disG %#x1G%#x2G%#y1G%#y2G%&countG%\"iG6\"F5C&@\$19%\"\"!C\$-%&printG6#%Dn~sho uld~be~a~big,~positive~integerG-%'RETURNGF5>8)F:?(8*\"\"\"FFF9%%trueGC (>8%-%)real_ranG6\$F:FF>8'FK>8&FK>8(FK>8\$-%%sqrtG6#,&*\$),&FQFFFJ!\"\"\" \"#\"\"\"FF*\$),&FSFFFOFgnFhnFinFF@\$2FU9\$>FC,&FCFFFFFF-%&evalfG6#*&FCFi nF9!\"\"F5F5F5" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%)real_ranGR6\$'%\"a G%(numericG'%\"bGF)6#%\"xG6\"F.C\$>8\$-%%randGF.-%&evalfG6#,&9\$\"\"\"*&, &9%F9F8!\"\"F9F1F9#F9\"-************F.F.F." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 20 "twopoint(1.0, 1000);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\$\"+++++(*!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "twop oint(0.5, 10000);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\$\"++++>[!#5" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "twopoint(2,0);" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#%Dn~should~be~a~big,~positive~integerG" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "0 8 0" 89 } {VIEWOPTS 1 1 0 1 1 1803 }