{VERSION 2 3 "IBM INTEL NT" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 }{CSTYLE " TXT CMD" -1 256 "MS Sans Serif" 0 0 128 0 0 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "Bookmark" 20 257 "" 0 0 0 128 0 1 1 0 0 0 0 1 0 0 0 }{CSTYLE "word" -1 258 "" 0 0 128 0 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "bookmark" -1 259 "" 0 0 0 128 0 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 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 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 "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 2 6 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "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 }{PSTYLE "newpage" -1 256 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 1 0 -1 0 }{PSTYLE "vfill" -1 257 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 "Definit ion" -1 258 1 {CSTYLE "" -1 -1 "" 0 0 0 64 128 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Theorem" -1 259 1 {CSTYLE "" -1 -1 "" 0 0 219 36 36 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 4 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Problem" -1 260 1 {CSTYLE "" -1 -1 "" 0 0 0 0 255 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 4 4 3 4 0 0 0 0 -1 0 }{PSTYLE "dblnorm" -1 261 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 2 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "code" 2 262 1 {CSTYLE "" -1 -1 "Comic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approximating functions w ith polynomials" }}{PARA 270 "" 0 "" {TEXT -1 86 "In this worksheet, w e will work the first programming assignment on Taylor series. " }} {PARA 0 "" 0 "" {TEXT 260 13 "Assignment: " }}{PARA 0 "" 0 "" {TEXT -1 538 "The hyperbolic cosine, cosh, is defined as the average of exp( x) and exp(-x). Get the Taylor series for cosh about a=0. How ma ny terms do you need to guarantee 7 digits of accuracy (rounded) as x \+ ranges over the interval 0 to 2? Do the calculations with 14 digits o f precision to avoid roundoff error. Write a proc 'mycosh' which will take any x in 0 to 2, evaluate the Taylor polynomial you have determi ned above and return the value rounded to 7 digits. Make a table comp aring the values of mycosh with Maple's cosh function. " }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 261 8 "Solution" }{TEXT -1 4 ": " }{XPPEDIT 18 0 "cosh(x) = (exp(x)+exp(-x))/2" "/-%%coshG6# %\"xG*&,&-%$expG6#F&\"\"\"-F*6#,$F&!\"\"F,F,\"\"#F0" }{TEXT -1 6 ", s o " }{XPPEDIT 18 0 "`cosh'`(x) = (exp(x)-exp(-x))/2" "/-%&cosh'G6#%\" xG*&,&-%$expG6#F&\"\"\"-F*6#,$F&!\"\"F0F,\"\"#F0" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "`cosh''`(x)=cosh(x)." "I(UNKNOWNG6\"" }}{PARA 0 "" 0 " " {TEXT -1 76 " so the derivatives cycle through these two functions. \+ Also cosh(0)=1 and " }{XPPEDIT 18 0 "`cosh'`(0)=0" "/-%&cosh'G6#\"\" !F&" }{TEXT -1 56 " so we can just write down the Taylor series for co sh as" }}{PARA 268 "" 0 "" {XPPEDIT 18 0 "cosh(x) = 1 +1/2*x^2 + 1/4!* x^4 + `...` + 1/(2*n)!*x^(2*n) + `...`" "/-%%coshG6#%\"xG,.\"\"\"\"\" \"*(\"\"\"F)\"\"#!\"\"F&\"\"#F)*(\"\"\"F)-%*factorialG6#\"\"%F-F&\"\"% F)%$...GF)*(\"\"\"F)-F26#*&\"\"#F)%\"nGF)F-)F&*&\"\"#F)F=F)F)F)F6F)" } }{PARA 0 "" 0 "" {TEXT -1 127 "By Taylor's remainder theorem, the er ror in using the 2nth taylor polynomial to approximate cosh over [0..2 ] is no more than" }}{PARA 269 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "M/(2n+1)!*(2-0)^(2*n+1)" "*(%\"MG\"\"\"-%*factorialG6#,&*&\"\"#F$% \"nGF$F$\"\"\"F$!\"\"),&\"\"#F$\"\"!F-,&*&\"\"#F$F+F$F$\"\"\"F$F$" } {TEXT -1 1 "," }}{PARA 0 "" 0 "" {TEXT -1 184 "where M is a number whi ch bounds from above the absolute value of the 2n+1 th derivative of c osh on the interval [0,2]. We can use the maximum value of the deriva tive for M, which is " }{XPPEDIT 18 0 "(exp(2)-exp(-2))/2=3.63" "/*&,& -%$expG6#\"\"#\"\"\"-F&6#,$\"\"#!\"\"F.F)\"\"#F.$\"$j$!\"#" }{TEXT -1 64 ". So we want to find the smallest solution to the inequality " }{XPPEDIT 18 0 "3.63/(2*n+1)!*2^(2*n+1) <= .5*10^(-6)" "1*($\"$j$!\"# \"\"\"-%*factorialG6#,&*&\"\"#F'%\"nGF'F'\"\"\"F'!\"\")\"\"#,&*&\"\"#F 'F.F'F'\"\"\"F'F'*&$\"\"&!\"\"F')\"#5,$\"\"'F0F'" }{TEXT -1 1 "." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "for k from 2 by 2 to 20 do \+ \nk,evalf(3.63/(k+1)!*2^(k+1)) od;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"#$\"+******R[!\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"%$\"+,++!o*!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"'$\"+?w/>#*!#6" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$ \"\")$\"+@Jp@^!#7" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#5$\"+iQVi=!#8 " }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#7$\"+U9ZvZ!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#9$\"+#3Oh4*!#<" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 $\"#;$\"+qqmP8!#=" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#=$\"+!*G_k:!#? " }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#?$\"++=-!\\\"!#A" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 281 "We see that the 14th taylor polynomial i s the first one within the desired error, as guaranteed by Taylor's th eorem. So now construct the polynomial and tabulate its values over \+ 0 to 2 to check out the theory. First, generate the polynomial. Thi s can be accomplished like so. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "p :=taylor(cosh(x),x=0,15);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6 #>%\"pG+5%\"xG\"\"\"\"\"!#F'\"\"#\"\"##F'\"#C\"\"%#F'\"$?(\"\"'#F'\"&? .%\"\")#F'\"(+)GO\"#5#F'\"*+;+z%\"#7#F'\",+7Hyr)\"#9-%\"OG6#F'\"#:" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "p :=convert(p,polynom);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"pG,2\"\"\"F&*$%\"xG\"\"##F&F)*$F( \"\"%#F&\"#C*$F(\"\"'#F&\"$?(*$F(\"\")#F&\"&?.%*$F(\"#5#F&\"(+)GO*$F( \"#7#F&\"*+;+z%*$F(\"#9#F&\",+7Hyr)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "Now, convert the coefficients of the polynomial to floating po int numbers with 14 digits of precision." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "p := evalf(p,14);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6# >%\"pG,2$\"\"\"\"\"!F'*$%\"xG\"\"#$\"/++++++]!#9*$F*\"\"%$\"/nmmmmmT!# :*$F*\"\"'$\"/*))))))))))Q\"!#;*$F*\"\")$\"/(e,te,[#!#=*$F*\"#5$\"/')R A>tbF!#?*$F*\"#7$\"/oy)pvw3#!#A*$F*\"#9$\"/IxfX2Z6!#C" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Then 'hornify' p and turn it into the fun ction named mycosh." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "myco sh := unapply(convert(p,horner),x);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6 #>%'mycoshG:6#%\"xG6\"6$%)operatorG%&arrowGF(,&$\"\"\"\"\"!F.*&,&$\"/+ +++++]!#9F.*&,&$\"/nmmmmmT!#:F.*&,&$\"/*))))))))))Q\"!#;F.*&,&$\"/(e,t e,[#!#=F.*&,&$\"/')RA>tbF!#?F.*&,&$\"/oy)pvw3#!#AF.*$9$\"\"#$\"+gX2Z6F HF.FOFPF.F.FOFPF.F.FOFPF.F.FOFPF.F.FOFPF.F.FOFPF.F(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "Now test the accuracy by tabulation." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "printf(`%5.2s %20.12s %20.1 2s \\n`,`x`,`mycosh(x)`, `cosh(x)` );" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 105 "for i from 0 to 20 do\n printf(`%3.2e %20.6e %20.6e \\n`,evalf (i/10),mycosh(i/10.),evalf(cosh(i/10))); od;" }}{PARA 6 "" 1 "" {TEXT -1 1162 " x mycosh(x) cosh(x) \n0.00e-01 \+ 1.000000e+00 1.000000e+00 \n1.00e-01 1.005004e +00 1.005004e+00 \n2.00e-01 1.020066e+00 1.0 20066e+00 \n3.00e-01 1.045338e+00 1.045338e+00 \n4.00 e-01 1.081072e+00 1.081072e+00 \n5.00e-01 1.1 27625e+00 1.127625e+00 \n6.00e-01 1.185465e+00 \+ 1.185465e+00 \n7.00e-01 1.255169e+00 1.255169e+00 \+ \n8.00e-01 1.337434e+00 1.337434e+00 \n9.00e-01 \+ 1.433086e+00 1.433086e+00 \n1.00e+00 1.543080e+00 \+ 1.543080e+00 \n1.10e+00 1.668518e+00 1.66851 8e+00 \n1.20e+00 1.810655e+00 1.810655e+00 \n1.30e+00 1.970914e+00 1.970914e+00 \n1.40e+00 2.15089 8e+00 2.150898e+00 \n1.50e+00 2.352409e+00 2 .352409e+00 \n1.60e+00 2.577464e+00 2.577464e+00 \n1. 70e+00 2.828315e+00 2.828315e+00 \n1.80e+00 3 .107473e+00 3.107473e+00 \n1.90e+00 3.417731e+00 \+ 3.417731e+00 \n2.00e+00 3.762195e+00 3.762195e+0 0 " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "By inspection, cosh and myc osh coincide to 7 digits of precision over the interval 0..2" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT 262 8 "Question" } {TEXT -1 82 ": What if we expanded about 1? Could we get by with a s maller degree polynomial?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 263 7 "Answ er:" }{TEXT -1 35 " Sure, the error bound would be " }{XPPEDIT 18 0 "M/(n+1)!*1^n" "*(%\"MG\"\"\"-%*factorialG6#,&%\"nGF$\"\"\"F$!\"\") \"\"\"F)F$" }{TEXT -1 132 " where M is the same maximum of the absolu te value of the n+1st derivative on [0,2]. which is much smaller than \+ the previous bound." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "M := (exp(2.)+1/exp(2.))/2.;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"MG$\"+ #p&>iP!\"*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "for k from 2 \+ to 16 do \nk,evalf(M/(k+1)!) od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$ \"\"#$\"+bhKqi!#5" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"$$\"+Q:en:!#5 " }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"%$\"+xI;NJ!#6" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"&$\"+&zr_A&!#7" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"'$\"+#*Rnku!#8" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"($\"+* [U3L*!#9" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\")$\"+x-wO5!#9" }} {PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"*$\"+x-wO5!#:" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#5$\"+EM4D%*!#<" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\" #6$\"+@XCay!#=" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#7$\"+blsTg!#>" }} {PARA 11 "" 1 "" {XPPMATH 20 "6$\"#8$\"+o*=bJ%!#?" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#9$\"+XE,xG!#@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"# :$\"+.H8)z\"!#A" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"#;$\"+P_sd5!#B" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "According to these calculations , if we expand about a=1, the 10th degree taylor polynomial will do. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 271 "" 0 "" {TEXT 264 10 "Problems: " }{TEXT -1 57 " Wr ite these out by hand and give to me on Monday 9/12." }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT -1 290 "Suppose you have a f our function calculator with an extra button called crummyexp. Crummy exp gives a good approximation to exp(x) as long as x is between 0 and 0.1 but a crummy one outside this range. Devise a method to use th is calculator to approximate exp(x) outside this range also." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT -1 201 "If you haven 't submitted the cosh problem, do this one instead: Use Taylors theo rem with remainder to find a polynomial p(x) which approximates exp(x) on [0,0.1] to within 7 digits of precision. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 260 "" 0 "" {TEXT -1 4 "Let " }{XPPEDIT 18 0 "k[ 1](a,h) = (f(a+h)-f(a))/h" "/-&%\"kG6#\"\"\"6$%\"aG%\"hG*&,&-%\"fG6#,& F)\"\"\"F*F1F1-F.6#F)!\"\"F1F*F4" }{TEXT -1 14 ". Show that " } {XPPEDIT 18 0 "k[1](a,h)" "-&%\"kG6#\"\"\"6$%\"aG%\"hG" }{TEXT -1 59 " converges to f'(a) with Order h. Assume f' is continuous" }}{PARA 260 "" 0 "" {TEXT -1 87 "on the interval [a-1, a+1]. Use the mean v alue theorem (taylor's theorem for n = 0)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{MARK "17 0 0" 0 } {VIEWOPTS 1 1 0 1 1 1803 }