{VERSION 3 0 "APPLE_PPC_MAC" "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 "" -1 256 "" 1 36 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 273 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 274 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 276 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 277 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 278 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 279 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 280 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 281 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 282 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 283 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 284 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 285 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 286 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 287 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 288 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 289 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 290 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 291 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 292 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 293 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 294 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 295 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 296 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 297 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 298 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 299 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 300 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 301 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 302 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 303 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 304 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 305 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 306 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 307 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 308 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 309 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 310 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 311 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 312 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 313 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 314 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 315 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 316 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 317 "" 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 318 "" 0 1 0 0 0 0 0 1 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 "H eading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 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 -1 8 2 0 0 0 0 0 0 -1 0 } {PSTYLE "Heading 3" 4 5 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 0 1 0 0 0 0 0 0 0 0 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Plot" 0 13 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT 256 8 "Calculus" }{TEXT 271 37 " \n\nMathematics and Modeling with Maple" }}{PARA 19 "" 0 "" {TEXT -1 28 "\nDaniel D. Warner\n\nFall 2000" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 15 "Modeling Change" }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 18 "Drugs i n the Body\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 19 "Novocaine Example \n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "Initial Condition: " }{XPPEDIT 18 0 "u[0 ] = 500" "6#/&%\"uG6#\"\"!\"$+&" }{TEXT -1 20 ".\nRecursion Formula:" }{XPPEDIT 18 0 "u[n] = u[n-1]-.2*u[n-1];" "6#/&%\"uG6#%\"nG,&&F%6#,&F' \"\"\"\"\"\"!\"\"F,*&$\"\"#!\"\"F,&F%6#,&F'F,\"\"\"F.F,F." }{TEXT -1 22 ".\nDefine the function " }{XPPEDIT 18 0 "u(n);" "6#-%\"uG6#%\"nG" }{TEXT -1 60 " directly from the difference equation. \nThis is call ed a " }{TEXT 257 9 "recursive" }{TEXT -1 13 " definition.\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "u := proc(n) if n<=0 then 50 0 else u(n-1) - 0.2*u(n-1) fi end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "\nWe can now evaluate " }{XPPEDIT 18 0 "u;" "6#%\"uG" }{TEXT -1 23 " for various values on " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 20 " simply by entering " }{XPPEDIT 18 0 "u(n);" "6#-%\"uG6#%\"nG" }{TEXT -1 6 ". \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "u(0 ); u(1); u(2); u(3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "\nWe can \+ generate a list of points for " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 50 " taking on the values from 0 to 25 by entering .\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "[seq([n,u(n)], n=0..25)];" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 152 "\nWe can avoid printing out the e ntire list, but save it for future use by assigning the list to a vari able and by terminating the command with a colon.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "pts := [seq([n,u(n)], n=0..25)]:" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "\nWe can plot the list of points u sing the plot command.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "plot(pts,style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "\nUpon reflection, we see that we can write " }{XPPEDIT 18 0 "u(n);" "6#-%\" uG6#%\"nG" }{TEXT -1 6 " in a " }{TEXT 258 11 "closed form" }{TEXT -1 4 " as " }{XPPEDIT 18 0 "u(n) = 500*.8^n;" "6#/-%\"uG6#%\"nG*&\"$+&\" \"\")$\"\")!\"\"F'F*" }{TEXT -1 38 ". \nWhat happens if we simply rep lace " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 4 " by " }{XPPEDIT 18 0 "t;" "6#%\"tG" }{TEXT -1 9 " and let " }{XPPEDIT 18 0 "t;" "6#%\"tG " }{TEXT -1 27 " take on arbitrary values?\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "u := proc(t) 500*(0.8)^t end;\nplot(u(t),t=0..25 );" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 131 "\nWe can display both plot s by giving each one a name, supressing any output, \nand displaying t hem with the plots[display] command.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "P1 := plot(pts,style=point):\nP2 := plot(u(t),t=0..25 ):\nplots[display](\{P1,P2\});" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 20 "Amoxicillin Example\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 " restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 129 "The patient's kidney s eliminate half the drug every hour, and \nthe patient takes a 500 mg pill every 4 hours.\n\nInitial Condition " }{XPPEDIT 18 0 "u[0] = 500 ;" "6#/&%\"uG6#\"\"!\"$+&" }{TEXT -1 23 ". \n\nRecurrence formula\n" } {XPPEDIT 18 0 "u[1] = 500+.5^4*u[0];" "6#/&%\"uG6#\"\"\",&\"$+&\"\"\"* &$\"\"&!\"\"\"\"%&F%6#\"\"!F*F*" }{TEXT -1 12 " = 531.25\n" } {XPPEDIT 18 0 "u[2] = 500+.5^4*u[1];" "6#/&%\"uG6#\"\"#,&\"$+&\"\"\"*& $\"\"&!\"\"\"\"%&F%6#\"\"\"F*F*" }{TEXT -1 16 " = 533.203125\n" } {XPPEDIT 18 0 "u[3] = 500+.5^4*u[2];" "6#/&%\"uG6#\"\"$,&\"$+&\"\"\"*& $\"\"&!\"\"\"\"%&F%6#\"\"#F*F*" }{TEXT -1 18 " = 533.3251953 \n" } {TEXT 259 6 " . . ." }{TEXT -1 1 "\n" }{XPPEDIT 18 0 "u[n] = 500+.5^4* u[n-1];" "6#/&%\"uG6#%\"nG,&\"$+&\"\"\"*&$\"\"&!\"\"\"\"%&F%6#,&F'F*\" \"\"!\"\"F*F*" }{TEXT -1 13 "\n\nNow define " }{XPPEDIT 18 0 "u(n);" " 6#-%\"uG6#%\"nG" }{TEXT -1 62 " using the initial conditions and the r ecurrence formula.\n \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "u := proc(n) if n<=0 then 500 else 500 + 0.5^4*u(n-1) fi end;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "\nDouble check the four values tha t we already know.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "u(0 ); u(1); u(2); u(3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "\nPlot th e amount of amoxicillin in the patient's body after taking 25 pills ov er a 6 day period.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "pts := [seq([n,u(n)],n=0..24)]:\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "\nThe values appear to have rapidly appro ached a " }{TEXT 260 8 "limiting" }{TEXT -1 35 " value. Let's check a few values.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "u(10); u( 15); u(20);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 117 "\nTo 10 digits th ese are the same. But if we increase our precision to 25 digits we wi ll see\nsome small differences.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "Digits := 25;\nu(10); u(15); u(20);\nDigits := 10;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 234 "\nOf course, while these differ ences are interesting from a mathematical point of view, differences\n that are less than one hundredth of a milligram would be of no practic al significance.\n\nSuppose that we assume that there is a number, " } {XPPEDIT 18 0 "L;" "6#%\"LG" }{TEXT -1 78 ", which remains the same fo r each iteration.\nThen we would have the relation " }{XPPEDIT 18 0 " L = 500+.5^4*L;" "6#/%\"LG,&\"$+&\"\"\"*&$\"\"&!\"\"\"\"%F$F'F'" } {TEXT -1 41 ". We can simply solve this equation for " }{XPPEDIT 18 0 "L;" "6#%\"LG" }{TEXT -1 19 " \nand learn that " }{XPPEDIT 18 0 "L = 500/(1-.5^4);" "6#/%\"LG*&\"$+&\"\"\",&\"\"\"F'*$$\"\"&!\"\"\"\"%! \"\"F/" }{TEXT -1 49 " = 533.3333333. \n\nGiven a recursion formu la " }{XPPEDIT 18 0 "u[n] = F(u[n-1]);" "6#/&%\"uG6#%\"nG-%\"FG6#&F%6# ,&F'\"\"\"\"\"\"!\"\"" }{TEXT -1 4 ", a " }{TEXT 263 10 "rest point" } {TEXT -1 16 " is any number, " }{XPPEDIT 18 0 "x;" "6#%\"xG" }{TEXT -1 12 ", for which " }{XPPEDIT 18 0 "x = F(x);" "6#/%\"xG-%\"FG6#F$" } {TEXT -1 102 ".\n \nAlthough this was a simple equation which was eas y to do by hand, we can also solve it\nusing the " }{TEXT 264 5 "solve " }{TEXT -1 86 " command in Maple. This can be helpful when the equat ion is complicated.\nSimply type " }{TEXT 265 5 "solve" }{TEXT -1 56 " along with the equation and the variable to solve for\n." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "solve(L = 500 + 0.5^4*L,L);\n" }}}} {SECT 1 {PARA 5 "" 0 "" {TEXT -1 12 "Exercise 17\n" }}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 138 "Suppose that 600 mg of an antibiotic are administered every three hours, and\nthat the body eliminates 40% of the antibiotic in one hou r.\n\n" }{TEXT 266 1 "a" }{TEXT -1 79 ". Model the maximum level of t he antibiotic with a difference equation.\n\n " }{XPPEDIT 18 0 "u[ 0] = 600;" "6#/&%\"uG6#\"\"!\"$+'" }{TEXT -1 7 " \n " }{XPPEDIT 18 0 "u[n] = 600+.4^3*u[n-1];" "6#/&%\"uG6#%\"nG,&\"$+'\"\"\"*&$\"\"%! \"\"\"\"$&F%6#,&F'F*\"\"\"!\"\"F*F*" }{TEXT -1 6 ". \n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 267 2 "b." }{TEXT -1 171 " Does \+ the maximum value stabilize? If so what is this \"stable\" value.\n\n First, define the difference equation in Maple and determine the \+ first few numerical values.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "u := proc(n) if n<=0 then 600 else 600 + 0.4^3*u(n-1) fi end;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "u(0); u(1); u(2); u(3);" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "\n Now determine any rest poi nts.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "solve(L = 600 + 0 .4^3*L,L);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 162 " \n The number 6 41.0256410 is a rest point and it certainly appears that the maximum c oncentration of the antibiotic will\n quickly \"stabilize\" at this \+ value. \n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 268 2 "c." } {TEXT -1 94 " Produce a graph to depict the maximum amount of the ant ibiotic in the first 12 hours. \n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "pts := [seq([n,u(n)],n=0..4)]:\nplot(pts, style=point );" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 25 "Patterns of Accumulation \n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 11 "Summation.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "To sum the odd integers from 3 to 19 in Maple use the sum command\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "Sum(2*k+1, k= 1..9) = sum(2*k+1, k=1..9);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 174 " \nThe capital S in Sum tells Maple to simply write the summation in st andard mathematical\nnotation. The second sum, with the lower case s, tells Maple to do the calculation.\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "A sum of the form " }{XPPEDIT 18 0 "Sum(a^k,k = 0 .. n) = 1+a+a^2;" "6#/-%$SumG6$)%\"aG%\"kG/F);\"\"!%\"nG,(\"\"\"\"\"\"F(F0*$F (\"\"#F0" }{TEXT -1 3 " + " }{TEXT 262 8 ". . . + " }{XPPEDIT 18 0 "a^ n;" "6#)%\"aG%\"nG" }{TEXT -1 76 " is called a finite geometric series .\nIf we ask Maple to evaluate it we get\n" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 26 "S := sum(a^k,k = 0 .. n); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "\nThis is not exactly correct. If " }{XPPEDIT 18 0 " a = 1;" "6#/%\"aG\"\"\"" }{TEXT -1 8 ", then " }{XPPEDIT 18 0 "S = n+ 1;" "6#/%\"SG,&%\"nG\"\"\"\"\"\"F'" }{TEXT -1 51 ". The formula is c orrect for all other values of " }{XPPEDIT 18 0 "a;" "6#%\"aG" }{TEXT -1 2 ".\n" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 31 "Amoxicillin Exampl e Revisited.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 191 "We now return to the Amoxicilli n example. Remember that the patient's kidneys eliminate\nhalf the dr ug every hour, and that the patient takes a 500 mg pill every 4 hours .\n\nInitial Condition " }{XPPEDIT 18 0 "u[0] = 500;" "6#/&%\"uG6#\"\" !\"$+&" }{TEXT -1 23 ". \n\nRecurrence formula\n" }{XPPEDIT 18 0 "u[1] = 500+.5^4*u[0];" "6#/&%\"uG6#\"\"\",&\"$+&\"\"\"*&$\"\"&!\"\"\"\"%&F %6#\"\"!F*F*" }{TEXT -1 5 " = " }{XPPEDIT 18 0 "500*(1+.5^4);" "6#*& \"$+&\"\"\",&\"\"\"F%*$$\"\"&!\"\"\"\"%F%F%" }{TEXT -1 23 " = 500(1 \+ + 0.0625) \n" }{XPPEDIT 18 0 "u[2] = 500+.5^4*u[1];" "6#/&%\"uG6#\"\" #,&\"$+&\"\"\"*&$\"\"&!\"\"\"\"%&F%6#\"\"\"F*F*" }{TEXT -1 5 " = " } {XPPEDIT 18 0 "500*(1+.5^4+.5^8);" "6#*&\"$+&\"\"\",(\"\"\"F%*$$\"\"&! \"\"\"\"%F%*$$\"\"&!\"\"\"\")F%F%" }{TEXT -1 27 " = 500(1 + 0.0625 + 0.062" }{XPPEDIT 18 0 "5^2;" "6#*$\"\"&\"\"#" }{TEXT -1 3 ") \n" } {XPPEDIT 18 0 "u[3] = 500+.5^4*u[2];" "6#/&%\"uG6#\"\"$,&\"$+&\"\"\"*& $\"\"&!\"\"\"\"%&F%6#\"\"#F*F*" }{TEXT -1 4 " = " }{XPPEDIT 18 0 "500 *(1+.5^4+.5^8+.5^12);" "6#*&\"$+&\"\"\",*\"\"\"F%*$$\"\"&!\"\"\"\"%F%* $$\"\"&!\"\"\"\")F%*$$\"\"&!\"\"\"#7F%F%" }{TEXT -1 27 " = 500(1 + 0 .0625 + 0.062" }{XPPEDIT 18 0 "5^2;" "6#*$\"\"&\"\"#" }{TEXT -1 8 " + \+ 0.062" }{XPPEDIT 18 0 "5^3;" "6#*$\"\"&\"\"$" }{TEXT -1 3 ")\n " } {TEXT 261 6 " . . ." }{TEXT -1 1 "\n" }{XPPEDIT 18 0 "u[n] = 500+.5^4* u[n-1];" "6#/&%\"uG6#%\"nG,&\"$+&\"\"\"*&$\"\"&!\"\"\"\"%&F%6#,&F'F*\" \"\"!\"\"F*F*" }{TEXT -1 4 " = " }{XPPEDIT 18 0 "500*Sum(.625e-1^k,k \+ = 0 .. n);" "6#*&\"$+&\"\"\"-%$SumG6$)$\"$D'!\"%%\"kG/F-;\"\"!%\"nGF% " }{TEXT -1 17 " . \n \nNow define " }{XPPEDIT 18 0 "u(n);" "6#-%\"uG6 #%\"nG" }{TEXT -1 35 " in tems of this summation formula." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "u := proc(n) 500*sum(0.0625^k,k=0.. n) end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "\nDouble check the fou r values that we already know.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "u(0); u(1); u(2); u(3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 13 "\nNow examine " }{XPPEDIT 18 0 "u(10);" "6#-%\"uG6#\"#5" }{TEXT -1 2 ".\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "u(10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "\nNote that the values of " } {XPPEDIT 18 0 "u(3);" "6#-%\"uG6#\"\"$" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "u(10);" "6#-%\"uG6#\"#5" }{TEXT -1 477 " differ from the previou s calculation by 2 units in the last digit.\nThis is an example of rou nd-off error. When calculations are done in two different ways using a fixed\nnumber of decimal digits, the different calculations will c ause rounding to occur at different times.\nThis will typically produc e slightly different results. Rounding error is another reason to per form\ncalculations with more digits than the minimum necessary to refl ect the accuracy of the measurements." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "\nPlot the amount of amoxicillin in the patient's body af ter taking 25 pills over a 6 day period.\n" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 55 "pts := [seq([n,u(n)],n=0..24)]:\nplot(pts, style=po int);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "\nWe can also define " } {XPPEDIT 18 0 "u(n);" "6#-%\"uG6#%\"nG" }{TEXT -1 40 " in terms of the closed form solution .\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 82 "u := proc(n) 500*((1-0.0625^(n+1))/(1-0.0625)) end;\nu(0); u(1); u (2); u(3); u(10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 163 "\nThe close d form solution yields results that are identical to those with the su mmation formula,\nbecause Maple uses the closed form solution to calcu late the sum.\n" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 21 "Piecewise Fu nctions.\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "Piecewise functions can be define d in Maple using the piecewise command.\nFor a simple example suppose \+ that " }{XPPEDIT 18 0 "f(x) = 4;" "6#/-%\"fG6#%\"xG\"\"%" }{TEXT -1 5 " for " }{XPPEDIT 18 0 "x < -3;" "6#2%\"xG,$\"\"$!\"\"" }{TEXT -1 13 " , then 2 for " }{XPPEDIT 18 0 "x < 2;" "6#2%\"xG\"\"#" }{TEXT -1 20 ", and\nfinally 3 for " }{XPPEDIT 18 0 "2 <= x;" "6#1\"\"#%\"xG" }{TEXT -1 38 ". We define the function as follows.\n" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 43 "f := proc(x) piecewise(x<-3,4,x<2,2,3) end;" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "\nTyping the expression " } {XPPEDIT 18 0 "f(t);" "6#-%\"fG6#%\"tG" }{TEXT -1 93 " causes Maple to display the piecewise function the way it is usually\nprinted in math books.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "f(t);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "\nWe plot " }{XPPEDIT 18 0 "f(x);" "6#-%\"fG6#%\"xG" }{TEXT -1 33 " as we would any other function.\n" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(f(x),x=-5..5,y=0..5); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 148 "\nFor a slightly more intere sting example, consider a function that decays exponentially, then gro ws\nexponentially, and then begins to decay again.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "g := proc(x) piecewise(x<3,5*(0.585 )^x,x<6,(1.71)^(x-3),5*(0.7)^(x-6)) end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(g(x),x=0..10,y=0..5);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 21 "Exercise 17 Revisited" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 160 "\nRe call Exercise 17 from Section 1.1. For the three hours after the firs t dose the amount of the antibiotic\ndecays exponentially. The closed form solution is " }{XPPEDIT 18 0 "u[0] = 600;" "6#/&%\"uG6#\"\"!\"$+ '" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "u[n] = .4^n*u[0];" "6#/&%\"uG6# %\"nG*&)$\"\"%!\"\"F'\"\"\"&F%6#\"\"!F-" }{TEXT -1 65 ". However this only holds\nuntil the next dose which occurs when " }{XPPEDIT 18 0 "n = 3;" "6#/%\"nG\"\"$" }{TEXT -1 16 ". We start the " }{XPPEDIT 18 0 ".4^n;" "6#)$\"\"%!\"\"%\"nG" }{TEXT -1 54 " decay process all over wi th an initial \ncondition of " }{XPPEDIT 18 0 "600+.4^3*600;" "6#,&\"$ +'\"\"\"*&$\"\"%!\"\"\"\"$\"$+'F%F%" }{TEXT -1 171 ". The effect of t wo pills can be described by a piecewise function.\nNote that when dec ay process starts over after the second pill, we must adjust the expon ent and write\n" }{XPPEDIT 18 0 ".4^(n-3);" "6#)$\"\"%!\"\",&%\"nG\"\" \"\"\"$!\"\"" }{TEXT -1 45 " in order to multiply by the correct facto r.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "u := proc(n) piece wise(n<=0, 600, n<3, 600*0.4^n, \n (600 + 600*0.4 ^3)*0.4^(n-3)) end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "\nWe can p lot the effect of these two pills over a 12 hour period.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "pts := [seq([n,u(n)],n=0..12)]:\npl ot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "\nWe can extend this piecewise function to handle three pills by adding anothe r term.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 141 "u := proc(n) \+ piecewise(n<=0, 600, n<3, 600*0.4^n, \n n<6, (600 + 600*0.4^3)*0.4 ^(n-3), \n (600 + 600*0.4^3 + 600*0.4^6)*0.4^(n-6)) end;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "\nOver a 12 hour period we now get the following plot.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "p ts := [seq([n,u(n)],n=0..12)]:\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 187 "This app roach will get extremely awkward if we want to consider the effect of \+ taking a pill\nevery three hours for several days. However, there is \+ another way to look at what's happening." }}{PARA 0 "" 0 "" {TEXT -1 100 "\nNotice that if we multiply out the last term in the definition \+ of the piecewise solution we get\n\n " }{XPPEDIT 18 0 "(600+600*.4^3+ 600*.4^6)*.4^(n-6) = 600*.4^(n-6)+600*.4^(n-3)+600*.4^n;" "6#/*&,(\"$+ '\"\"\"*&\"$+'F'*$$\"\"%!\"\"\"\"$F'F'*&\"$+'F'*$$\"\"%!\"\"\"\"'F'F'F ')$\"\"%!\"\",&%\"nGF'\"\"'!\"\"F',(*&\"$+'F')$\"\"%!\"\",&F;F'\"\"'F= F'F'*&\"$+'F')$\"\"%!\"\",&F;F'\"\"$F=F'F'*&\"$+'F')$\"\"%!\"\"F;F'F' " }{TEXT -1 121 "\n \nThis means that we can also think of the total a mount in the body as the sum of the amount\nremaining from each pill. \+ " }{TEXT 282 116 "Each term in the sum is just the closed form soluti on shifted to\nstart at the time the corresponding pill was taken." } {TEXT -1 90 " We can write one piecewise function which\nrepresents a ny shifted solution. We will let " }{TEXT 270 1 "n" }{TEXT -1 34 " de note the current hour and let " }{TEXT 269 1 "h" }{TEXT -1 46 " deno te the\nhour at which the pill is taken.\n" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 53 "v := proc(n,h) piecewise(n " 0 "" {MPLTEXT 1 0 95 "u := proc(n) sum(v(n,3*k),k=0..12) end;\npts := [seq([n,u(n)],n= 0..48)]:\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "\nSince we have a closed form solution, we can also plot the funct ion as a continuous function, " }{XPPEDIT 18 0 "u(t);" "6#-%\"uG6#%\"t G" }{TEXT -1 3 " .\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "plo t(u(t),t=0..48, 0..700);" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 27 "A \+ Model for Natural Growth\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 18 "The Rumor Example\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 405 "\nIn this model we consider \+ the spread of a rumor. Our idea is that the number of people who know \nthe rumor at the next time step is the sum of those who know it at t he present time plus a small percentage\nof the product of those who k now it with those who don't. The idea of this product is that it will measure\nthe number of possible interactions betweeen those who know \+ the rumor and those who don't.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "u := proc(n) if n<=0 then b else u(n-1) + a*u(n-1)*(P op - u(n-1)) fi end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "\nLet's a ssume that the population, " }{XPPEDIT 18 0 "Pop;" "6#%$PopG" }{TEXT -1 62 ", has been normalized to 1, and the proportionality constant, \+ " }{XPPEDIT 18 0 "a;" "6#%\"aG" }{TEXT -1 17 ", \nis 0.05.\n " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "a := 0.05;\nPop := 1;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 92 "\nNow set the size of the group wh o initially knows the rumor to 1% of the total population.\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "b := 0.01;\npts := [seq([n,u (n)],n=0..10)];\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 170 "\nThis calculation takes quite a bit of time, and the ru mor has not even spread to 2% of the population.\nThe problem is that \+ our recursive definition causes this function " }{TEXT 272 5 "u(n) " } {TEXT -1 70 "to be evaluated many many\ntimes. We can fix this by tel ling Maple to " }{TEXT 273 8 "remember" }{TEXT -1 76 " the values that it has alreaady calculated.\nSimply add the Maple statement " }{TEXT 274 17 "option remember; " }{TEXT -1 28 "to the function definition.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "u := proc(n) option rem ember; if n<=0 then b \n else u(n-1) + a*u(n-1)*(Pop - u(n-1)) fi \+ end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "a := 0.05;\nPop := \+ 1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "b := 0.01;\nu(100);\n pts := [seq([n,u(n)],n=0..200)]:\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "\nWhen we evaluate " }{TEXT 275 5 "u(n) \+ " }{TEXT -1 175 "with new values of its parameters we must first tell \+ it to forget all the\nvalues that it remebered from the calculations w ith the old parameters. The Maple command\nis called " }{TEXT 276 6 " forget" }{TEXT -1 2 ".\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 103 "readlib(forget);\nforget(u);\nb := 0.04;\nu(100);\npts := [seq([n ,u(n)],n=0..200)]:\nplot(pts, style=point);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "forget(u);\nb := 0.07;\nu(100);\npts := [seq([n,u( n)],n=0..200)]:\nplot(pts, style=point);forget(u);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 95 "forget(u);\nb := 0.1;\nu(100);\npts := [seq ([n,u(n)],n=0..200)]:\nplot(pts, style=point);forget(u);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "\nWe can solve the recurrence formula for its rest points.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "solv e(x = x + a*x*(Pop-x),x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "\nCa n you explain what happens when " }{XPPEDIT 18 0 "b = 0;" "6#/%\"bG\" \"!" }{TEXT -1 7 " and " }{XPPEDIT 18 0 "b = 1;" "6#/%\"bG\"\"\"" } {TEXT -1 4 "?\n " }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 18 "The Yeast \+ Example\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "restart;\nreadl ib(forget);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 123 "YeastData : = [[10,9.6],[20,29.0],[30,71.1],[40,175],[50,351],\n [60, 513],[70,594],[80,640],[90,656],[100,662]];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "plot(YeastData,style=point);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "u := proc(n) option remember; if n<=0 then b \+ \n else u(n-1) + r*u(n-1) - p*(u(n-1))^2 fi end;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "\nTo get started, let's estimate that the long term population will be 690 and that the growth\nrate, " }{XPPEDIT 18 0 "r;" "6#%\"rG" }{TEXT -1 20 ", is about 0.1. \n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 146 "b := 9.6;\nr := 0.1;\np := r/690; \nu(10);\nP1 := plot(YeastData,style=point):\npts := [seq([n,u(n)],n=0 ..100)]:\nP2 := plot(pts):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 99 "\nThis isn't too bad a fit, but there are a coupl e of points we can improve on.\nFirst, we're using " }{XPPEDIT 18 0 " u(0) = 9.6;" "6#/-%\"uG6#\"\"!$\"#'*!\"\"" }{TEXT -1 34 ", instead of \+ the given fact that " }{XPPEDIT 18 0 "u(10) = 9.6;" "6#/-%\"uG6#\"#5$ \"#'*!\"\"" }{TEXT -1 41 ".\nSecond, we simply guessed the value of " }{TEXT 283 1 "r" }{TEXT -1 33 ", but we could use the values of\n" } {XPPEDIT 18 0 "u(10);" "6#-%\"uG6#\"#5" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "u(20);" "6#-%\"uG6#\"#?" }{TEXT -1 175 " to get a more precise e stimate. \n\nTo get the more precise estimates, assume that initially \+ the yeast simply\ngrows exponentially. Then we would have the closed \+ form solution\n" }{XPPEDIT 18 0 "u(n) = u[0]*(1+r)^n;" "6#/-%\"uG6#%\" nG*&&F%6#\"\"!\"\"\"),&\"\"\"F,%\"rGF,F'F," }{TEXT -1 35 ". This lead s to the two equations\n" }{XPPEDIT 18 0 "u[0]*(1+r)^10 = 9.6;" "6#/*& &%\"uG6#\"\"!\"\"\"*$,&\"\"\"F)%\"rGF)\"#5F)$\"#'*!\"\"" }{TEXT -1 7 " and " }{XPPEDIT 18 0 "u[0]*(1+r)^20 = 29.0;" "6#/*&&%\"uG6#\"\"!\" \"\"*$,&\"\"\"F)%\"rGF)\"#?F)$\"$!H!\"\"" }{TEXT -1 47 ". \nWe can sol ve these by hand, first eliminate " }{XPPEDIT 18 0 "u[0];" "6#&%\"uG6# \"\"!" }{TEXT -1 37 " from the second equation, solve\nfor " }{TEXT 284 1 "r" }{TEXT -1 32 ", then substitute that value of " }{TEXT 285 1 "r" }{TEXT -1 36 " in the first equation to determine " }{XPPEDIT 18 0 "u[0];" "6#&%\"uG6#\"\"!" }{TEXT -1 51 ".\nOr we can simply ask M aple to do the work.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "r := 'r';\nb := 'b';\neq1 := b*(1+r)^10 = 9.6;\neq2 := b*(1+r)^2 0 = 29.0;\nsolve(\{eq1,eq2\},\{b,r\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "\nThis seems like a lot more answers than we want. Howev er, there are only two\nsolutions where " }{TEXT 286 1 "r" }{TEXT -1 4 " is " }{TEXT 287 3 "not" }{TEXT -1 59 " a complex number, and of th ese only one of the solutions,\n" }{XPPEDIT 18 0 "r = .11689;" "6#/%\" rG$\"&*o6!\"&" }{TEXT -1 79 " has a positive value. The correspondi ng value for the yeast population\nat " }{XPPEDIT 18 0 "n = 0;" "6#/% \"nG\"\"!" }{TEXT -1 5 " is " }{XPPEDIT 18 0 "b = 3.1779;" "6#/%\"bG$ \"&z<$!\"%" }{TEXT -1 26 ".\n\nUsing these values for " }{TEXT 288 1 " b" }{TEXT -1 5 " and " }{TEXT 289 1 "r" }{TEXT -1 75 ", and the same l ong term population, 690, \nwe get the following fit.\n " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 129 "forget(u);\nb := 3.1779;\nr := 0.11689;\np := r/690;\nu(10);\npts := [seq([n,u(n)],n=0..100)]:\nP 2 := plot(pts):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 157 "\nThis is a big improvement near the beginning of the da ta, and\nwe can improve the fit at the other end by lowering our estim ate\nof the long term population.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 102 "forget(u);\np := r/680;\nu(10);\npts := [seq([n,u(n) ],n=0..100)]:\nP2 := plot(pts):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 308 "\nThis is good enough for now, but notic e that we don't really\nhave a good fit where the function becomes con cave down.\nIn fact, the data looks like it might eventually get large r than\nour model predicts. We will learn some other techniques later \nthat can further improve the fitted parameters of our model.\n" }}}} {SECT 1 {PARA 5 "" 0 "" {TEXT -1 21 "A Chaotic Population\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "If the initial growth rate, " }{TEXT 290 1 "r" }{TEXT -1 75 ", is large, then our difference equation can\nhave some surprising results.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "u := proc(n) option remember; if n<=0 then b else r*u(n-1) - p*(u(n-1))^2 fi end; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "b := 100;\nr := 4;\np : = 0.005;\nseq(round(u(n)),n=0..11); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "pts := [seq([n,u(n)],n=0..50)]:\nplot(pts);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "\nLooking at things over a longer period dosn't show any improvement\nin the regularity of the results. \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "pts := [seq([n,u(n)], n=0..100)]:\nplot(pts);" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 21 "Inv estigating Limits\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 24 "Limits fro m Closed Form\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 264 "\nMaple can compute limits usi ng the limit command.\nJust as in the sum command, using Limit with a \+ capital L\ncauses Maple to write the mathematical expression without\n evaluating it. Using limit with a lower case l, causes\nMaple to eval uate the limit -- if it can.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "Limit((1/2)^n,n=infinity) = limit((1/2)^n,n=infinity);;" }}}} {SECT 1 {PARA 5 "" 0 "" {TEXT -1 29 "Rest Points and Limit Points\n" } }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "restart;\nreadlib(forget): " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 92 "\nLet's investigate the limit points and rest points of the following difference equation\n " } {XPPEDIT 18 0 "u[n] = 2*u[n-1]-u[n-1]^2;" "6#/&%\"uG6#%\"nG,&*&\"\"#\" \"\"&F%6#,&F'F+\"\"\"!\"\"F+F+*$&F%6#,&F'F+\"\"\"F0\"\"#F0" }{TEXT -1 8 " and " }{XPPEDIT 18 0 "u[0] = b;" "6#/&%\"uG6#\"\"!%\"bG" } {TEXT -1 3 ". \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "u := pr oc(n) option remember; if n<=0 then b else 2*u(n-1) - u(n-1)^2 fi end; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "solve(x=2*x-x^2,x);" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "\nThe rest points are zero and on e. Zero is clearly a limit point for " }{XPPEDIT 18 0 "b = 0;" "6#/% \"bG\"\"!" }{TEXT -1 40 ", and\n one is clearly a limit point for " } {XPPEDIT 18 0 "b = 1;" "6#/%\"bG\"\"\"" }{TEXT -1 40 ". But what happ ens for other values of " }{TEXT 291 1 "b" }{TEXT -1 2 "?\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "b := 0.1;\nseq(u(n),n=0..7); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 0.5;\n seq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget (u);\nb := 0.8;\nseq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 21 "\nIt appears that for " }{TEXT 277 2 "0<" }{XPPEDIT 18 0 "b <= \+ 1;" "6#1%\"bG\"\"\"" }{TEXT -1 44 " we have a limit point and the valu e is 1.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 1.1;\nseq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 1.5;\nseq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 1.9;\nseq(u(n),n=0..7);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "forget(u);\nb := 2;\nseq(u(n ),n=0..7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "\nIt appears that o ne is the limit point for all values of " }{TEXT 278 1 "b" }{TEXT -1 13 " such that 0<" }{TEXT 279 1 "b" }{TEXT -1 30 "<2.\nZero is a limit point for " }{TEXT 280 1 "b" }{TEXT -1 11 "=0 and for " }{TEXT 281 1 "b" }{TEXT -1 4 "=2.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "f orget(u);\nb := 2.1;\nseq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 2.5;\nseq(u(n),n=0..7);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "forget(u);\nb := 3.0;\nseq(u(n),n=0 ..7);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "\nFor values of " } {TEXT 292 1 "b" }{TEXT -1 68 " larger than 2, it looks like the values tend to\nnegative infinity.\n" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 16 "Proving a Limit\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "v : = proc(n) if n<=0 then 1 else cos(v(n-1))/n^2 fi end;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "pts := seq(evalf(v(k),4),k=0..9);" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 43 "Continuous and Piecewise Con tinuous Models\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 19 "Painless Dent istry\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "\nStarting with the discrete Novoc aine model we created a continuous model \nby substituting " }{TEXT 293 1 "t" }{TEXT -1 5 " for " }{TEXT 294 1 "n" }{TEXT -1 123 " in the \+ closed form representation of the model.\nThis continuous model predic ts the same values as the discrete model\nwhen " }{TEXT 295 1 "t" } {TEXT -1 81 " is an integer, and it provides \"reasonable\" looking an swers for\nother values of " }{TEXT 296 3 "t, " }{TEXT -1 110 "but at \+ this point in time, we don't have any physical\nreason to justify this as the correct continuous model.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "N := proc(t) 0.8^t * 500 end;\nplot(N(t), t=0..24);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 22 "Amoxicillin Revisited\n" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 54 "\nThe Amoxicilin example led to the discrete model \n\n " }{XPPEDIT 18 0 "u[n] = 500*(1-.625e-1^(n+1))/(1-.625e-1);" "6 #/&%\"uG6#%\"nG*(\"$+&\"\"\",&\"\"\"F*)$\"$D'!\"%,&F'F*\"\"\"F*!\"\"F* ,&\"\"\"F*$\"$D'!\"%F3F3" }{TEXT -1 69 " .\n\nWe can also turn this in to a continuous function by\nsubstituting " }{TEXT 297 1 "t" }{TEXT -1 5 " for " }{TEXT 298 1 "n" }{TEXT -1 5 ".\n " }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 80 "A := proc(t) 500*(1.0 - 0.0625^(t+1)) / (1.0 - 0.0625) end;\nplot(A(t), t=0..24);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 20 "\nHowever, this is a " }{TEXT 299 9 "very poor" }{TEXT -1 74 " model for the amount of Amoxicillin in the\nblood. In the dis crete model " }{XPPEDIT 18 0 "u[n];" "6#&%\"uG6#%\"nG" }{TEXT -1 183 " represents the amount on Amoxicillin \nimmediately after taking a pil l. Over the next four hours the amount is\nreduced by the kidneys. \+ \n\nFollowing the Novacaine model we can define " }{XPPEDIT 18 0 "h(t) ;" "6#-%\"hG6#%\"tG" }{TEXT -1 8 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "h := proc(t) 500*0.5^t end;\nplot(h(t), t=0..4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "\nAt " }{XPPEDIT 18 0 "t = 4;" " 6#/%\"tG\"\"%" }{TEXT -1 141 ", the patient takes a second pill which \+ adds 500 mg to the amount of\nAmoxicillin in the patients blood. This can be represented by defining " }{XPPEDIT 18 0 "h(t);" "6#-%\"hG6#% \"tG" }{TEXT -1 29 " as\na piecewise function.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 87 "h := proc(t) piecewise(t<4, 500*0.5^t, 53 1.25*0.5^(t-4)) end;\nh(t);\nplot(h(t), t=0..8);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 60 "\nIt's interesting to look at a small table of val ues around " }{XPPEDIT 18 0 "t = 4;" "6#/%\"tG\"\"%" }{TEXT -1 5 ".\n \+ " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 169 "[3.0,h(3.0)];[3.9,h( 3.9)];[3.99,h(3.99)];[3.999,h(3.999)];[3.9999,h(3.9999)];\n[4.0,h(4.0) ];[4.0001,h(4.0001)];[4.001,h(4.001)];[4.01,h(4.01)];[4.1,h(4.1)];\n[5 .0,h(5.0)];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 98 "\nMaple can handle left and right sided limits, and \nit will indicate when limits are n ot defined.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "limit(h(t) ,t=4,left);\nlimit(h(t),t=4,right);\nlimit(h(t),t=4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 141 "\nIt's possible for a function to have a limit at a point\nwhere it is undefined. These points are called hol es\nor removable discontinuities.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 171 "f := proc(x) (x^3-8)/(x-2) end;\n[1.9,f(1.9)];[1.99, f(1.99)];[1.999,f(1.999)];[1.9999,f(1.9999)];\n[2.0001,f(2.0001)];[2.0 01,f(2.001)];[2.01,f(2.01)];[2.1,f(2.1)];\n[2,f(2)];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "limit(f(t),t=2,left);\nlimit(f(t),t=2,rig ht);\nlimit(f(t),t=2);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "plot(f(t),t=-3..3);\nf(2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "\n Maple has a plot option, called " }{TEXT 300 7 "discont" }{TEXT -1 96 " which will first attempt\nto find all discontinuities, so that the j umps are correctly plotted.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "plot(h(t),t=0..8,discont=true);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 452 "\nA better approach to the Amoxicillin model is to defin e one function\nwhich follows the Novacaine model for the amount of am oxicillin from\none pill. However, add a parameter to this function s o that it can be\nshifted to account for the time the pill was taken. \+ The amount of Amoxicillin\nat any time is just the sum of the amounts remaining from each pill that\nhas been taken. This leads to the fol lowing model for 6 pills taken at\n4 hour intervals.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 111 "H := proc(t,h) piecewise(t " 0 "" {MPLTEXT 1 0 26 "plot(sin(2*Pi/x),x=-2 ..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "limit(sin(2*Pi/x), x=0,right);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 23 "Continuous Yeast Model\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "\nLet's revisit the yeast model to see if there's a continuous model\nlurking in the background.\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 123 "YeastData := [[10,9.6],[20, 29.0],[30,71.1],[40,175],[50,351],\n [60,513],[70,594],[8 0,640],[90,656],[100,662]];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "P1 := plot(YeastData,style=point):\nplots[display](P1);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "\nNow consider the " }{TEXT 301 8 "logistic" }{TEXT -1 10 " function\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "y := proc(t) a/(1+b*c^t) end;" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 40 "assume(0 " 0 "" {MPLTEXT 1 0 16 "a := 680;\ny(10);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "\nNow we can determine " }{TEXT 303 1 "b" } {TEXT -1 5 " and " }{TEXT 304 1 "c" }{TEXT -1 13 " by forcing " } {XPPEDIT 18 0 "y(t);" "6#-%\"yG6#%\"tG" }{TEXT -1 67 " to match two sp ecific data points.\nThis is usually referred to as " }{TEXT 305 13 "i nterpolating" }{TEXT -1 77 " the data at the selected points. Two\npo ints that might be interesting are " }{XPPEDIT 18 0 "t = 10;" "6#/%\" tG\"#5" }{TEXT -1 7 " and " }{XPPEDIT 18 0 "t = 50;" "6#/%\"tG\"#]" }{TEXT -1 4 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "solve (\{y(10)=9.6, y(50)=351\},\{b,c\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 117 "\nAgain the mathematical problem has lots of answers, but ther e is only one\nanswer that satisfies our condition that " }{XPPEDIT 18 0 "0 < c;" "6#2\"\"!%\"cG" }{TEXT -1 7 " and " }{XPPEDIT 18 0 "c \+ < 1;" "6#2%\"cG\"\"\"" }{TEXT -1 4 ". \n" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 76 "b := 205.17;\nc := 0.89783;\nP2 := plot(y(t),t=0..1 00):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 148 " \nMeasuring the fit. We can calculate the differences between the dat a values and the\nfunction values. These differences are called the r esiduals.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "res := [seq( YeastData[k,2]-y(YeastData[k,1]),k=1..nops(YeastData))];" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 347 "\nHere are three different ways to recor d the size of these residuals.\nWe can look at the sum of the absolute values of the residuals,\n the maximum of the absolute values of the \+ residuals, or \nthe sum of the squares of the residuals. \n\nThis las t measure, usually referred to as the \"sum of squared errors\"\nturns out to be one of the most useful.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "sum(res[k],k=1..nops(res));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "sum(abs(res[k]),k=1..nops(res));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "max(seq(abs(res[k]),k=1..nops(res)) );" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "sum(res[k]^2,k=1..nop s(res));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 16 "Measuring change" }}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 30 "Analyzing a Discrete Function\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 17 "Richer or Broker\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "\nWe \+ want to look at the differences in prices of a stock from day to day. \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "FwdDiff := proc(Y) lo cal k; [seq(Y[k]-Y[k-1], k=2..nops(Y))] end:#Define the FwdDiff functi on." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 236 "DiffTable := proc(X ,Y) local k, fd, sd;\n fd := FwdDiff(Y);\n sd \+ := FwdDiff(fd);\n linalg[transpose](convert([X,Y,[op(fd), \+ \"-\"],[op(sd),\"-\",\"-\"]],array));\n end:# Define the D iffTable function" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 147 "a := \+ [58.33, 59.04, 61.10, 62.27, 61.62, 59.26,\n 58.31, 57.92, 57.86 , 58.00, 59.11, 62.33, \n 67.84, 68.55, 69.96, 71.37, 71.96, 72. 15];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "pts := [seq([k-1, a [k]],k=1..nops(a))]:\nplot(pts,style=point);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "DiffTable([seq(k-1,k=1..nops(a))],a);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 164 "P1 := plot(pts,style=point) :\nfd := FwdDiff(a);\npts := [seq([k-1,fd[k]],k=1..nops(fd))]:\nP2 := \+ plot(pts, style=point, symbol=box, color=blue):\nplots[display](P1,P2) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 140 "sd := FwdDiff(fd);\np ts := [seq([k-1,sd[k]],k=1..nops(sd))]:\nP3 := plot(pts, style=point, \+ symbol=circle, color=green):\nplots[display](P2,P3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "pts := [seq([k-1, a[k]],k=1..nops(a))]:\n plot(pts,style=point, view=[4..11,57..65]);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 118 "b := [seq(100-a[k],k=1..nops(a))];\npts := [seq([ k-1, b[k]],k=1..nops(b))]:\nplot(pts,style=point, view=[4..11,35..43]) ;" }}{PARA 13 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 34 "Constructi ng Models from Patterns\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 27 "Sun \+ Microsystem's Revenues\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "r estart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 98 "FwdDiff := proc( Y) local k; \n [seq(Y[k]-Y[k-1], k=2..nops(Y))]\nend:#Define the Fwd Diff function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 280 "DiffTabl e := proc(XY) local k, X, Y, fd, sd;\n X := [seq(XY[k,1], k=1..nops (XY))];\n Y := [seq(XY[k,2], k=1..nops(XY))];\n fd := FwdDiff(Y); \n sd := FwdDiff(fd);\n linalg[transpose](convert([X,Y,[op(fd), \" -\"],[op(sd), \"-\", \"-\"]],array));\nend:# Define the DiffTable func tion" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 112 "SSE := proc(f,Xd,Y d) local k;\n sum((Yd[k]-f(Xd[k]))^2, k=1..nops(Xd));\nend:# Define \+ the Sum of Squared Errors." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 132 "LinReg := proc(Xd,Yd) local eq;\n eq := stats[fit,leastsquare[[ x,y], \n y=a*x+b, \{a,b\}]]([Xd,Yd]); \n unapply(rhs(eq),x);\ne nd:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 18 "\nThe Revenue data\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 110 "SunRev := [ 210.0, 538.0, \+ 1052.0, 1765.0, 2466.0, 3221.0,\n 3589.0, 4309.0, 4690.0, 59 02.0, 7095.0];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 124 "Xd := [s eq(85+k, k=1..nops(SunRev))]:\npts := [seq([Xd[k], SunRev[k]], k=1..no ps(SunRev))]:\nplot(pts,style=point, color=red);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 97 "fd := FwdDiff(SunRev);\na0 := sum(fd[k],k=1.. nops(fd))/nops(fd);\nb0 := solve(SunRev[1]=a0*86+b,b);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "DiffTable(pts);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 192 "a0 := (SunRev[11] - SunRev[1])/10;\nb0 := \+ solve(SunRev[1]=a0*86+b,b);\nf0 := t -> a0*t+b0;\nP1 := plot(pts,style =point, color=red):\nP2 := plot(f0(t),t=86..96,color=green):\nplots[di splay](P1,P2);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 86 "f1 := L inReg(Xd,SunRev);\nP3 := plot(f1(t),t=86..96,color=blue):\nplots[displ ay](P1,P3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "SS0 := SSE(f 0,Xd,SunRev);\nSS1 := SSE(f1,Xd,SunRev);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "f := x -> 3*x - 5;\npts := [seq([2*k-1,f(2*k-1)],k=1. .8)]:\nDiffTable(pts);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 19 "Bouncing Golf Ball\n" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 25 "\nPreliminary definitions." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 98 "FwdDiff := proc(Y) local k; \n [seq(Y[k]-Y[k -1], k=2..nops(Y))]\nend:#Define the FwdDiff function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 280 "DiffTable := proc(XY) local k, X, \+ Y, fd, sd;\n X := [seq(XY[k,1], k=1..nops(XY))];\n Y := [seq(XY[ k,2], k=1..nops(XY))];\n fd := FwdDiff(Y);\n sd := FwdDiff(fd);\n \+ linalg[transpose](convert([X,Y,[op(fd), \"-\"],[op(sd), \"-\", \"-\" ]],array));\nend:# Define the DiffTable function" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 112 "SSE := proc(f,Xd,Yd) local k;\n sum((Yd[k] -f(Xd[k]))^2, k=1..nops(Xd));\nend:# Define the Sum of Squared Errors. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 132 "LinReg := proc(Xd,Yd) \+ local eq;\n eq := stats[fit,leastsquare[[x,y], \n y=a*x+b, \{a, b\}]]([Xd,Yd]); \n unapply(rhs(eq),x);\nend:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 186 "QuadReg := proc(Xd,Yd) local k, eq;\n eq := stats[fit,leastsquare[[x,y], \n y=a*x^2+b*x+c, \{a,b,c\}]]([Xd,Y d]); \n unapply(rhs(eq),x);\nend:# Define the Quadratic Regression f unction" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "\nNow consider the dat a from the picture of the bouncing golf ball.\n" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 249 "Golf := [1.7, 4.3, 6.4, 8.2, 9.7, 10.9, 11.7, 12.3, 12.6, 12.5, 12.2, 11.6, 10.7,\n 9.5, 7.9, 5.9, 3.6, 0.9 ];\nXd := [seq(k-1,k=1..nops(Golf))];\npts := [seq([Xd[k], Golf[k]], \+ k=1..nops(Golf))]:\nplot(pts,style=point, symbol=circle, color=red);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 221 "\nThe plot looks a lot like th e photo. The y-values are the same, but the x-values are\nnot the sam e. How are the x-values related to the horizontal values in the photo ?\n\nLet's fit a least squares quadratic to this data.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 137 "g := QuadReg(Xd,Golf);\nP1 := plot (pts,style=point, symbol=circle, color=red):\nP2 := plot(g(x),x=0..17, color=blue):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "\nThis fit looks really good. Let's check the first and second differences of the data.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "DiffTable(pts);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "\nThe sec ond differences are all small negative numbers, which are fairly close together.\nThe first differences are steadily getting smaller. Let's \+ plot them.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 210 "fd := FwdD iff(Golf):\nP1 := plot([seq([k-1,fd[k]],k=1..nops(fd))],style=point,co lor=red,symbol=box):\nsd := FwdDiff(fd):\nP2 := plot([seq([k-1,sd[k]], k=1..nops(sd))],style=point,color=blue):\nplots[display](P1,P2);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 208 "\nThe first differences of the da ta almost lie on a straight line, and the second differences\nof the d ata are almost constant. Let's examine the first and second differenc es of the\nfitted quadratic function, " }{XPPEDIT 18 0 "g(x);" "6#-%\" gG6#%\"xG" }{TEXT -1 4 ". \n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 225 "gd := [seq(g(k),k=0..17)]:\nfd := FwdDiff(gd):\nP3 := plot([seq ([k-1,fd[k]],k=1..nops(fd))],style=point,symbol=box):\nsd := FwdDiff(f d):\nP4 := plot([seq([k-1,sd[k]],k=1..nops(sd))],style=point,color=blu e):\nplots[display](P3,P4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 229 " \nThe picture is nearly identical. The first differences seem to lie \+ on a straight line\nwith a negative slope, and the second differences \+ appear to be constant.\n\nLet's look at the first differences for anot her quadratic function\n" }{XPPEDIT 18 0 "f(x) = 3*x^2-16*x+5;" "6#/-% \"fG6#%\"xG,(*&\"\"$\"\"\"*$F'\"\"#F+F+*&\"#;F+F'F+!\"\"\"\"&F+" } {TEXT -1 5 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 138 "f := x -> 3*x^2-16*x+5;\nP1 := plot(f(x),x=-1..7):\nfd := [seq([k,f(k+1)-f (k)], k=0..7)];\nP2 := plot(fd,style=point):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 165 "\nIt certainly appears that th e first differences lie on a straight line with\na positive slope. In fact the slope appears to be 6.\nLet's check the Difference Table.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "pts := [seq([x,f(x)],x= 0..7)];\nDiffTable(pts);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "\nYe s, the first differences are increasing linearly.\nCan we provide some algebraic confirmation? Let Maple help us\nlook at the formula for \+ " }{XPPEDIT 18 0 "f(x+1)-f(x);" "6#,&-%\"fG6#,&%\"xG\"\"\"\"\"\"F)F)-F %6#F(!\"\"" }{TEXT -1 4 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "f(x+1) - f(x);\nsimplify(%);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 157 "\nVoila! The formula for the first difference is the formula \+ for a straight\nline with slope 6.\n\nWhat happens if we do this for a general quadratic function?\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "g := proc(x) a*x^2 + b*x + c end;\ng(x+1) - g(x);\nsimplify(%) ;" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 47 "Divided Differences and A verage Rate of Change\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 16 "Ponder osa Pines\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "\nPreliminary definitions" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 98 "FwdDiff := proc(Y) local k; \+ \n [seq(Y[k]-Y[k-1], k=2..nops(Y))]\nend:#Define the FwdDiff functio n." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 280 "DiffTable := proc(XY ) local k, X, Y, fd, sd;\n X := [seq(XY[k,1], k=1..nops(XY))];\n \+ Y := [seq(XY[k,2], k=1..nops(XY))];\n fd := FwdDiff(Y);\n sd := F wdDiff(fd);\n linalg[transpose](convert([X,Y,[op(fd), \"-\"],[op(sd) , \"-\", \"-\"]],array));\nend:# Define the DiffTable function" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 112 "SSE := proc(f,Xd,Yd) local \+ k;\n sum((Yd[k]-f(Xd[k]))^2, k=1..nops(Xd));\nend:# Define the Sum o f Squared Errors." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 132 "LinRe g := proc(Xd,Yd) local eq;\n eq := stats[fit,leastsquare[[x,y], \n \+ y=a*x+b, \{a,b\}]]([Xd,Yd]); \n unapply(rhs(eq),x);\nend:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 186 "QuadReg := proc(Xd,Yd) loca l k, eq;\n eq := stats[fit,leastsquare[[x,y], \n y=a*x^2+b*x+c, \{a,b,c\}]]([Xd,Yd]); \n unapply(rhs(eq),x);\nend:# Define the Quad ratic Regression function" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "DivDiff := proc(X,Y) \n local k; \n [seq((Y[k]-Y[k-1])/(X[k]-X [k-1]),\n k=2..nops(X))]\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 26 "\nThe Ponderosa Pine data.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 158 "Girth := [53.0, 60.0, 63.0, 72.0, 78.0, 88.0, 10 0.0, 119.0, 122.0, 129.0]; \nBoardFeet := [19.0, 26.0, 32.0, 48.0, 61. 0, 86.0, 128.0, 214.0, 232.0, 275.0];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "pts := [seq([Girth[k], BoardFeet[k]], k=1..nops(Girth ))]:\nplot(pts,style=point);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 196 "P1 := plot(pts,style=point):\nf1 := LinReg(Girth,BoardFeet);\nP 2 := plot(f1(x),x=53..129,color=blue):\nf2 := QuadReg(Girth,BoardFeet) ;\nP3 := plot(f2(x),x=53..129,color=red):\nplots[display](P1,P2,P3);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 96 "\nTo the eye, th e quadratic looks like a much better fit.\nWhat do the first differenc es tell us?\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "fd := FwdD iff(BoardFeet):\npts := [seq([Girth[k],fd[k]],k=1..nops(fd))]:\nplot(p ts,style=point);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 19 "\nThis is certainly " }{TEXT 306 3 "not" }{TEXT -1 337 " what we w ould expect to see from the first differences\nof a quadratic. What's wrong?\n\nThe problem is that the data are not equally spaced along t he x-axis. We\ncan't ignore that because a large difference in the y- values may not be all\nthat large when we consider the difference in t he x-values. The way to\naccount for this is to use " }{TEXT 307 19 " divided differences" }{TEXT -1 47 " which are computed\naccording to \+ the formula " }{XPPEDIT 18 0 "(y[n+1]-y[n])/(x[n+1]-x[n]);" "6#*&,&&% \"yG6#,&%\"nG\"\"\"\"\"\"F*F*&F&6#F)!\"\"F*,&&%\"xG6#,&F)F*\"\"\"F*F*& F16#F)F.F." }{TEXT -1 4 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 100 "dd := DivDiff(Girth,BoardFeet):\npts := [seq([Girth[k],dd[k]] ,k=1..nops(dd))]:\nplot(pts,style=point);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "\nThe first divided differences definitel y show a linear trend." }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 22 "Darin g Turnpike Drive\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "\nPreliminary definitions" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "DivDiff := proc(X,Y) \n \+ local k; \n [seq((Y[k]-Y[k-1])/(X[k]-X[k-1]),\n k=2..nops(X))]\nen d:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 19 "\nThe Turnpike Data\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 136 "Time := [0, 0.19, 0.35, 0.55, 0.77, 1.10, 1.43, 1.75, 2.00 ];\nDistance := [0, 13.0, 26.0, \+ 42.5, 60.0, 85.0, 110.0, 135.0, 150.0]; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "\nPlot the average speed (in miles per hour) for each str etch.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 109 "dd := DivDiff(T ime,Distance);\npts := [seq([Time[k],dd[k]],k=1..nops(dd))]:\nplot(pts ,0..2,55..85,style=point);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "\nNow consider the function " }{XPPEDIT 18 0 "f(x) = 2*x* cos(2.5*x);" "6#/-%\"fG6#%\"xG*(\"\"#\"\"\"F'F*-%$cosG6#*&$\"#D!\"\"F* F'F*F*" }{TEXT -1 145 ". We are interested\nin examining the average \+ rate of change of this function over different\nintervals. First cons ider intervals of length 1.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "f := proc(x) 2*x*cos(2.5*x) end;\nplot(f(x),x=-1..6);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 68 "\nConsider the average rate of cha nge over intervals of length 1\nfor " }{TEXT 311 1 "x" }{TEXT -1 22 " \+ ranging from 1 to 5.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 96 "X d := [seq(k,k=1..5)];\nYd := [seq(f(Xd[k]),k=1..5)]:\nevalf(Yd,5);\ndd := evalf(DivDiff(Xd,Yd),5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 104 " \nNow consider intervals of length 0.1. Also display the function and \nthe divided differences together.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 226 "Xd := [seq((1.0+0.1*k),k=0..40)]:\nYd := [seq(f(Xd[k +1]),k=0..40)]:\ndd := DivDiff(Xd,Yd):\npts := [seq([Xd[k],dd[k]],k=1. .nops(dd))]:\nP2 := plot(pts,-1..6,style=point,color=blue):\nP1 := plo t(f(x),x=-1..6):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 3 "\n " }{XPPEDIT 18 0 "Delta*g/(Delta*x) = (g(b)-g(a))/(b-a );" "6#/*(%&DeltaG\"\"\"%\"gGF&*&F%F&%\"xGF&!\"\"*&,&-F'6#%\"bGF&-F'6# %\"aGF*F&,&F/F&F2F*F*" }{TEXT -1 20 " \n\nThe linear case\n " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "g := proc(x) m*x+k end;\n(g( b)-g(a))/(b-a);\nsimplify(%);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 12 "Secant line\n" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 44 "\nSuppose that we have an arbitrary function " } {XPPEDIT 18 0 "f(x);" "6#-%\"fG6#%\"xG" }{TEXT -1 77 ", and suppose th at\nwe want the straight line that passes through the points (" } {XPPEDIT 18 0 "a,f(a);" "6$%\"aG-%\"fG6#F#" }{TEXT -1 7 ") and\n(" } {XPPEDIT 18 0 "b,f(b);" "6$%\"bG-%\"fG6#F#" }{TEXT -1 106 "). What's \+ the equation of that straight line?\n\nHere's what we can learn from M aple. First consider the \n" }{TEXT 308 16 "slope intercept " }{TEXT -1 5 "form " }{XPPEDIT 18 0 "m*x+k;" "6#,&*&%\"mG\"\"\"%\"xGF&F&%\"kGF &" }{TEXT -1 4 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "so lve(\{m*a+k=f(a),m*b+k=f(b)\},\{m,k\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "\nNote that the slope is " }{XPPEDIT 18 0 "(f(b)-f(a))/(b -a);" "6#*&,&-%\"fG6#%\"bG\"\"\"-F&6#%\"aG!\"\"F),&F(F)F,F-F-" }{TEXT -1 8 " .\n\nThe " }{TEXT 309 11 "point slope" }{TEXT -1 9 " form is " }{XPPEDIT 18 0 "m*(x-a)+k;" "6#,&*&%\"mG\"\"\",&%\"xGF&%\"aG!\"\"F&F&% \"kGF&" }{TEXT -1 3 ".\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "solve(\{m*(a-a)+k=f(a),m*(b-a)+k=f(b)\},\{m,k\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 163 "\nThe point slope form is a little easie r to remember. Of course, both the point\nslope form and the slope in tercept form have the same slope, and the slope is\nthe " }{TEXT 316 22 "average rate of change" }{TEXT -1 4 " in " }{XPPEDIT 18 0 "f(x);" "6#-%\"fG6#%\"xG" }{TEXT -1 17 " on the interval " }{TEXT 317 6 "(a, b )" }{TEXT -1 43 ".\n\nThis is so important that we define the " } {TEXT 318 5 "avgRC" }{TEXT -1 10 " function." }}{PARA 0 "" 0 "" {TEXT -1 2 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "avgRC := proc(f ,a,b)\n simplify((f(b)-f(a))/(b-a))\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "\nFinally there is the " }{TEXT 315 9 "two point" }{TEXT -1 6 " form " }{XPPEDIT 18 0 "alpha*(x-a)+beta*(b-x);" "6#,&*&%&alphaG \"\"\",&%\"xGF&%\"aG!\"\"F&F&*&%%betaGF&,&%\"bGF&F(F*F&F&" }{TEXT -1 4 "\n. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "solve(\{alpha*( a-a)+beta*(b-a)=f(a),alpha*(b-a)+beta*(b-b)=f(b)\},\{alpha,beta\});" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 41 "\nThe two point form is usually \+ written " }{XPPEDIT 18 0 "f(b);" "6#-%\"fG6#%\"bG" }{TEXT -1 1 " " } {XPPEDIT 18 0 "(x-a)/(b-a)+f(a);" "6#,&*&,&%\"xG\"\"\"%\"aG!\"\"F',&% \"bGF'F(F)F)F'-%\"fG6#F(F'" }{TEXT -1 1 " " }{XPPEDIT 18 0 "(b-x)/(b-a );" "6#*&,&%\"bG\"\"\"%\"xG!\"\"F&,&F%F&%\"aGF(F(" }{TEXT -1 92 " . \+ \nWritten this way it is easy to see that the function takes on the c orrect \nvalues at " }{XPPEDIT 18 0 "x = a;" "6#/%\"xG%\"aG" }{TEXT -1 8 " and " }{XPPEDIT 18 0 "x = b;" "6#/%\"xG%\"bG" }{TEXT -1 66 " . However, the value of the slope is not \nquite as obvious.\n\nThe \+ " }{TEXT 312 11 "point slope" }{TEXT -1 155 " form is the most conveni ent way to represent the secand line.\nWe can easily define a routine \+ for computing the secant line given the function\nand the two " } {TEXT 313 1 "x" }{TEXT -1 9 "-values.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 133 "SecantLine := proc(f,a,b) \n local slope,fa,x;\n \+ fa := simplify(f(a));\n slope := avgRC(f,a,b);\n unapply(slope*(x -a)+fa,x);\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "f := x \+ -> 2*x*cos(2.5*x);\nplot(f(x),x=-1..6,-12..12);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 58 "g := SecantLine(f,1,5);\nplot([f(x),g(x)],x=-1 ..6,-12..12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 167 "Xd := [se q(1+0.1*(k-1),k=1..41)]:\npts := [seq([Xd[k],avgRC(f,Xd[k],Xd[k]+0.1)] ,k=1..41)]:\nP1 := plot(f(x),x=-1..6):\nP2 := plot(pts,style=point):\n plots[display](P1,P2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 13 "Secant Movie\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart;\nwith(plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "avgRC := proc(f,a,b)\n simplify((f (b)-f(a))/(b-a))\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 133 " SecantLine := proc(f,a,b) \n local slope,fa,x;\n fa := simplify(f( a));\n slope := avgRC(f,a,b);\n unapply(slope*(x-a)+fa,x);\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 801 "SecantMovie := proc(f,n, a,b,x1,x2,y1,y2)\n local sl,pt,tt,dt,rho,k,h,slope,P1,P2,P3,P4;\n \+ sl := array(1..n);\n pt := array(1..n);\n tt := array(1..n);\n d t := 0.5;\n rho := exp(ln(0.001)/(n-1));\n for k from 1 to n do\n \+ h := rho^(k-1)*(b-a);\n slope := (f(a+h)-f(a))/h;\n sl[ k] := SecantLine(f,a,a+h);\n pt[k] := [[a,f(a)],[(a+h),f(a+h)]]; \n tt[k] := cat(\"Slope: \",convert(evalf(slope,4),string));\n \+ od; \n P1 := display(seq(plot(sl[k](x),x=x1..x2,y1..y2),k=1..n),in sequence=true):\n P2 := display(seq(plot(pt[k],style=point,symbol=ci rcle),k=1..n),insequence=true):\n P3 := animate(f(x),x=x1..x2,y=y1.. y2,color=black,frames=n):\n P4 := display(seq(textplot([a+dt,f(a)-dt ,tt[k]],align=RIGHT),k=1..n),insequence=true):\n display(P1,P2,P3,P4 ,view=[x1..x2,y1..y2]);\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "f := x -> 2*x*cos(2.5*x);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "SecantMovie(f,50,1,5,-1,6,-10,10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "SecantMovie(f,50,1.37,5.6,-1,6,-10,10);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 46 "Average Rate of Change and Se lected Exercises\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "avgRC := proc(f,a,b)\n simplify((f(b)-f(a))/(b-a))\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "f := x -> 2*x*cos(2.5*x);\navgRC(f,1,5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 19 "\nExercises 12 & 14\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "f := x -> m*x+b;\navgRC(f,x,x+h);\nf := x - > a*x^3+b*x^2+c*x+d;\navgRC(f,x,h);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "\nExercises 16, 18, and 20.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "f := x -> -3*x + 5;\nplot([f(x),avgRC(f,x-0.5,x+0.5)] ,x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "f := x -> sin( x);\nplot([f(x),avgRC(f,x-0.5,x+0.5)],x=0..6);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 56 "f := x -> 2^x;\nplot([f(x),avgRC(f,x-0.5,x+0.5 )],x=0..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 15 "Rate of Change\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 18 "Surfing in Bombay\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "\nPre liminary definitions" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 103 "Fw dDiff := proc(Y) \n local k; \n [seq(Y[k]-Y[k-1], k=2..nops(Y))] \+ \nend:#Define the FwdDiff function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 112 "SSE := proc(f,Xd,Yd) local k;\n sum((Yd[k]-f(Xd[k] ))^2, k=1..nops(Xd));\nend:# Define the Sum of Squared Errors." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 161 "SinReg2 := proc(w,Xd,Yd) lo cal eq;\n eq := stats[fit,leastsquare[[x,y],\n y = a*cos(w*x)+b *sin(w*x)+d,\n \{a,b,d\}]]([Xd,Yd]);\n unapply(rhs(eq),x);\nend :" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 240 "sdCount := proc(y) lo cal fd,sd,ct,sg,k;\n fd := FwdDiff(y);\n sd := FwdDiff(fd);\n ct := 0;\n sg := sd[1];\n for k from 2 to nops(sd) do\n if sg*s d[k] < 0 then\n sg := sd[k];\n ct := ct+1;\n fi; \n od;\n ct;\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3120 "SinReg1 := proc(wlo,whi,Xd,Yd) \n local k,w1,w2,w3,w4,rs1,rs2,rs3,r s4,\n SS1,SS2,SS3,SS4,ww,rs,SS,q,a,b,c,ans,gf;\n userinfo(3,Sin Reg,`wlo,whi:`,wlo,whi);\n w1 := wlo;\n rs1 := SinReg2(w1,Xd,Yd); \n SS1 := SSE(rs1,Xd,Yd);\n w4 := whi;\n rs4 := SinReg2(w4,Xd,Y d);\n SS4 := SSE(rs4,Xd,Yd);\n gf := evalf((sqrt(5)-1)/2);\n w3 := w1 + gf*(w4-w1);\n rs3 := SinReg2(w3,Xd,Yd);\n SS3 := SSE(rs3 ,Xd,Yd);\n w2 := w1 + gf*gf*(w4-w1);\n rs2 := SinReg2(w2,Xd,Yd); \n SS2 := SSE(rs2,Xd,Yd);\n userinfo(3,SinReg,\"w1,w2,w3,w4:\",w1, w2,w3,w4);\n userinfo(3,SinReg,\"SSE:\",SS1,SS2,SS3,SS4);\n q := \+ x -> a*x^2 + b*x + c;\n for k from 1 to 25 do\n if ((SS2 < SS1) and (SS2 < SS3) and (SS3 < SS4)) then\n w4 := w3;\n \+ rs4 := rs3;\n SS4 := SS3;\n ans := solve(\{q(w1)=SS1, \+ q(w2)=SS2, q(w3)=SS3\},\{a,b,c\});\n ww := -subs(ans,b)/(2*su bs(ans,a));\n if ((w1 < ww) and (ww < w2)) then\n w 3 := w2;\n rs3 := rs2;\n SS3 := SS2;\n \+ w2 := ww;\n rs2 := SinReg2(w2,Xd,Yd);\n SS2 \+ := SSE(rs2,Xd,Yd);\n elif ((w2 < ww) and (ww < w3)) then\n \+ w3 := ww;\n rs3 := SinReg2(w3,Xd,Yd);\n \+ SS3 := SSE(rs3,Xd,Yd);s;\n else\n w3 := w2;\n \+ rs3 := rs2;\n SS3 := SS2;\n w2 := w1 + \+ gf*(w3-w1);\n rs2 := SinReg2(w2,Xd,Yd);\n SS2 := SSE(rs2,Xd,Yd);\n fi;\n elif (SS2 < SS1) and (SS3 < SS2) and (SS3 < SS4) then\n w1 := w2;\n rs1 := rs2;\n \+ SS1 := SS2;\n ans := solve(\{q(w2)=SS2, q(w3)=SS3, q(w4)= SS4\},\{a,b,c\});\n ww := -subs(ans,b)/(2*subs(ans,a));\n \+ if ((w2 < ww) and (ww < w3)) then\n w2 := ww;\n \+ rs2 := SinReg2(w2,Xd,Yd);\n SS2 := SSE(rs2,Xd,Yd);\n \+ elif ((w3 < ww) and (ww < w4)) then\n w2 := w3;\n \+ rs2 := rs3;\n SS2 := SS3;\n w3 := ww ;\n rs3 := SinReg2(w3,Xd,Yd);\n SS3 := SSE(rs3,X d,Yd);\n else\n w2 := w3;\n rs2 := rs3; \n SS2 := SS3;\n w3 := w2 + gf*gf*(w4-w2);\n \+ rs3 := SinReg2(w3,Xd,Yd);\n SS3 := SSE(rs3,Xd,Yd); \n fi;\n elif SS2 < SS3 then\n w4 := w3;\n \+ rs4 := rs3;\n SS4 := SS3;\n w3 := w2;\n rs 3 := rs2;\n SS3 := SS2;\n w2 := w1 + gf*gf*(w4-w1);\n rs2 := SinReg2(w2,Xd,Yd);\n SS2 := SSE(rs2,Xd,Yd);\n \+ else\n w1 := w2;\n rs1 := rs2;\n SS1 := \+ SS2;\n w2 := w3;\n rs2 := rs3;\n SS2 := SS3; \n w3 := w1 + gf*(w4-w1);\n rs3 := SinReg2(w3,Xd,Yd); \n SS3 := SSE(rs3,Xd,Yd);\n fi;\n userinfo(3,SinReg, \"w1,w2,w3,w4:\",w1,w2,w3,w4);\n userinfo(3,SinReg,\"SSE:\",SS1,S S2,SS3,SS4);\n if (abs(w4-w1) < 0.001*w4) then\n break;\n fi;\n od;\n SS := min(SS1,SS2,SS3,SS4);\n if (SS1 = SS) th en\n rs1;\n elif (SS2 = SS) then \n rs2;\n elif (SS3 = S S) then\n rs3;\n else\n rs4;\n fi;\nend:# Define the Sin usoidal Regression function" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1064 "SinReg := proc(Xd,Yd) \n local k,cnt,w0,Sk,SS,kk,rs,A,B,a,b,c, d;\n cnt := sdCount(Yd);\n userinfo(3,SinReg,`Count:`,cnt);\n if cnt < 2 then\n cnt := 2;\n fi;\n # We assume that the data \+ covers at least a quarter of the period.\n w0 := evalf(0.5*Pi/abs(Xd [nops(Xd)]-Xd[1]));\n kk := 1;\n rs := SinReg2(kk*w0,Xd,Yd);\n S S := SSE(rs,Xd,Yd);\n userinfo(3,SinReg,`w, SS:`,w0, SS);\n for k \+ from 2 to 2*cnt+2 do\n rs := SinReg2(k*w0,Xd,Yd);\n Sk := SS E(rs,Xd,Yd);\n userinfo(3,SinReg,`w, SS:`,k*w0, Sk);\n if Sk < SS then\n kk := k;\n SS := Sk;\n fi;\n od;\n if kk = 1 then\n rs := SinReg1(w0,3*w0,Xd,Yd);\n elif kk = 2 *cnt+2 then\n rs := SinReg1(2*cnt*w0,(2*cnt+2)*w0,Xd,Yd);\n els e\n rs := SinReg1((kk-1)*w0,(kk+1)*w0,Xd,Yd);\n fi;\n userinf o(3,SinReg,`rs`,rs(x));\n A := op(1,op(1,rs(x)));\n B := op(1,op(2 ,rs(x)));\n a := sqrt(A^2+B^2);\n b := op(1,op(1,op(2,op(1,rs(x))) ));\n c := arctan(A,B);\n d := op(3,rs(x));\n unapply(a*sin(b*x+ c)+d,x);\nend:# Define the Sinusoidal Regression function" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 310 13 "\nThe Tide dat" }{TEXT -1 2 "a\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 186 "Hour := [ 6, 7, 8, \+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];\nDep th := [2.5, 2.7, 4.5, 7.5, 11.1, 14.5, 17.0, 18.0, 17.2, 15.0, 11.7, 8 .0, 4.9, 2.9, 2.5]; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "pts := [seq([Hour[k],Depth[k]],k=1..nops(Hour))]:\nplot(pts,style=point); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "Bombay := SinReg(Hour,D epth);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 130 "P1 := plot(pts,s tyle=point,color=blue):\nP2 := plot(Bombay(x),x=6..20,2..20):\nplots[d isplay](P1,P2);\nSS5 := SSE(Bombay,Hour,Depth);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 1 "\n" }{TEXT 314 11 "Zooming In\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 172 "pt := [[11,Bombay(11)]];\na := 8;\nb := 14 ;\nP1 := plot(pt,view=[8..14,6..18],style=point):\nP2 := plot(Bombay(x ),x=a..b):\nplots[display](P1,P2);\n(Bombay(b)-Bombay(a))/(b-a);" }} {PARA 13 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 175 "pt := [[11,Bombay(11)]];\na := 10;\nb := 12;\nP1 := plot(pt,v iew=[10..12,11..17],style=point):\nP2 := plot(Bombay(x),x=a..b):\nplot s[display](P1,P2);\n(Bombay(b)-Bombay(a))/(b-a);" }}{PARA 13 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 187 "pt := [[11 ,Bombay(11)]];\na := 10.9;\nb := 11.1;\nP1 := plot(pt,view=[10.9..11 .1,14.2..14.8],style=point):\nP2 := plot(Bombay(x),x=a..b):\nplots[dis play](P1,P2);\n(Bombay(b)-Bombay(a))/(b-a);" }}{PARA 13 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 194 "pt := [[11,Bomba y(11)]];\na := 10.99;\nb := 11.01;\nP1 := plot(pt,view=[10.99..11.01 ,14.49...14.56],style=point):\nP2 := plot(Bombay(x),x=a..b):\nplots[di splay](P1,P2);\n(Bombay(b)-Bombay(a))/(b-a);" }}{PARA 13 "" 0 "" {TEXT -1 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 20 "Bombay Secant M ovie\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart;\nwith(plo ts):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "avgRC := proc(f,a,b )\n simplify((f(b)-f(a))/(b-a))\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 133 "SecantLine := proc(f,a,b) \n local slope,fa,x;\n \+ fa := simplify(f(a));\n slope := avgRC(f,a,b);\n unapply(slope*(x -a)+fa,x);\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 801 "Secant Movie := proc(f,n,a,b,x1,x2,y1,y2)\n local sl,pt,tt,dt,rho,k,h,slope ,P1,P2,P3,P4;\n sl := array(1..n);\n pt := array(1..n);\n tt := \+ array(1..n);\n dt := 0.5;\n rho := exp(ln(0.001)/(n-1));\n for k from 1 to n do\n h := rho^(k-1)*(b-a);\n slope := (f(a+h)-f (a))/h;\n sl[k] := SecantLine(f,a,a+h);\n pt[k] := [[a,f(a)] ,[(a+h),f(a+h)]];\n tt[k] := cat(\"Slope: \",convert(evalf(slope, 4),string));\n od; \n P1 := display(seq(plot(sl[k](x),x=x1..x2,y 1..y2),k=1..n),insequence=true):\n P2 := display(seq(plot(pt[k],styl e=point,symbol=circle),k=1..n),insequence=true):\n P3 := animate(f(x ),x=x1..x2,y=y1..y2,color=black,frames=n):\n P4 := display(seq(textp lot([a+dt,f(a)-dt,tt[k]],align=RIGHT),k=1..n),insequence=true):\n di splay(P1,P2,P3,P4,view=[x1..x2,y1..y2]);\nend:" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 51 "Bombay := x -> 7.78*sin(0.47146*x +1.688) + 10 .186;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "SecantMovie(Bombay ,35,11,18,6,20,0,25);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 13 "Tangen t Line\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 167 "TangentLine := proc(f,a)\n \+ local slope,fa;\n fa := simplify(f(a));\n slope := simplify(D(f) (a));\n unapply(slope*(x-a)+fa,x);\nend:# Define the TangentLine fun ction" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "Bombay := x -> 7.7 80117521*sin(.4714658670*x+1.688424783)+10.18610980;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 144 "f := TangentLine(Bombay,11);\npt := [[11 ,Bombay(11)]];\nP1 := plot(pt,style=point):\nP2 := plot([Bombay,f],8.. 14,color=red):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 186 "Hour := [ 6, 7, 8, 9, 10, 11, 12, 13 , 14, 15, 16, 17, 18, 19, 20];\nDepth := [2.5, 2.7, 4.5, 7.5 , 11.1, 14.5, 17.0, 18.0, 17.2, 15.0, 11.7, 8.0, 4.9, 2.9, 2.5]; " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 147 "pts := [seq([Hour[k],Depth[ k]],k=1..nops(Hour))]:\nP1 := plot(pts,style=point):\nP2 := plot([Bomb ay,f],6..20,2..22,color=red):\nplots[display](P1,P2);" }}}}}{SECT 0 {PARA 4 "" 0 "" {TEXT -1 29 "Rate of Change as a Function\n" }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 16 "Plotting Slopes\n" }}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 55 "avgRC := proc(f,a,b)\n simplify((f(b)-f(a))/(b-a))\nend:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 261 "Xd := [0,Pi/6,Pi/4,Pi/3,Pi/ 2,2*Pi/3,3*Pi/4,5*Pi/6,Pi,\n 7*Pi/6,5*Pi/4,4*Pi/3,3*Pi/2,5*Pi/3, 7*Pi/4,11*Pi/6,2*Pi];\npts := [seq([Xd[k],sin(Xd[k])],k=1..nops(Xd))]: \nP1 := plot(pts,style=point,symbol=circle):\nP2 := plot(sin(x),x=0..2 *Pi):\nplots[display](P1,P2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 116 "h := 0.25;\nZd := [seq(evalf(avgRC(sin,Xd[k]-h,Xd[k]+h),4),k=1. .nops(Xd))];\nfp := [seq(D(sin)(Xd[k]),k=1..nops(Xd))];" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "sin(Pi/3);\nD(sin)(Pi/3);\n\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 42 "Bombay := x -> 7.78*sin(.471 *x+1.69)+10.2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "pts := [s eq([k,D(Bombay)(k)],k=0..12)]:\nplot(pts,style=point);\n\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "plot([Bombay(x),D(Bombay)(x)],x=0.. 12);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "f := x -> x^2;\nplo t([f(x),D(f)(x)],x=-2..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "g := x -> 3 + x^2;\nplot([g(x),D(g)(x)],x=-2..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "f := x -> abs(5 - x^2);\nD(f);\nplo t([f(x),D(f)(x)],x=-4..4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(f(x),x=-4..4,-5..10);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(f(x),x=2..2.5,-1..1);" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 46 "Average Rate of Change and Selected Exercises\n" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 55 "avgRC := proc(f,a,b)\n simplify((f(b)-f(a))/(b-a)) \nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "\nExercises 12, 18, and 20.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "f := x -> -3*x + \+ 5;\nplot([f(x),avgRC(f,x-0.5,x+0.5),D(f)(x)],x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "plot((avgRC(f,x-0.5,x+0.5) - D(f)(x )),x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "f := x -> si n(x);\nplot([f(x),avgRC(f,x-0.5,x+0.5),D(f)(x)],x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "plot((avgRC(f,x-0.5,x+0.5) - D(f)(x )),x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "f := x -> 2^ x;\nplot([f(x),avgRC(f,x-0.5,x+0.5),D(f)(x)],x=0..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "plot((avgRC(f,x-0.5,x+0.5) - D(f)(x )),x=0..6);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "2 5 2" 0 } {VIEWOPTS 1 1 0 1 1 1803 }