{VERSION 2 3 "SUN SPARC SOLARIS" "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 Output" 2 20 "" 0 1 0 0 255 1 0 0 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 "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 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "Let us expand the right ha nd side in a Fourier series." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "chi:=(a,b,x)->Heaviside(x-a)*Heaviside(b-x):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "f:=t->(t+Pi)*chi(-Pi,0,t)+(-t+Pi)*chi(0,Pi, t);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fG:6#%\"tG6\"6$%)operatorG% &arrowGF(,&*&,&9$\"\"\"%#PiGF0F0-%$chiG6%,$F1!\"\"\"\"!F/F0F0*&,&F/F6F 1F0F0-F36%F7F1F/F0F0F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "xrange:=-Pi..Pi;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'xrangeG;,$%#Pi G!\"\"F'" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "p:=2*Pi;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"pG,$%#PiG\"\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "plot(f(x),x=xrange,scaling=constrained);" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 96 "Let us compute the Fourier coeff icients up to n. Since f is even, we expect the b's to be zero." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "n:=5;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"nG\"\"&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "a0:=(1/p)*int(f(x),x=xrange);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#> %#a0G,$%#PiG#\"\"\"\"\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "for k from 1 to n by 1 do a[k]:=(2/p)*int(f(x)*cos(k*2*Pi*x/p),x=xran ge);od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"\",$*$%#PiG!\" \"\"\"%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"#\"\"!" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"$,$*$%#PiG!\"\"#\"\"%\"\" *" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"%\"\"!" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"&,$*$%#PiG!\"\"#\"\"%\"#D" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 76 "for k from 1 to n by 1 do b[ k]:=(2/p)*int(f(x)*sin(k*2*Pi*x/p),x=xrange);od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"bG6#\"\"\"\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>&%\"bG6#\"\"#\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"bG6#\"\"$ \"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"bG6#\"\"%\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"bG6#\"\"&\"\"!" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 108 "With the coefficients in hand we can construct a part ial sum of the Fourier series and plot it along with f." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "h:=x->a0+sum(a[j]*cos(j*2*Pi*x/p)+b [j]*sin(j*2*Pi*x/p),j=1..n);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"hG :6#%\"xG6\"6$%)operatorG%&arrowGF(,&%#a0G\"\"\"-%$sumG6$,&*&&%\"aG6#% \"jGF.-%$cosG6#,$**F7F.%#PiGF.9$F.%\"pG!\"\"\"\"#F.F.*&&%\"bGF6F.-%$si nGF:F.F./F7;F.%\"nGF.F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "plot(\{f(x),h(x)\},x=xrange,scaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 60 "Now let's do the same thing but with comp lex Fourier series." }}{PARA 0 "" 0 "" {TEXT -1 85 "Notice that since \+ f is real-valued, the Fourier coefficients come in conjugate pairs." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "for k from -n to n by 1 do c[k]:=(1/p)*int(f(x)*exp(-I*k*2*Pi*x/p),x=xrange);od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#!\"&,$*$%#PiG!\"\"#\"\"#\"#D" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#!\"%\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#!\"$,$*$%#PiG!\"\"#\"\"#\"\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#!\"#\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#!\"\",$*$%#PiGF'\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#>&%\"cG6#\"\"!,$%#PiG#\"\"\"\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>&%\"cG6#\"\"\",$*$%#PiG!\"\"\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>&%\"cG6#\"\"#\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#\"\"$ ,$*$%#PiG!\"\"#\"\"#\"\"*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6# \"\"%\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"cG6#\"\"&,$*$%#PiG! \"\"#\"\"#\"#D" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "newh:=x-> sum(c[j]*exp(I*j*2*Pi*x/p),j=-n..n);" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#>%%newhG:6#%\"xG6\"6$%)operatorG%&arrowGF(-%$sumG6$*&&%\"cG6#%\"jG\" \"\"-%$expG6#,$*,%\"IGF4F3F4%#PiGF49$F4%\"pG!\"\"\"\"#F4/F3;,$%\"nGF>F CF(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 76 "This function looks diff erent from the previous h, yet it's really the same." }}{PARA 0 "" 0 " " {TEXT -1 62 "Due to numerical issues the values will be slightly dif ferent." }}{PARA 0 "" 0 "" {TEXT -1 73 "However we can see that the di fferences are quite small by plotting them." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "plot(h(x)-Re(newh(x)),x=xrange);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "plot(Im(newh(x)),x=xrange);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Here is a plot for new h." }}{PARA 0 "" 0 "" {TEXT -1 73 "I take real part because the plot command expects so mething exactly real." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 54 "pl ot(\{f(x),Re(newh(x))\},x=xrange,scaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 131 "Now let's look at the differential equat ion with a sinusoidal right-hand-side. First define the differential \+ operator on the left." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "do p:=y->diff(y,t$2)+omega^2*y;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$dop G:6#%\"yG6\"6$%)operatorG%&arrowGF(,&-%%diffG6$9$-%\"$G6$%\"tG\"\"#\" \"\"*&%&omegaGF5F0F6F6F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "de:=dop(y(t))=exp(I*m*t);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#de G/,&-%%diffG6$-F(6$-%\"yG6#%\"tGF/F/\"\"\"*&%&omegaG\"\"#F,F0F0-%$expG 6#*(%\"IGF0%\"mGF0F/F0" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "Solving it, we can easily identify the homogeneous and particular parts." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "dsolve(de,y(t));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%\"yG6#%\"tG,(*&-%$expG6#*(%\"IG\"\"\"%\"m GF/F'F/F/,&*$F0\"\"#F/*$%&omegaGF3!\"\"F6F6*&%$_C1GF/-%$cosG6#*&F5F/F' F/F/F/*&%$_C2GF/-%$sinGF;F/F/" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 100 "Now take a linear combination of all particular solutions using the F ourier coefficients as weights." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "yp:=t->sum(-exp(I*m*t)/(m^2-omega^2)*c[m],m=-n..n);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%#ypG:6#%\"tG6\"6$%)operatorG%&arrowGF(-%$s umG6$,$*(-%$expG6#*(%\"IG\"\"\"%\"mGF69$F6F6,&*$F7\"\"#F6*$%&omegaGF;! \"\"F>&%\"cG6#F7F6F>/F7;,$%\"nGF>FEF(F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 39 "Plug it into the differential equation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "res:=t->dop(yp(t));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$resG:6#%\"tG6\"6$%)operatorG%&arrowGF(-%$dopG6#-%#yp G6#9$F(F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "res(t);" }} {PARA 12 "" 1 "" {XPPMATH 20 "6#,0*(-%$expG6#,$*&%\"IG\"\"\"%\"tGF+!\" &F+,&\"#DF+*$%&omegaG\"\"#!\"\"F3%#PiGF3F2*(-F&6#,$F)!\"$F+,&\"\"*F+F0 F3F3F4F3F2*(-F&6#,$F)F3F+,&F+F+F0F3F3F4F3F2*(-F&6#F)F+F@F3F4F3F2*(-F&6 #,$F)\"\"$F+F:F3F4F3F2*(-F&6#,$F)\"\"&F+F.F3F4F3F2*&F1F2,0F$#!\"#F/F5# FQF;F \+ " 0 "" {MPLTEXT 1 0 11 "omega:=1/2;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>%&omegaG#\"\"\"\"\"#" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 53 "p lot(\{f(t),Re(res(t))\},t=xrange,scaling=constrained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 117 "Just to convince ourselves that everythi ng is real, plot the imaginary part and observe that it is vanishingly small." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(Im(res(t)), t=xrange);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 75 "Here is the plot of the actual approximate particular solution we obtained." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "plot(Re(yp(t)),t=xrange,scaling=con strained);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 28 "Again check that it is real." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "plot(Im(yp(t)) ,t=xrange);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK " 19 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }