{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 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 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 1 0 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 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 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 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Tim es" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Warning" -1 7 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 2 2 2 2 2 1 1 1 3 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output " -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 } 3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Plot" -1 13 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Out put" -1 257 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 256 56 "6. Finite difference me thods for boundary value problems" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 211 "In the last lecture I discussed a bounda ry value problem associated with heat conduction in a thin rod. After \+ we had introduced dimensionless variables, the problem amounted to sol ving the differential equation " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "de:=diff (t(z),z,z)-t(z)=-1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#deG/,&-%%dif fG6$-%\"tG6#%\"zG-%\"$G6$F-\"\"#\"\"\"F*!\"\"F3" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 344 "with boundary value conditions t(0)=0, t(a)=0. Ther e are many situations where we cannot find an analytical solution, and we have to find an approximate numerical solution. I have already no ted that the numerical option of dsolve only works for initial value p roblems, not for boundary value problems. A favorite numerical altern ative is the " }{TEXT 257 26 "finite difference method. " }{TEXT -1 21 "We will illustrate it" }{TEXT 261 1 " " }{TEXT -1 269 "using the e xample above. This has the advantage that we can compare the exact and approximate solution. Later on I will indicate how one can estimate t he accuracy when the exact solution isn't known. Since we are using a \+ numerical method we need to specify a value of " }{TEXT 260 1 "a" } {TEXT -1 15 ". Let us choose" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 6 "a:=30;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG\"#I" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "Let us write the solution as we found it \+ in lecture 5." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "f:=z->1-co sh(z-a/2)/cosh(a/2);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fGR6#%\"zG 6\"6$%)operatorG%&arrowGF(,&\"\"\"F-*&-%%coshG6#,&9$F-*&#F-\"\"#F-%\"a GF-!\"\"F--F06#,$F7#F-F6F8F8F(F(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 142 "The finite difference method seeks a solution on a discrete s et of N+1 points (including the end points). The distance between the \+ points is " }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "Delta=a/N" "6#/%&DeltaG*& %\"aG\"\"\"%\"NG!\"\"" }}{PARA 0 "" 0 "" {TEXT -1 80 "and the sequence of points is z=0, Delta, 2*Delta, .... Let us pick a value of N" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "N:=200;Delta:=a/N;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"NG\"$+#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%&DeltaG#\"\"$\"#?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "We call the first and last points " }{TEXT 258 17 "exterior points, " }{TEXT -1 90 "at these points the function is given by the boundary condition . The remaining points are " }{TEXT 259 16 "interior points " }{TEXT -1 90 "where we wish to find a numerical result. Suppose a function is given for the three points" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "x-Delta " "6#,&%\"xG\"\"\"%&DeltaG!\"\"" }{TEXT -1 2 ", " }{XPPEDIT 18 0 "x" " 6#%\"xG" }{TEXT -1 2 ", " }{XPPEDIT 18 0 "x+Delta" "6#,&%\"xG\"\"\"%&D eltaGF%" }}{PARA 0 "" 0 "" {TEXT -1 81 "We approximate the function ne ar x by the first few terms in the Taylor expansion" }}{PARA 0 "" 0 " " {XPPEDIT 18 0 "f(x-Delta) = f(x)-Delta*diff(f,x)+.5*Delta^2*diff(f,` $`(x,2));" "6#/-%\"fG6#,&%\"xG\"\"\"%&DeltaG!\"\",(-F%6#F(F)*&F*F)-%%d iffG6$F%F(F)F+*($\"\"&F+F)*$F*\"\"#F)-F16$F%-%\"$G6$F(F7F)F)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "f(x+Delta) = \+ f(x)+Delta*diff(f,x)+.5*Delta^2*diff(f,`$`(x,2));" "6#/-%\"fG6#,&%\"xG \"\"\"%&DeltaGF),(-F%6#F(F)*&F*F)-%%diffG6$F%F(F)F)*($\"\"&!\"\"F)*$F* \"\"#F)-F06$F%-%\"$G6$F(F7F)F)" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 45 "and solve these equations for the derivatives" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "diff(f,x)=(f(x+Delta)-f(x-Delta))/2/Delta" "6#/-%%diffG 6$%\"fG%\"xG*(,&-F'6#,&F(\"\"\"%&DeltaGF.F.-F'6#,&F(F.F/!\"\"F3F.\"\"# F3F/F3" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "diff(f,x$2)=(f(x+Delta)+f(x-D elta)-2*f(x))/Delta^2" "6#/-%%diffG6$%\"fG-%\"$G6$%\"xG\"\"#*&,(-F'6#, &F+\"\"\"%&DeltaGF2F2-F'6#,&F+F2F3!\"\"F2*&F,F2-F'6#F+F2F7F2*$F3F,F7" }}{PARA 0 "" 0 "" {TEXT -1 117 "Substituting the expressions for the d erivatives into the differential equation gives a system of algebraic \+ equations" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "t[n+1]+t[n-1]-2t[n]-Delta^ 2 *t[n]=-Delta^2" "6#/,*&%\"tG6#,&%\"nG\"\"\"F*F*F*&F&6#,&F)F*F*!\"\"F **&\"\"#F*&F&6#F)F*F.*&%&DeltaGF0&F&6#F)F*F.,$*$F4F0F." }}{PARA 0 "" 0 "" {TEXT -1 88 "If the first solution point is t[1] the last is t[N+ 1], the boundary conditions are thus" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "t[1]:=0;t[N+1]:=0;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"tG6# \"\"\"\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"tG6#\"$,#\"\"!" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 170 "There is one equation for each i nterior point. I have suppressed the lengthy printout of the equation s. The curly bracket surrounding the sequence operator creates a set" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "eqs:=\{seq(t[n+1]+t[n-1]- 2*t[n]-Delta^2 *t[n]=-Delta^2,n=2..N)\}:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 24 "To solve these equations" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "sole:=evalf(solve(eqs,\{seq(t[n],n=2..N)\})):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 151 "sole will list the solutions t[n] in arbitrary order, so I have again suppressed the output. To get thi ngs in the right order we use the assign command" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "assign(sole);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "Let us plot the error by comparing with the exact result " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}{PARA 7 "" 1 "" {TEXT -1 50 "Warning, the name changecoords has been redefin ed\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 172 "listplot([seq(t[n+ 1]-evalf(f(a*(n)/N)),n=0..N)],labels=[\"point n\",\"error \"], \ntitle=\"Difference between approximate and exact solution\" ,axes=bo xed,tickmarks=[3,3]);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6'-%'CURVESG6#7ew7$$\"\"\"\"\"!$F*F*7$$\"\"#F*$!(*R27!#57 $$\"\"$F*$!($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 0 "Curve 1" }}}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 99 "Note that the solution corresponding to the point n=0 is \+ t[1]. A plot of the numerical solution is" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 126 "listplot([seq(t[n+1],n=0..N)],labels=[\"point n\", \"Temperature \"],\ntitle=\"Approximate solution\",axes=boxed,tick marks=[3,3]);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6 '-%'CURVESG6#7ew7$$\"\"\"\"\"!$F*F*7$$\"\"#F*$\"+MGr\"R\"!#57$$\"\"$F* $\"+2#R(*e#F17$$\"\"%F*$\"+7Z.@OF17$$\"\"&F*$\"+)\\.)3XF17$$\"\"'F*$\" +i.-t_F17$$\"\"(F*$\"+&=!)3$fF17$$\"\")F*$\"+7[=(\\'F17$$\"\"*F*$\"+(4 wY)pF17$$\"#5F*$\"+&fAVS(F17$$\"#6F*$\"+]jclxF17$$\"#7F*$\"+\\``w!)F17 $$\"#8F*$\"+$REUM)F17$$\"#9F*$\"+JDmu&)F17$$\"#:F*$\"+w&GIx)F17$$\"#;F *$\"+kxyV*)F17$$\"#t@*F17$$\"#>F*$\"+\" )eCE$*F17$$\"#?F*$\"+1J,?%*F17$$\"#@F*$\"+F1t+&*F17$$\"#AF*$\"+'e9-d*F 17$$\"#BF*$\"+u$G+j*F17$$\"#CF*$\"++y^\"o*F17$$\"#DF*$\"+w8%es*F17$$\" #EF*$\"+%Q'*Rw*F17$$\"#FF*$\"+58%oz*F17$$\"#GF*$\"+m^6D)*F17$$\"#HF*$ \"+7TX\\)*F17$$\"#IF*$\"+xdSq)*F17$$\"#JF*$\"+r:W)))*F17$$\"#KF*$\"+,t 'R!**F17$$\"#LF*$\"+&HKt\"**F17$$\"#MF*$\"+ls$)G**F17$$\"#NF*$\"+u5uQ* *F17$$\"#OF*$\"+elEZ**F17$$\"#PF*$\"+Qbga**F17$$\"#QF*$\"+WJ#4'**F17$$ \"#RF*$\"+?:Om**F17$$\"#SF*$\"+II/r**F17$$\"#TF*$\"+4I2v**F17$$\"#UF*$ \"+I@ay**F17$$\"#VF*$\"+\\%G:)**F17$$\"#WF*$\"+f\"*4%)**F17$$\"#XF*$\" +*47j)**F17$$\"#YF*$\"+hq@))**F17$$\"#ZF*$\"+3p&)*)**F17$$\"#[F*$\"+N& o7***F17$$\"#\\F*$\"+/P[#***F17$$\"#]F*$\"+c(HN***F17$$\"#^F*$\"+G-V%* **F17$$\"#_F*$\"+z`?&***F17$$\"#`F*$\"+_E(e***F17$$\"#aF*$\"+gqW'***F1 7$$\"#bF*$\"+E:%p***F17$$\"#cF*$\"+xrO(***F17$$\"#dF*$\"+*eLx***F17$$ \"#eF*$\"+2!\\!)***F17$$\"#fF*$\"+G0K)***F17$$\"#gF*$\"+hUb)***F17$$\" #hF*$\"+kav)***F17$$\"#iF*$\"+l'G*)***F17$$\"#jF*$\"+ix2****F17$$\"#kF *$\"+3h?****F17$$\"#lF*$\"+\"f;$****F17$$\"#mF*$\"+)p6%****F17$$\"#nF* $\"+oN\\****F17$$\"#oF*$\"+VSc****F17$$\"#pF*$\"+4Zi****F17$$\"#qF*$\" +Jpn****F17$$\"#rF*$\"+%)=s****F17$$\"#sF*$\"+z0w****F17$$\"#tF*$\"+)) Qz****F17$$\"#uF*$\"+eD#)****F17$$\"#vF*$\"+Ps%)****F17$$\"#wF*$\"+y%o )****F17$$\"#xF*$\"+gn))****F17$$\"#yF*$\"+%\\-*****F17$$\"#zF*$\"+Ng \"*****F17$$\"#!)F*$\"+'oF*****F17$$\"#\")F*$\"+5x$*****F17$$\"##)F*$ \"+Kj%*****F17$$\"#$)F*$\"+ZP&*****F17$$\"#%)F*$\"+@,'*****F17$$\"#&)F *$\"+)fl*****F17$$\"#')F*$\"+,.(*****F17$$\"#()F*$\"+OV(*****F17$$\"#) )F*$\"+$zx*****F17$$\"#*)F*$\"+]2)*****F17$$\"#!*F*$\"+vK)*****F17$$\" #\"*F*$\"+Ba)*****F17$$\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$\"$c\"F*Ffy7$$\"$d\"F*Fay7$$\"$e\"F*F \\y7$$\"$f\"F*Fgx7$$\"$g\"F*Fbx7$$\"$h\"F*F]x7$$\"$i\"F*Fhw7$$\"$j\"F* Fcw7$$\"$k\"F*F^w7$$\"$l\"F*Fiv7$$\"$m\"F*Fdv7$$\"$n\"F*F_v7$$\"$o\"F* Fju7$$\"$p\"F*Feu7$$\"$q\"F*F`u7$$\"$r\"F*F[u7$$\"$s\"F*Fft7$$\"$t\"F* Fat7$$\"$u\"F*F\\t7$$\"$v\"F*Fgs7$$\"$w\"F*Fbs7$$\"$x\"F*F]s7$$\"$y\"F *Fhr7$$\"$z\"F*Fcr7$$\"$!=F*F^r7$$\"$\"=F*Fiq7$$\"$#=F*Fdq7$$\"$$=F*F_ q7$$\"$%=F*Fjp7$$\"$&=F*Fep7$$\"$'=F*F`p7$$\"$(=F*F[p7$$\"$)=F*Ffo7$$ \"$*=F*Fao7$$\"$!>F*F\\o7$$\"$\">F*Fgn7$$\"$#>F*FX7$$\"$$>F*FS7$$\"$%> F*FN7$$\"$&>F*FI7$$\"$'>F*FD7$$\"$(>F*F?7$$\"$)>F*F:7$$\"$*>F*F57$$\"$ +#F*F/7$$\"$,#F*F+-%*AXESTICKSG6$F4F4-%&TITLEG6#Q5Approximate~solution 6\"-%+AXESLABELSG6$Q(point~nF^^nQ1Temperature~~~~~F^^n-%*AXESSTYLEG6#% $BOXG" 1 2 0 1 10 0 2 9 1 2 2 1.000000 45.000000 45.000000 0 0 "Curve \+ 1" }}}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 418 "On my laptop computer Mapl e needs a few seconds to solve 199 equations. As perhaps could be expe cted, the numerical solution is least accurate where the solution has \+ most curvature. The maximum error with 99 equations is about 1 part in thousand which may be too large for some applications. With 399 equat ions the accuracy is not too bad. (about 1 part in 10 000), and the co mputation time is still manageable. If we " }}{PARA 0 "" 0 "" {TEXT -1 594 "increase N much further Maple will start to get into trouble, \+ depending on the power on your computer. To get much higher accuracy, \+ more sophisticated methods are required. One approach is to first figu re out which region the error is the largest and to use a finer mesh i n problem areas. There is a huge literature on the subject and many s oftware packages areavailable on the web. A good place to start is \"N umerical recipes\" for a description on standard methods, and e.g. the University of Dundee website (go to the web-link section from the cou rse title page) for links to Maple software." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 282 "Let us next consider some gene ralizations. In our first example we had constant coefficients and thi s made the system exactly solvable . If in the steady state heat prob lem the heat loss and heat generation terms are not constant, but depe nd on position, we would have the equation" }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "diff(t(z),z,z)-f(z)*t(z)=g(z)" "6#/,&-%%diffG6%-%\"tG6# %\"zGF+F+\"\"\"*&-%\"fG6#F+F,-F)6#F+F,!\"\"-%\"gG6#F+" }}{PARA 0 "" 0 "" {TEXT -1 645 "where f(z) and g(z) may be known functions. The equa tion is still linear, but we will not in general be able to find a clo sed form exact solution. The numerical approach is then unavoidable an d we have to find a method, other than comparison with the exact solut ion, to estimate the accuracy. Finally, the boundary conditions at the ends may depend on the value of the derivative there. In order not t o make the problem too difficult we will, for now, assume that the bou ndary conditions are linear. Since we are using a numerical method we need to specify values for all parameters. We no longer need the pre vious results, so we start again" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "We ne xt specify the length of the domain of the solution" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "a:=1;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#> %\"aG\"\"\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "the number (N+1) o f mesh points" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "N:=200;Del ta:=a/N;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"NG\"$+#" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>%&DeltaG#\"\"\"\"$+#" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 63 "and the functions f(z) and g(z) which we arbitrary choo se to be" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "f:=z->cos(Pi*z) ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fGR6#%\"zG6\"6$%)operatorG%&a rrowGF(-%$cosG6#*&%#PiG\"\"\"9$F1F(F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "g:=z->-sin(Pi*z);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# >%\"gGR6#%\"zG6\"6$%)operatorG%&arrowGF(,$-%$sinG6#*&%#PiG\"\"\"9$F2! \"\"F(F(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "We put the mesh poi nts are then into an ordered list" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "x:=[seq(a*n/N,n=0..N)]:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "The first and last element on this list will be " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "x[1],x[N+1];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$\"\"!\"\"\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "Note that the first element on the list is " }{TEXT 263 3 "not" } {TEXT -1 67 " x[0]! Confusion regarding indexing is a very common erro r in Maple" }}{PARA 0 "" 0 "" {TEXT -1 134 "and it is often a good ide a to check the indexing actually used by the program. Let us evaluate \+ f and g numerically at the mesh points" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "fm:=seq(evalf(f(x[n])),n=1..N+1):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "gm:=seq(evalf(g(x[n])),n=1..N+1):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "Let us assume that for z=0 the bou ndary condition is " }{XPPEDIT 18 0 "alpha*diff(t,z)+beta*t = phi;" "6 #/,&*&%&alphaG\"\"\"-%%diffG6$%\"tG%\"zGF'F'*&%%betaGF'F+F'F'%$phiG" } {TEXT -1 58 ", while for z=a it is t(a)=0. The second condition is jus t" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "t[N+1]:=0;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"tG6#\"$,#\"\"!" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 317 "The first boundary condition requires us to find an e xpression for the derivative at the boundary. Since the t(-Delta) is \+ not defined we must find a different finite difference equation for th e derivative than the one we derived previously. Let us use the Taylor expansion about the origin and use the first 3 points" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "solve(\{t2=t1+dt*delta+dtt/2*delta^ 2,t3=t1+2*dt*delta+2*dtt*delta^2\},\{dt,dtt\});" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<$/%$dttG*&,(%#t3G\"\"\"%#t1GF)*&\"\"#F)%#t2GF)!\"\"F)* $)%&deltaGF,F)F./%#dtG,$*&,(F-!\"%*&\"\"$F)F*F)F)F(F)F)F1F.#F.F," }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 31 "we must also choose values for " } {XPPEDIT 18 0 "alpha" "6#%&alphaG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "beta" "6#%%betaG" }{TEXT -1 29 " . To be specific let us pick" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "alpha:=1;beta:=1;phi:=0;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%&alphaG\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%betaG\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$ph iG\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "leq:=alpha*(4*t[ 2]-3*t[1]-t[3])+2*Delta*beta*t[1]=2*Delta*phi;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$leqG/,(&%\"tG6#\"\"#\"\"%*&#\"$*H\"$+\"\"\"\"&F(6#F0 F0!\"\"&F(6#\"\"$F3\"\"!" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "The s et of interior equations aree" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "ieqs:=\{seq(t[n+1]+t[n-1]-2*t[n]=Delta^2*(fm[n]*t[n]+gm[n]),n=2. .N)\}:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "We now combine leq with ieqs to form a single set of equations" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "eqs:=ieqs union \{leq\}:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 23 "and solve the equations" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "sol:=solve(eqs,\{seq(t[n],n=1..N)\}):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "assign(sol);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 38 "and check what the solution looks like" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}{PARA 7 "" 1 "" {TEXT -1 50 "Warning, the name changecoords has been redefined\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 127 "listplot([seq([x[n],t[n]],n =1..N+1)],labels=[\"x\",\"Temperature \"],\ntitle=\"Approximate so lution\",axes=boxed,tickmarks=[3,3]);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6'-%'CURVESG6#7ew7$$\"\"!F)$\"+J*[Ic\"!\"*7$$ \"+++++]!#7$\"+GHDb:F,7$$\"+++++5!#6$\"+4a\\Z:F,7$$\"+++++:F6$\"+tdxR: F,7$$\"+++++?F6$\"+6M4K:F,7$$\"+++++DF6$\"+2xWC:F,7$$\"+++++IF6$\"+M!Q o^\"F,7$$\"+++++NF6$\"+hPE4:F,7$$\"+++++SF6$\"+\\Us,:F,7$$\"+++++XF6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$\"+\\E1$3 $Fiq7$$\"+++++%)Fiq$\"+RJ%=*HFiq7$$\"++++]%)Fiq$\"++WI+HFiq7$$FjpFiq$ \"+)f%e3GFiq7$$\"++++]&)Fiq$\"+P()o;FFiq7$$\"+++++')Fiq$\"++>iCEFiq7$$ \"++++]')Fiq$\"+Z#*QKDFiq7$$\"+++++()Fiq$\"+:g**RCFiq7$$\"++++]()Fiq$ \"+8vWZBFiq7$$\"+++++))Fiq$\"+@\"\\ZD#Fiq7$$\"++++]))Fiq$\"+)G1>;#Fiq7 $$\"+++++*)Fiq$\"+FX#*o?Fiq7$$\"++++]*)Fiq$\"+<%4e(>Fiq7$$F_qFiq$\"+&f mD)=Fiq7$$\"++++]!*Fiq$\"+eK,&)F67$$\"+++++'*Fiq$\"+2=:evF67$$\"++++]'*F iq$\"+&)3[9mF67$$\"+++++(*Fiq$\"+l7PqcF67$$\"++++](*Fiq$\"+V_)es%F67$$ \"+++++)*Fiq$\"+!H&3\"y$F67$$\"++++])*Fiq$\"+@S.OGF67$$\"+++++**Fiq$\" +jTz!*=F67$$\"++++]**Fiq$\"+A`Ga%*F07$$\"\"\"F)F(-%&TITLEG6#Q5Approxim ate~solution6\"-%*AXESTICKSG6$\"\"$Fein-%+AXESLABELSG6$Q\"xFainQ1Tempe rature~~~~~Fain-%*AXESSTYLEG6#%$BOXG" 1 2 0 1 10 0 2 9 1 2 2 1.000000 45.000000 45.000000 0 0 "Curve 1" }}}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "To check if we have enough points to have acceptable accuracy we n ow repeat the calculation with " }}{PARA 0 "" 0 "" {XPPEDIT 18 0 "delt a=Delta/2" "6#/%&deltaG*&%&DeltaG\"\"\"\"\"#!\"\"" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 34 "The calculation proceeds as before" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "Nh:=N/2;delta:=a/Nh;" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 26 "xh:=[seq(a*n/Nh,n=0..Nh)]:" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%#NhG\"$+\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%&de ltaG#\"\"\"\"$+\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "fh:=se q(evalf(f(xh[n])),n=1..Nh+1):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "gh:=seq(evalf(g(xh[n])),n=1..Nh+1):" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 12 "th[Nh+1]:=0;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&% #thG6#\"$,\"\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "leq:=a lpha*(4*th[2]-3*th[1]-th[3])+2*delta*beta*th[1]=2*delta*phi;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$leqG/,(&%#thG6#\"\"#\"\"%*&#\"$\\\"\"#]\" \"\"&F(6#F0F0!\"\"&F(6#\"\"$F3\"\"!" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "ieqs:=\{seq(th[n+1]+th[n-1]-2*th[n]=delta^2*(fh[n]*th [n]+gh[n]),n=2..Nh)\}:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "e qs:=ieqs union \{leq\}:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 38 " solh:=solve(eqs,\{seq(th[n],n=1..Nh)\}):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "assign(solh);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 149 "listplot([seq([xh[n],th[n]],n=1..Nh+1)],labels=[\"x\",\"Tempe rature \"],\ntitle=\"Approximate solution with courser mesh \",axe s=boxed,tickmarks=[3,3]);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6'-%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hvJFgn7$$\"+++++%)Fgn$\"+m\"GI*HFgn 7$$\"+++++&)Fgn$\"+@lp4GFgn7$$\"+++++')Fgn$\"+S0mDEFgn7$$\"+++++()Fgn$ \"+.7'4W#Fgn7$$\"+++++))Fgn$\"+)pScD#Fgn7$$\"+++++*)Fgn$\"+WBup?Fgn7$$ FXFgn$\"+90J$)=Fgn7$$\"+++++\"*Fgn$\"+a0R'p\"Fgn7$$\"+++++#*Fgn$\"+*pG !4:Fgn7$$\"+++++$*Fgn$\"+#*>F@8Fgn7$$\"+++++%*Fgn$\"+(>oJ8\"Fgn7$$\"++ +++&*Fgn$\"+7rlZ%*F07$$\"+++++'*Fgn$\"+tZ8hvF07$$\"+++++(*Fgn$\"+]*3En &F07$$\"+++++)*Fgn$\"++td#y$F07$$\"+++++**Fgn$\"+M-a\"*=F07$$\"\"\"F)F (-%&TITLEG6#QGApproximate~solutionwith~courser~mesh~6\"-%*AXESTICKSG6$ \"\"$Fjjl-%+AXESLABELSG6$Q\"xFfjlQ1Temperature~~~~~Ffjl-%*AXESSTYLEG6# %$BOXG" 1 2 0 1 10 0 2 9 1 2 2 1.000000 45.000000 45.000000 0 0 "Curve 1" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 91 "The points x[2*n-1],t[2n-1] correspond to xh[n],th [n]. To check the change when doing from " }{XPPEDIT 18 0 "Delta" "6#% &DeltaG" }{TEXT -1 4 " to " }{XPPEDIT 18 0 "Delta/2" "6#*&%&DeltaG\"\" \"\"\"#!\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 168 "listplot([ seq([xh[n],t[2*n-1]-th[n]],n=1..Nh+1)],labels=[\"x\",\"Temperature \+ \"],\ntitle=\"Difference between fine and coarse mesh solutions\",axe s=boxed,tickmarks=[3,3]);" }}{PARA 13 "" 1 "" {GLPLOT2D 400 300 300 {PLOTDATA 2 "6'-%'CURVESG6#7aq7$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07$$\"+++++**Fgn$!'rguF07$$\"\"\"F)F(-%&TITLEG6#QRDifference~betw een~fine~and~coarse~mesh~solutions6\"-%*AXESTICKSG6$\"\"$Fjjl-%+AXESLA BELSG6$Q\"xFfjlQ1Temperature~~~~~Ffjl-%*AXESSTYLEG6#%$BOXG" 1 2 0 1 10 0 2 9 1 2 2 1.000000 45.000000 45.000000 0 0 "Curve 1" }}}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 50 "So, the solution changes by a maximum fraction of " }{XPPEDIT 18 0 "5 *10^(-4)" "6#*&\"\"&\"\"\")\"#5,$\"\"%!\"\"F%" }{TEXT -1 548 " when going from 100 to 200 intervals, which would be the order of mag nitude of the accuracy of the calculation. My laptop has memory troubl e with this worksheet, if I increase the number of points further. So \+ if I need more accuracy, I may also need a more powerful computer or a more sophisticated program. But, I hope these examples illustrate the use of finite difference methods to solve boundary value problems. I \+ emphasize the need to check for accuracy, and to play with the number \+ of mesh points, when the finite difference method is used." }{TEXT 262 0 "" }{TEXT -1 270 " Also, always use a very coarse mesh when firs t debugging, and then gradually increase the size of the mesh as requi red! If you run this under Windows, frequently save your work when deb ugging. You don't want to lose your work each time the computer hangs \+ up or crashes!" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 119 "For a further example of problem which makes use of the methods of these worksheet see problem 3 of problem set 3 2001" }} {PARA 0 "" 0 "" {TEXT -1 113 "http://www.physics.ubc.ca/~birger/312p3/ index.html, with solution http://www.physics.ubc.ca/~birger/312s3.html or" }}{PARA 0 "" 0 "" {TEXT -1 43 "http://www.physics.ubc.ca/~birger/ 312s3.mws" }}}}{MARK "66 0 0" 101 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }