{VERSION 5 0 "APPLE_PPC_MAC" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{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 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "These are the initial cond itions for you to enter:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "alcohol_type:=p ort; gender:=F; weight:=70; driving_limit:=0.08;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 102 "if (gender=M) then blood_volume:=0.68*weight ;\nelif (gender=F) then blood_volume:=0.65*weight;\nend if;\n" }}} {SECT 0 {PARA 3 "" 0 "" {TEXT -1 78 "Part 1 - drinking 6 beers instant aneously and resulting blood alcohol content:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "alcohol_type:=beer; number:=6;" }}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 17 "Grams of alcohol:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 445 "if (alcohol_type=beer) then grams:=13.6;\nelif \+ (alcohol_type=light_beer) then grams:=11.3;\nelif (alcohol_type=port) \+ then grams:=16.4;\nelif (alcohol_type=burgundy) then grams:=10.9;\neli f (alcohol_type=rose_wine) then grams:=10.0;\nelif (alcohol_type=hundr ed_vodka) then grams:=16.7;\nelif (alcohol_type=hundred_bourbon) then \+ grams:=16.7;\nelif (alcohol_type=eighty_vodka) then grams:=13.4;\nelif (alcohol_type=eighty_bourbon) then grams:=13.4;\nend if;" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "initial_alcohol:=grams*number;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "concentration[1]:=initial_al cohol/blood_volume;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "driv ing:=0; rate:=12/60; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 51 "Number o f minutes for all alcohol to be eliminated:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "T:=floor(initial_alcohol/rate);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 189 "for t from 1 to T do\n concentration[t+1 ]:=(initial_alcohol-t*rate)/blood_volume;\n if (concentration[t+1] " 0 "" {MPLTEXT 1 0 22 "c oncentration[T+2]:=0:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "The amou nt of time (in minutes) before one can legally drive." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "driving_time;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 52 "Plot out the blood alcohol concentration in minute s." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 267 "l := [[ n, concentra tion[n]] $n=1..T+2]:\nL := [[ n, driving_limit] $n=1..T+2]:\nplot([l,L ],linestyle=[SOLID, DASHDOT], title=\"The blood-alcohol concentration \+ after 6 beer\", labels=[time, concentration], legend=[\"concentration \+ in the blood\",\"the legal driving limit\"]);" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 59 "Part 2 - More realistic drinking model of drinking 6 beers:" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 431 "Let us assume that we \+ are taking sips of beer once every 2 minutes. Let's also assume that \+ each sip is about 1/10 of the beer. So, on average you would drink a \+ beer in 20 minutes and about 3 beers per hour. (Let us also assume th at you stop drinking if you blood alcohol content would go above 0.5 a nd you would start drinking again if it were go drop below 0.4). Also , let us assume that you would only drink 6 beers in total." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "s ip_rate:=1/30; number_sips:=ceil(number/sip_rate); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "concentration[1]:=0;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 88 "Assume that we'll take sips from the first minute \+ and then take them every second minute" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 682 "beer_left:=grams*number:\ndriving:=1: count:=1:\nsip _size:=grams*sip_rate:\nfor t from 1 to T do\n if(beer_left<=0) then\n sip_size:=0;\n end if:\n concentration[t+1]:=concentration[t]+(-rate +(1-(-1)^t)/2*sip_size)/blood_volume;\n beer_left:=beer_left - ((1-(-1 )^t)/2)*sip_size;\n if (concentration[t+1]<0) then \n concentration[t +1]:=0;\n end if;\n if (concentration[t+1]>=0.08 and driving=1) then\n stop_driving[count]:=t-1;\n driving:=0;\n elif (concentration[t+1]< 0.08 and driving=0) then\n start_driving[count]:=t-1;\n count:=count +1;\n driving:=1;\n end if:\nend do: \nl := [[ n-1, concentration[n]] $n=1..T+1]:\nL := [[ n-1, driving_limit] $n=1..T+1]:\nplot(\{l,L\}, s tyle=point,symbol=point);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "count;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 100 "stopped := [[ n , stop_driving[n]] $n=1..count-1];\nstarted := [[ n, start_driving[n]] $n=1..count-1];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 103 "l2 := \+ [[ n-1, concentration[n]] $n=125..140]:\nL2 := [[ n-1, driving_limit] \+ $n=125..140]:\nplot(\{l2,L2\});" }}}}}{MARK "4 2 1 0 0" 33 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }