{VERSION 7 1 "Windows XP" "7.1" } {USTYLETAB {PSTYLE "Heading 4" -1 20 1 {CSTYLE "" -1 -1 "Times" 1 10 0 0 0 1 1 1 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Ord ered List 5" -1 200 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 144 2 0 2 2 -1 1 }{PSTYLE "Ordered List 1" -1 201 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 0 2 0 2 2 -1 1 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Bullet Item" -1 15 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 0 2 0 2 2 -1 1 }{PSTYLE "Lef t Justified Maple Output" -1 12 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Help" -1 10 1 {CSTYLE "" -1 -1 "Courier" 1 9 0 0 255 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Author" -1 19 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }3 1 0 0 8 8 2 0 2 0 2 2 -1 1 }{PSTYLE "Diagnostic" -1 9 1 {CSTYLE "" -1 -1 "Courier" 1 10 64 128 64 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Headi ng 2" -1 4 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 0 0 1 }1 1 0 0 8 2 2 0 2 0 2 2 -1 1 }{PSTYLE "Ordered List 3" -1 202 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 72 2 0 2 2 -1 1 }{PSTYLE "Maple Plot" -1 13 1 {CSTYLE "" -1 -1 "Tim es" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }3 1 0 0 0 0 2 0 2 0 2 2 -1 1 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Dash Item" -1 16 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 0 2 0 2 2 -1 1 }{PSTYLE "Heading 3" -1 5 1 {CSTYLE "" -1 -1 "Times " 1 12 0 0 0 1 1 1 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 } {PSTYLE "Ordered List 4" -1 203 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 108 2 0 2 2 -1 1 }{PSTYLE "Maple \+ Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }3 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Line Printed Output" -1 6 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "List Item" -1 14 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 0 2 0 2 2 -1 1 }{PSTYLE "Warning" -1 7 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Error" -1 8 1 {CSTYLE "" -1 -1 "Courier" 1 10 255 0 255 1 2 2 2 2 2 1 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Fixed Width" -1 17 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }3 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 0 0 1 }1 1 0 0 8 4 2 0 2 0 2 2 -1 1 }{PSTYLE "Title " -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 0 0 1 }3 1 0 0 12 12 2 0 2 0 2 2 -1 1 }{PSTYLE "Ordered List 2" -1 204 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 3 3 2 36 2 0 2 2 -1 1 }{CSTYLE "Help Variable" -1 25 "Courier" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Text" -1 200 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Bold" -1 39 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Page Number" -1 33 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "2D Math Italic Small" -1 201 "Times" 1 1 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Nonterminal" -1 24 "Courier" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Default" -1 38 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Maple Comment" -1 21 "Courier" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Maple Input" -1 0 "Courier" 1 12 255 0 0 1 2 1 2 2 1 2 0 0 0 1 }{CSTYLE "2D Math Small" -1 7 "Times " 1 1 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Fixed" -1 23 "Courier " 1 10 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Popup" -1 31 "Times" 1 12 0 128 128 1 1 2 1 2 2 2 0 0 0 1 }{CSTYLE "Plot Title" -1 27 "Times" 1 10 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "2D Input" -1 19 "Times" 1 12 255 0 0 1 2 2 2 2 1 2 0 0 0 1 }{CSTYLE "Copyright" -1 34 "Times" 1 10 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Maple Input Placeholder" -1 202 "Courier" 1 12 200 0 200 1 2 1 2 2 1 2 0 0 0 1 }{CSTYLE "2D Math Bold Small" -1 10 "Times" 1 1 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "2D Mat h" -1 2 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Notes" -1 37 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Help Underli ned Bold" -1 41 "Times" 1 12 0 0 0 1 1 1 2 2 2 2 0 0 0 1 }{CSTYLE "Hyp erlink" -1 17 "Times" 1 12 0 128 128 1 2 2 1 2 2 2 0 0 0 1 }{CSTYLE "2 D Math Symbol 2" -1 16 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 } {CSTYLE "Plot Text" -1 28 "Times" 1 8 0 0 0 1 2 2 2 2 2 2 0 0 0 1 } {CSTYLE "Help Italic" -1 42 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 } {CSTYLE "Output Labels" -1 29 "Times" 1 8 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Heading" -1 26 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Help Normal" -1 30 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "2D Comment" -1 18 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Maple Name" -1 35 "Times" 1 12 104 64 92 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "2D Output" -1 20 "Times" 1 12 0 0 255 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Dictionary Hyperlink" -1 45 "Times" 1 12 147 0 15 1 2 2 1 2 2 2 0 0 0 1 }{CSTYLE "Help Emphasized" -1 22 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Italic Bold" -1 40 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "Help Menus" -1 36 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "LaTeX" -1 32 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "Prompt" -1 1 "Courier" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "Help Underlined" -1 44 "Times" 1 12 0 0 0 1 2 2 1 2 2 2 0 0 0 1 }{CSTYLE "Help Underlined Italic" -1 43 "Times" 1 12 0 0 0 1 1 2 1 2 2 2 0 0 0 1 }{CSTYLE "2D Math Bold" -1 5 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "2D Math Italic" -1 3 "Times " 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{PSTYLE "" -1 205 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 0 0 1 }3 1 0 0 8 4 2 0 2 0 2 2 -1 1 }{CSTYLE "" -1 203 "Times" 1 12 0 128 0 1 1 1 2 2 2 2 0 0 0 1 } {CSTYLE "" -1 204 "Times" 1 12 255 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 205 "Times" 1 12 0 128 0 1 1 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 206 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 207 "Tim es" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 208 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 209 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 210 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 211 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 212 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 } {CSTYLE "" -1 213 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 214 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 215 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 216 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 217 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 218 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 219 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 220 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 } {CSTYLE "" -1 221 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 222 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 223 "T imes" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 224 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 225 "Times" 1 12 255 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 226 "Times" 1 12 255 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 227 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 228 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 } {CSTYLE "" -1 229 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 230 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 231 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 232 "Tim es" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 233 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 234 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 235 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 236 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 237 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 } {PSTYLE "" -1 206 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 255 1 2 2 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{CSTYLE "" -1 238 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 239 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 240 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 241 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 242 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 243 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 244 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{PSTYLE "" -1 207 1 {CSTYLE "" -1 -1 "Times" 1 12 0 128 0 1 1 1 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{CSTYLE "" -1 245 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 246 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 247 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 248 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 249 "Times " 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 250 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 251 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 252 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 253 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 254 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 } {CSTYLE "" -1 255 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 256 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 257 "T imes" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 258 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "" -1 259 "Times" 1 12 255 0 0 1 2 2 2 2 2 2 0 0 0 1 }{PSTYLE "" -1 208 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 } {PSTYLE "" -1 209 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 1 2 2 2 2 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 205 "" 0 "" {TEXT 200 21 "Numerical Integration" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }} {PARA 0 "" 0 "" {TEXT 203 289 "Note: While reading this worksheet make sure that you re-execute each command by placing the cursor on the co mmand line and pressing Enter. You should do this with every worksheet , but it is even more important with this one. If you don't re-execute commands defining the integration rules" }{TEXT 260 1 " " }{TEXT 204 29 "LEFT, RIGHT, TRAP, MID, SIMP," }{TEXT 260 2 " " }{TEXT 205 179 "M aple will not recognize them and you won't be able to solve your homew ork problems. You have to re-execute the commands in the same Maple \+ session in which you do your homework." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 586 "You have learned how to es timate definite integrals using left and right Riemann sums as well as three other methods: the trapezoid, midpoint and Simpson's rules. In \+ certain situations it is possible to tell if your estimates are too hi gh or too low without actually knowing the exact value of your integra l. For example, if the function is concave up on the interval of integ ration, the trapezoid rule overestimates and the midpoint rule underes timates. In this worksheet we will explore some other aspects of these approximations. Refer to Sec.7.5, 7.6 of you textbook for background. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 4 "" 0 "" {TEXT 261 39 "Numerical In tegration Rules Using Maple" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 108 "Maple has all the above mentioned rul es of numerical integration programmed in. They are available in the \+ \"" }{TEXT 206 7 "student" }{TEXT 260 40 "\" package. However, the rul es in the \"" }{TEXT 207 7 "student" }{TEXT 260 374 "\" package are de fined slightly differently than in our textbook. To be consistent with the text, we shall program Maple to calculate approximations correspo nding to each of the rules the way our book does. Although you are not expected to learn Maple programming at this time, you may want to loo k at the structure of our little programs below. In these programs we \+ define " }{TEXT 208 10 "procedures" }{TEXT 260 215 " in Maple for cal culating the left and right Riemann sums, trapezoid approximation, mid point approximation and Simpson's approximation, for any given functio n f, interval [a,b], and the number of subdivisions n. \"" }{TEXT 209 4 "proc" }{TEXT 260 58 "\" stands for procedure. In parentheses are th e variables " }{TEXT 210 7 "f,a,b,n" }{TEXT 260 84 " which we will hav e to specify each time we apply any of the procedures. The name \"" } {TEXT 211 5 "local" }{TEXT 260 14 "\" preceeding " }{TEXT 212 1 "h" } {TEXT 260 5 " and " }{TEXT 213 1 "i" }{TEXT 260 162 " tells Maple that these variables are to be used as indicated in the procedure, and not to be confused with variables of the same name which may appear elsew here." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 84 "LEFT:= proc (f,a,b,n) local h,i; h:=(b-a)/n; evalf(su m(f(a+i*h)*h,i=0..(n-1))); end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "RIGHT:= proc (f,a,b,n) local h,i; h:=(b-a)/n; evalf(sum(f(a+i* h)*h,i=1..n)); end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "TRAP := proc (f,a,b,n) evalf((LEFT(f,a,b,n)+RIGHT(f,a,b,n))/2); end:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 90 "MID:= proc (f,a,b,n) local h ,i; h:=(b-a)/n; evalf(sum(f(a+(i+1/2)*h)*h, i=0..(n-1))); end:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 "SIMP:= proc (f,a,b,n) evalf( (2*MID(f,a,b,n)+TRAP(f,a,b,n))/3); end:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 204 "Notice how these proce dures reflect the mathematical definitions of the corresponding numeri cal integration rules. In order to apply each of the procedures define d above, you need to give your function a " }{TEXT 214 4 "name" }{TEXT 260 6 ", say:" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 10 "w:=x->x^2;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# >%\"wGf*6#%\"xG6\"6$%)operatorG%&arrowGF(*$)F'\"\"#\"\"\"F(F(F(" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 260 84 "To calculate the corresponding nu merical approximation of an integral, for example " }{XPPEDIT 18 0 "i nt(w(x), x = 0 .. 1);" "6#-%$intG6$-%\"wG6#%\"xG/F);\"\"!\"\"\"" } {TEXT 260 59 ", for, say, n =50 divisions, you use the following synt ax:" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "LEFT(w,0,1,50);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"++++MK!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "SIMP(w,0,1,5 0);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+LLLLL!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 11 "a nd so on. " }{TEXT 215 37 "You have to give your function a name" } {TEXT 260 90 "; the syntax LEFT(x^2,0,1,50) will not work. (Do you see why by looking at the programs?) " }}{PARA 0 "" 0 "" {TEXT 260 0 "" } }{PARA 0 "" 0 "" {TEXT 260 125 "Once we have the rules of numerical in tegration programmed in, we can begin conducting numerical experimenta tion with Maple. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 4 "" 0 "" {TEXT 261 51 "The Errors in Midpoint and Trapezoid Approximati ons" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 104 "Let's choose an interesting function whose antiderivative cannot be f ound in simple terms. For example, " }{XPPEDIT 18 0 "f(x) = sin(x^2);" "6#/-%\"fG6#%\"xG-%$sinG6#*$)F'\"\"#\"\"\"" }{TEXT 260 38 ". Let's d efine the function in Maple:" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "f:=x->sin(x^2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fGf*6#%\"xG6\"6$%)operatorG%&arrowGF(-%$sin G6#*$)F'\"\"#\"\"\"F(F(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 37 "Sup pose we want to find the integral " }{XPPEDIT 18 0 "int(f(x), x = 0 .. 1);" "6#-%$intG6$-%\"fG6#%\"xG/F);\"\"!\"\"\"" }{TEXT 260 91 " . For \+ the purpose of error analysis, we ask Maple to find the exact value of the integral:" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 38 "A:=Int(f(x),x=0..1); ExactA:=value(A);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG-%$IntG6$-%$sinG6#*$)%\"xG\"\"# \"\"\"/F-;\"\"!F/" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'ExactAG,$**#\" \"\"\"\"#F(-%)FresnelSG6#*&*$-%%sqrtG6#F)F(F(*$-F06#%#PiGF(!\"\"F(F/F( F3F(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 239 "The exact value is in terms of some function \"Fresnel\" that we don't know. Let's use the \+ command \"evalf\", which by default will give us an approximation of t he exact value to ten decimal places. Let it be our reference \"exact \" value." }}{PARA 0 "" 0 "" {TEXT 260 1 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "exactA:=evalf(ExactA);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'exactAG$\"+8Io-J!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 58 "Let's explor e the error of approximation for our integral " }{TEXT 216 1 "A" } {TEXT 260 175 " using the trapezoid and the midpoint rules for n=25 an d n=50 divisions. Let's label the results of applying the trapezoid a nd midpoint rules by T1, T2, M1, M2, respectively." }}{PARA 0 "" 0 "" {TEXT 260 1 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "T1:=TRAP( f,0,1,25);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#T1G$\"+PV7/J!#5" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "T2:=TRAP(f,0,1,50);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%#T2G$\"+_K/.J!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "M1:=MID(f,0,1,25);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#M1G$\"+m@'>5$!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "M2:=MID(f,0,1,50);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>%#M2G$\"+))G]-J!#5" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }} {PARA 0 "" 0 "" {TEXT 260 56 "Recall that the error of an approximatio n is defined as " }{TEXT 217 38 "Error = Exact value- Approximate valu e" }{TEXT 260 113 ". Let's calculate the errors corresponding to the \+ approximations that we obtained above. We label the errors as " }{TEXT 218 7 "ErrorT1" }{TEXT 260 2 ", " }{TEXT 219 7 "ErrorT2" }{TEXT 260 6 ", etc." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 40 "ErrorT1:=exactA-T1; ErrorT2:=exactA-T2; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(ErrorT1G$!(C8W\"!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(ErrorT2G$!'R-O!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "ErrorM1:=exactA-M1; ErrorM2:=exactA-M2;" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%(ErrorM1G$\"'Z3s!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(ErrorM2G$\"'D,=!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 435 "Observe tha t the midpoint errors are of the opposite sign than the corresponding \+ trapezoid errors, and the magnitude of each midpoint error is, roughly , half of the magnitude of the corresponding trapezoid error. Indeed, \+ let's calculate the corresponding ratios. More precisely, let's calcul ate the ratios of absolute values of errors as we are only interested \+ in ratios of magnitudes of errors. The syntax for the absolute value i s \"" }{TEXT 220 12 "abs(ErrorM1)" }{TEXT 260 10 "\" , etc. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 67 " evalf(abs(ErrorM1)/abs(ErrorT1)); evalf(abs(ErrorM2)/abs(ErrorT2));" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+UNG,]!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+wE:+]!#5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 161 "More numerical experimen tation, with integrals of different functions over different intervals , confirms the above observation. This leads to the following rule." } }{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 221 14 "Rule of Thumb." }{TEXT 260 2 " " }{TEXT 222 217 "For the same num ber of divisions, the magnitude of the midpoint erorr is, roughly, hal f the magnitude of the trapezoid error. If the concavity is constant, the signs of the midpoint and trapezoid errors are opposite." }} {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 114 "(See t he discussion on page 352 of the book. There is a good theoretical rea son why this \"rule of thumb\" holds.)" }}{PARA 11 "" 1 "" {TEXT 262 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 223 11 "Problem 1. " }{TEXT 260 22 " Define the function " }{XPPEDIT 18 0 "g(x) = sqrt(2+x^2);" "6#/- %\"gG6#%\"xG-%%sqrtG6#,&\"\"#\"\"\"*$)F'F,F-F-" }{TEXT 260 271 " . Exp lore the validity of the above rule of thumb by using Maple to calcula te TRAP(g,a,b,n), MID(g,a,b,n) for several values of a,b,n. Calculate the corresponding \"exact\" values, the corresponding errors and quot ients. Write a sentence or two describing your results." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 101 "As you kn ow, the Rule of Thumb above leads to yet another numerical scheme call ed the Simpson's rule." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 4 "" 0 "" {TEXT 261 57 "Speed of Convergence. The Effe cts of Doubling n on Errors" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 394 "The main question when studying a numerical m ethod is how fast the approximation provided by the method converges t o the exact value. One way to measure the speed of convergence for our numerical integration schemes is to see how the error decreases when we double the number of divisions n. Hence, for each of our rules of numerical integration we would like to answer the question: by what " }{TEXT 224 5 "ratio" }{TEXT 260 103 " does the error decrease when n \+ is doubled? Below we investigate this question for the trapezoid rule. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 51 "As our test example we shall use the same function " }{XPPEDIT 18 0 "f(x ) = sin(x^2);" "6#/-%\"fG6#%\"xG-%$sinG6#*$)F'\"\"#\"\"\"" }{TEXT 260 18 " and the integral " }{XPPEDIT 18 0 "A = int(f(x), x = 0 .. 1);" "6 #/%\"AG-%$intG6$-%\"fG6#%\"xG/F+;\"\"!\"\"\"" }{TEXT 260 168 " as in t he previous section. We shall calculate trapezoid approximations, corr esponding errors and ratios for many values of n. It will be convenie nt to use so called " }{TEXT 225 5 "lists" }{TEXT 260 4 ". A " }{TEXT 226 4 "list" }{TEXT 260 245 " in Maple is a sequence of things separat ed by commas and enclosed by square brackets. The order of elements in a list matters. The latter distinguishes a list of elements from a se t of elements. Let's define our list of n values and label it L." } {TEXT 227 1 " " }{TEXT 260 43 "Observe that the next entry is obtained by " }{TEXT 228 8 "doubling" }{TEXT 260 18 " the previous one." }} {PARA 0 "" 0 "" {TEXT 260 3 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "L:=[5,10,20,40,80,160];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>% \"LG7(\"\"&\"#5\"#?\"#S\"#!)\"$g\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 18 "For a given list, " }{TEXT 229 1 "L" }{TEXT 260 20 " we use t he syntax " }{TEXT 230 4 "L[i]" }{TEXT 260 52 " to denote the i-th ele ment of the list. For example" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "L[3]; L[4];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#?" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#S" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 361 "Now we want to calculate the trapezoid approximations f or our function f, a=0, b=1, for all six values n from list L. Instead of typing six separate commands and labeling the results T1, T2, etc , we can calculate all six approximations at once and put them in a li st. We shall label the list Ts. We obtain the list of approximations u sing the following syntax." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "Ts:=[seq(TRAP(f,0,1,L[i]),i= 1..6)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#TsG7($\"+=F5$F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 33 "Observe how we use the command \"" }{TEXT 231 3 "seq" }{TEXT 260 130 "\", which stands for \"sequence\", to evaluate TRAP(f,0,1,L[i ]) for all elements in the list L from i=1 to i=6. We surround the \"" }{TEXT 232 3 "seq" }{TEXT 260 67 "\" command with square brackets so \+ that the result is another list." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }} {PARA 0 "" 0 "" {TEXT 260 24 "We have obtained a list " }{TEXT 233 3 " Ts " }{TEXT 260 85 "of values of trapezoid approximations correspondin g to the six values of n from list " }{TEXT 234 1 "L" }{TEXT 260 75 ". Now we shall make a list of errors corresponding to values from the l ist " }{TEXT 235 2 "Ts" }{TEXT 260 34 ". The list of errors is labeled \"" }{TEXT 236 7 "ErrorTs" }{TEXT 260 63 "\". Recall that our referen ce exact value of the integral A is " }{TEXT 237 6 "exactA" }{TEXT 260 1 "." }}{PARA 0 "" 0 "" {TEXT 260 1 " " }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 36 "ErrorTs:=[seq(exactA-Ts[i],i=1..6)];" }}{PARA 206 " " 1 "" {XPPMATH 20 "6#>%(ErrorTsG7($!)/CMO!#5$!(*4D!*F($!( " 0 "" {MPLTEXT 1 0 0 "" }} }{EXCHG {PARA 0 "" 0 "" {TEXT 260 189 "Finally, we want to set up the \+ corresponding list of ratios of magnitudes of consecutive errors. Reca ll that these are the errors corresponding to values of n that are dou bled at each step." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "RatioErrorTs:=[seq(abs(ErrorTs[i])/abs(Err orTs[i+1]),i=1..5)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%-RatioErrorT sG7'$\"+(*\\\"o-%!\"*$\"+!)Hn1SF($\"++vl,SF($\"+\")*)>+SF($\"+H5!)**RF (" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 328 "What do these numbers tell us about the effects of doubling n on the error for the trapezoid rule? It seems that doublin g n causes the magnitude of the error to decrease by the factor of 4. \+ It is so in general. More numerical experimentation, with different fu nctions on different intervals leads to the following rule of thumb." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT 238 14 "Rule of Thumb." }{TEXT 260 2 " " }{TEXT 239 127 "For \+ the trapezoid rule, doubling the number of divisions n causes the magn itute of the error to decrease by the factor of four." }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 240 12 "Problem 2. " }{TEXT 260 44 "In this problem, use the same test function " } {XPPEDIT 18 0 "f(x) = sin(x^2);" "6#/-%\"fG6#%\"xG-%$sinG6#*$)F'\"\"# \"\"\"" }{TEXT 260 14 " and integral " }{XPPEDIT 18 0 "A = int(f(x), x = 0 .. 1);" "6#/%\"AG-%$intG6$-%\"fG6#%\"xG/F+;\"\"!\"\"\"" }{TEXT 260 10 " as above." }}{PARA 0 "" 0 "" {TEXT 260 281 " (a) Inves tigate the effects of doubling n on the error for the right rule RIGHT (f,a,b,n). Calculate the corresponding errors and ratios for a list of doubling values of n. Use lists in your work with Maple as in the abo ve example. State your answer as a \"Rule of Thumb\". " }}{PARA 0 "" 0 "" {TEXT 260 390 " (b) Find the errors for the Simpson's rule \+ SIMP(f,a,b,n) for a list of doubling values of n. Note how small those values are. Do not attempt to calculate ratios of errors. Errors are \+ so small that Maple's default setting of acuracy to ten decimal digits does not allow for a good comparison. There is a way to change the de fault setting, but we are not going to do it at this point." }}} {EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 241 12 " Problem 3. " }{TEXT 260 37 "For the function and integral studied" } {TEXT 242 1 " " }{TEXT 260 203 "above, what do you think TRAP(f,0,1,32 0) is? Give your answer based only on the values we computed above fo r TRAP(40), TRAP(80), and TRAP(160). Then use Maple to verify your an swer. How close were you?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }} {PARA 0 "" 0 "" {TEXT 243 10 "Problem 4." }{TEXT 260 59 " For the midp oint rule, what is the effect on the error of " }{TEXT 244 9 "tripling " }{TEXT 260 49 "n? Experiment with Maple to justify your answer. " } }}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 207 "" 0 "" {TEXT 200 234 "Note: If you choose for your experiments a function whose domain \+ is not the whole real line, make sure that the interval of integration is contained in the domain, as it should be. Otherwise, you may cause the program to freeze solid!" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 245 9 "Problem 5" }{TEXT 260 713 ". Supp ose you have found TRAP(40) and TRAP(80) for a certain integral. Thin k of a way of combining these to get an estimate of the integral which is more accurate than either one separately. Note that just averaging them might be an improvement, but maybe not. After all, TRAP(80) is \+ likely to be more accurate, so why spoil it by averaging with TRAP(40) . But consider that the error, exact - TRAP(40), is about 4 times a s large as the error exact-TRAP(80). But we suppose you don't know t he value of exact! You might use the preceding sentence as an equat ion to be solved for \"exact.\" Try and see. Compare your improved es timate with TRAP(40), TRAP(80) and Maple's exact value for the integra l A = " }{XPPEDIT 18 0 "int(sin(x^2), x = 0 .. 1);" "6#-%$intG6$-%$sin G6#*$)%\"xG\"\"#\"\"\"/F+;\"\"!F-" }{TEXT 260 18 " calculated above." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 4 "" 0 " " {TEXT 261 29 "Error Estimates in Terms of n" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 126 "It turns out that with more careful analysis it can be shown that errors in the trapezoid, midpoi nt and Simpsons rules satisfy" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }} {PARA 0 "" 0 "" {TEXT 260 47 " (1) \+ " }{XPPEDIT 18 0 "abs(TRAP(g, a, b, n)-int(g(x), x = a .. b)) < C[1]/(n^2);" "6#2-%$absG6#,&-%%TRAPG6&%\"gG%\"aG%\"bG%\"nG\"\"\"-%$in tG6$-F+6#%\"xG/F5;F,F-!\"\"*&&%\"CG6#F/F/*$)F.\"\"#F/F8" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 47 " \+ (2) " }{XPPEDIT 18 0 "abs(MID(g, a, b, n)-int (g(x), x = a .. b)) < C[2]/(n^2);" "6#2-%$absG6#,&-%$MIDG6&%\"gG%\"aG% \"bG%\"nG\"\"\"-%$intG6$-F+6#%\"xG/F5;F,F-!\"\"*&&%\"CG6#\"\"#F/*$)F.F =F/F8" }{TEXT 260 2 " " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 28 " " }}{PARA 0 "" 0 "" {TEXT 260 46 " (3) " } {XPPEDIT 18 0 "abs(SIMP(g, a, b, n)-int(g(x), x = a .. b)) < C[3]/(n^4 );" "6#2-%$absG6#,&-%%SIMPG6&%\"gG%\"aG%\"bG%\"nG\"\"\"-%$intG6$-F+6#% \"xG/F5;F,F-!\"\"*&&%\"CG6#\"\"$F/*$)F.\"\"%F/F8" }{TEXT 260 3 " ," } }{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 6 "where " }{XPPEDIT 18 0 "C[1], C[2], C[3];" "6%&%\"CG6#\"\"\"&F$6#\"\"#&F$6#\" \"$" }{TEXT 260 80 " are constants which depend on the particular func tion g and the interval [a,b] " }{TEXT 246 22 "but do not depend on n" }{TEXT 260 342 ". Unfortunately, the constants depend on features of \+ higher derivatives and are usually not available to us. Observe, howev er, that whatever those constant are, formulas (1)-(3) above mean, rou ghly speaking, that, as n gets larger and larger, midpoint and trapezo id approximations converge to the actual value of the integral \"as fa st as\" " }{XPPEDIT 18 0 "1/(n^2);" "6#*&\"\"\"F$*$)%\"nG\"\"#F$!\"\" " }{TEXT 260 92 " converges to 0, while the Simpson's approximations c onverge to the actual value as fast as " }{XPPEDIT 18 0 "1/(n^4);" "6# *&\"\"\"F$*$)%\"nG\"\"%F$!\"\"" }{TEXT 260 152 " converges to 0, that \+ is, much faster. Do you see how estimates (1)-(3) explain the results \+ obtained above about the effects of doubling n on the error?" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 4 "" 0 "" {TEXT 261 54 "Graphical Comparison of the E rrors for Different Rules" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 310 "It is always helpful to represent your data gra phically. In this section we shall graph errors corresponding to diffe rent numerical integration rules. To change pace and to reinforce our \+ skills of working with lists, let's choose a different function to wor k with and a different list of values for n. Consider" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "g:=x->l n(1+x^2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"gGf*6#%\"xG6\"6$%)ope ratorG%&arrowGF(-%#lnG6#,&*$)F'\"\"#\"\"\"F3F3F3F(F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "B:=Int(g(x),x=0..2); value(B);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"BG-%$IntG6$-%#lnG6#,&*$)%\"xG\"\"# \"\"\"F0F0F0/F.;\"\"!F/" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,(*&\"\"#\" \"\"-%#lnG6#\"\"&F&F&\"\"%!\"\"*&F%F&-%'arctanG6#F%F&F&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 163 "Again, the actual exact value of the integral B is not very c onvenient for numerical work. Hence, we shall take as the \"exact\" va lue its ten digit approximation." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "exactB:=evalf(value(B));" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%'exactBG$\"+gK " 0 "" {MPLTEXT 1 0 21 "NL:= [10,20,30,40,50];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#NLG7'\"#5\"#? \"#I\"#S\"#]" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 108 "Now let's defin e the corresponding lists of errors for left, right, midpoint, trapezo id and Simpson's rules." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "ErrorLeft:=[seq((exactB-LEFT(g,0,2, NL[i])),i=1..5)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*ErrorLeftG7'$ \"*osFe\"!\"*$\")P_!)zF($\")O;N`F($\")!Gp+%F($\")*3#3KF(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "ErrorRight:=[seq((exactB-RIGHT(g,0, 2,NL[i])),i=1..5)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%+ErrorRightG7 '$!*9.hj\"!\"*$!)a&Q6)F($!)EU%R&F($!);ESSF($!)FaHKF(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "ErrorTrap:=[seq((exactB-TRAP(g,0,2,NL[i]) ),i=1..5)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*ErrorTrapG7'$!(Blm#! \"*$!'fmmF($!'&H'HF($!'om;F($!'pm5F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 50 "ErrorMid:=[seq((exactB-MID(g,0,2,NL[i])),i=1..5)];" } }{PARA 11 "" 1 "" {XPPMATH 20 "6#>%)ErrorMidG7'$\"(3KL\"!\"*$\"'CLLF($ \"'X\"[\"F($\"&ML)F($\"&LL&F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "ErrorSimp:=[seq((exactB-SIMP(g,0,2,NL[i])),i=1..5)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%*ErrorSimpG7'$!#O!\"*$!\"%F($!\"#F(\"\"!$!\" \"F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 36 "Observe that each of the above is a " }{TEXT 248 4 "list" }{TEXT 260 41 " of errors. To plot a list we need the \"" }{TEXT 249 8 "listplot" }{TEXT 260 38 "\" command that is contained i n the \"" }{TEXT 250 5 "plots" }{TEXT 260 32 "\" package. We load the \+ package." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 233 "Since we have worked with the package before, we end our command \+ with a colon so Maple doesn't display the content of the package. We w ant to plot some of the above lists of errors in one coordinate system , hence we shall label them " }{TEXT 251 7 "lp1,lp2" }{TEXT 260 159 " \+ etc and then use the command \"display\" to plot groups of them togeth er. Each individual command we end with a colon as we don't want indiv idual plots shown." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "lp1:=listplot(ErrorLeft, color=red):" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "lp2:=listplot(ErrorRight, co lor=blue):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "lp3:=listplot (ErrorTrap, color=black):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "lp4:=listplot(ErrorMid, color=green):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "lp5:=listplot(ErrorSimp, color=magenta):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 369 "If we \+ try to display all of the above plots in one coordinate system, some \+ of them would be barely visible or not visible at all. That is because errors corresponding to left and right rules are very large in compar ison with errors corresponding to other rules, so the graphs of the ot her rules would merge with the horizontal axis. Let's display them a f ew at a time." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "display([lp1,lp2]);" }}{PARA 13 "" 1 "" {TEXT 263 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 80 "The above graph gives errors of the left and the right rules. As you see, the \"" }{TEXT 252 8 "listplot" } {TEXT 260 324 "\" command plots consecutive points from the list and j oins them by segments. Below we display the errors of the midpoint and the trapezoid rules. Notice how much smaller the errors are. Observe \+ also our rule of thumb at work: midpoint errors are of the opposite si gn that trapezoid errors and about half of their magnitude." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "d isplay([lp3,lp4]);" }}{PARA 13 "" 1 "" {TEXT 263 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 128 "Finally, we display the error for Simpson's rule. The values are so s mall that they wouldn't show up on any of the above graphs." }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "lp 5;" }}{PARA 13 "" 1 "" {TEXT 263 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 260 336 "Actually, t he errors of Simpson's rule approximation are so small and they approa ch zero so quickly that Maple switched to scientific notation for val ues on the vertical axis to display the graph. We shall not go into it s meaning at this point. Let's just say that errors for Simpson's rule approach zero too quickly to visualize them!" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 253 10 "Problem 6." }{TEXT 260 19 " For the function " }{XPPEDIT 18 0 "k(x) = cos(x^2+1);" "6#/- %\"kG6#%\"xG-%$cosG6#,&*$)F'\"\"#\"\"\"F/F/F/" }{TEXT 260 19 " and th e integral " }{XPPEDIT 18 0 "int(k(x), x = 0 .. 2);" "6#-%$intG6$-%\"k G6#%\"xG/F);\"\"!\"\"#" }{TEXT 260 3 ", " }{TEXT 254 4 "list" }{TEXT 260 5 " and " }{TEXT 255 4 "plot" }{TEXT 260 113 " the errors for the \+ left and right rules, and then for the midpoint and trapezoid rules fo r n=5, 10, 20, 40, 80. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 4 "" 0 "" {TEXT 261 17 "Homework Problems" }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}{PARA 0 "" 0 "" {TEXT 260 64 "Your homework for this \+ worksheet consists of Problems 1-6 above." }}{PARA 0 "" 0 "" {TEXT 256 6 "Note. " }{TEXT 260 42 "For this worksheet you will be better of f " }{TEXT 257 3 "not" }{TEXT 260 1 " " }{TEXT 258 5 "using" }{TEXT 260 5 " the " }{TEXT 259 7 "restart" }{TEXT 260 230 " command in your \+ homework worksheet. If you do use the command, you have to copy and re -execute all the procedures defining LEFT, RIGHT, and other rules, as \+ well as redefine the function f(x), reload the package with(plots), et c. " }}{PARA 0 "" 0 "" {TEXT 260 0 "" }}}{EXCHG {PARA 208 "" 0 "" {TEXT 200 76 "MTH 142 Maple Worksheets written by B. Kaskosz and L. Pa kula,Copyright 1999." }}}{EXCHG {PARA 209 "" 0 "" {TEXT 200 26 "Last m odified August 1999." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }