{VERSION 7 0 "Mac OS X" "7.0" } {USTYLETAB {PSTYLE "Heading 4" -1 20 1 {CSTYLE "" -1 -1 "MS Serif" 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 "Ordered 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 12 0 0 255 1 2 2 2 2 2 1 3 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 "_pstyle3" -1 202 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 1 2 2 2 2 2 2 0 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 12 40 120 40 1 2 2 2 2 2 1 2 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE " Heading 2" -1 4 1 {CSTYLE "" -1 -1 "MS Serif" 1 16 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 "_pstyle1" -1 203 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }3 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Ordered List 3" -1 204 1 {CSTYLE "" -1 -1 "Time s" 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 "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 "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 "Tim es" 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 "MS Serif" 1 14 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 205 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 "_pstyle2" -1 206 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }1 1 0 0 0 0 2 0 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 "_psty le5" -1 207 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 "Line Printed Output" -1 6 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 255 1 2 2 2 2 2 1 2 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 "T imes" 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 12 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 12 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 "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "MS Serif" 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 2 2 2 2 1 0 0 1 }3 1 0 0 12 12 2 0 2 0 2 2 -1 1 }{PSTYLE "_pstyle4" -1 208 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "Ordered List 2" -1 209 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 "Text" -1 200 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "_cstyle2" -1 201 "Times" 1 12 0 0 0 1 2 2 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 "_cstyle4" -1 202 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 0 0 0 1 } {CSTYLE "_cstyle1" -1 203 "Times" 1 18 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 Output" -1 20 "Times" 1 12 0 0 255 1 2 2 2 2 2 1 0 0 0 1 }{CSTYLE "Dictionary Hyperlink" -1 45 "MS Serif" 1 12 147 0 15 1 2 2 1 2 2 2 0 0 0 1 }{CSTYLE "2D Input" -1 19 "Times" 1 12 0 0 0 1 2 2 2 2 1 2 0 0 0 1 }{CSTYLE "Maple Input Placeholder" -1 204 "Courier" 1 12 200 0 200 1 2 1 2 2 1 2 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 0 0 0 1 }{CSTYLE "_cstyle3" -1 205 "Courier" 1 12 255 0 0 1 2 1 2 2 1 2 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "MS Serif" 1 12 0 128 128 1 2 2 1 2 2 2 0 0 0 1 }{PSTYLE "" -1 210 1 {CSTYLE "" -1 -1 "Courier" 1 12 255 0 0 1 2 1 2 2 1 2 1 0 0 1 }1 1 0 0 0 0 2 0 2 0 2 2 -1 1 }{PSTYLE "" -1 211 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 }} {SECT 0 {EXCHG {PARA 203 "" 0 "" {TEXT 203 46 "In-class Demonstration: Fourier Approximations" }}{PARA 206 "" 0 "" {TEXT 201 0 "" }}{PARA 206 "" 0 "" {TEXT 201 35 "By Russell Blyth and Mike May, S.J." }} {PARA 206 "" 0 "" {TEXT 201 0 "" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 20 "restart:with(plots):" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 65 "We start by using Maple to perform some tedious integral s for us." }}{PARA 206 "" 0 "" {TEXT 201 0 "" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 95 " Verify that the functions used as basis vectors in \+ the approximating subspace are orthogonal. " }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 78 "Int(sin(i*Pi*x)*sin(j*Pi*x),x=-1..1) = int(sin (i*Pi*x)*sin(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 78 "Int(sin(i*Pi*x)* sin(i*Pi*x),x=-1..1) = int(sin(i*Pi*x)*sin(i*Pi*x),x=-1..1);\n" } {MPLTEXT 1 205 78 "Int(sin(i*Pi*x)*cos(j*Pi*x),x=-1..1) = int(sin(i*Pi *x)*cos(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 78 "Int(cos(i*Pi*x)*cos(j *Pi*x),x=-1..1) = int(cos(i*Pi*x)*cos(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 76 "Int(cos(i*Pi*x)*cos(i*Pi*x),x=-1..1) = int(cos(i*Pi*x)*cos(i *Pi*x),x=-1..1);" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 144 "That left us with some work still to do. Try again. This time we first tell Map le that i and j are integers (Maple assumes i and j are nonzero):" }}} {EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 39 "assume(i,integer): assum e(j,integer):\n" }{MPLTEXT 1 205 25 "interface(showassumed=0):" }}} {EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 78 "Int(sin(i*Pi*x)*sin(j*Pi *x),x=-1..1) = int(sin(i*Pi*x)*sin(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 78 "Int(sin(i*Pi*x)*sin(i*Pi*x),x=-1..1) = int(sin(i*Pi*x)*sin(i*P i*x),x=-1..1);\n" }{MPLTEXT 1 205 78 "Int(sin(i*Pi*x)*cos(j*Pi*x),x=-1 ..1) = int(sin(i*Pi*x)*cos(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 78 "In t(cos(i*Pi*x)*cos(j*Pi*x),x=-1..1) = int(cos(i*Pi*x)*cos(j*Pi*x),x=-1. .1);\n" }{MPLTEXT 1 205 76 "Int(cos(i*Pi*x)*cos(i*Pi*x),x=-1..1) = int (cos(i*Pi*x)*cos(i*Pi*x),x=-1..1);" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 36 "We need to also integrate against 1:" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 58 "Int(sin(i*Pi*x)*1,x=-1..1) = int(sin(i*Pi*x)* 1,x=-1..1);\n" }{MPLTEXT 1 205 58 "Int(cos(i*Pi*x)*1,x=-1..1) = int(co s(i*Pi*x)*1,x=-1..1);\n" }{MPLTEXT 1 205 36 "Int(1*1,x=-1..1) = int(1* 1,x=-1..1);" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 125 "To compensate \+ for the value of this final integral, we must remember to half the coe fficient of this constant function later." }}{PARA 206 "" 0 "" {TEXT 201 0 "" }}{PARA 206 "" 0 "" {TEXT 201 162 "Graph several of these int egrands as a reality check - note that in each case it appears that th e signed area from x=-1 to x=1 has the appropriate value (0 or 1):" }} }{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 38 "plot(sin(2*Pi*x)*sin(3* Pi*x),x=-1..1);" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 38 "plot (sin(3*Pi*x)*cos(4*Pi*x),x=-1..1);" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 38 "plot(cos(5*Pi*x)*cos(3*Pi*x),x=-1..1);" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 38 "plot(sin(3*Pi*x)*sin(3*Pi*x),x= -1..1);" }}}{EXCHG {PARA 208 "" 0 "" {TEXT 202 0 "" }}{PARA 208 "" 0 " " {TEXT 202 7 "Example" }}{PARA 206 "" 0 "" {TEXT 201 0 "" }}{PARA 206 "" 0 "" {TEXT 201 41 "Find Fourier approximations for f(x) = x." }} {PARA 206 "" 0 "" {TEXT 201 0 "" }}{PARA 206 "" 0 "" {TEXT 201 48 "We \+ compute the Fourier coefficients for f(x) = x" }}}{EXCHG {PARA 202 "> \+ " 0 "" {MPLTEXT 1 205 58 "Int(x*sin(j*Pi*x),x=-1..1) = int(x*sin(j*Pi* x),x=-1..1);\n" }{MPLTEXT 1 205 58 "Int(x*cos(j*Pi*x),x=-1..1) = int(x *cos(j*Pi*x),x=-1..1);\n" }{MPLTEXT 1 205 32 "Int(x,x=-1..1) = int(x,x =-1..1);" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 78 "Note there are onl y sine terms (not surprisingly, since f is an odd function)." }}{PARA 206 "" 0 "" {TEXT 201 74 "Next use Maple to write a general expression for the order n approximation" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 22 "Fapprox := (x,n) -> \n" }{MPLTEXT 1 205 45 " sum(-2*(-1) ^j/(j*Pi)*sin(j*Pi*x),j=1..n);" }}}{EXCHG {PARA 206 "" 0 "" {TEXT 201 59 "We can now plot (say) a 10 term approximation against f(x)." }}} {EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 22 "eval(Fapprox(x,10));\n" }{MPLTEXT 1 205 43 "plot([Fapprox(x,10),x],x=-2..2,y = -2..2,\n" } {MPLTEXT 1 205 114 " title = \" 10th Order Fourier approximation t o y =x\", titlefont = [HELVETICA,12], color = [green,blue]);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 200 30 "We can also animate this plot." } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "mindeg := 2: degsteps := 2 0: bydeg :=4:\n" }{MPLTEXT 1 0 56 "A := display(seq(plot([Fapprox(x,mi ndeg + bydeg*i),x],\n" }{MPLTEXT 1 0 21 " x=-2..2,y=-2..2,\n" } {MPLTEXT 1 0 74 " title=\"degree = \"||(mindeg + bydeg*i), titlefont =[HELVETICA, 14]), \n" }{MPLTEXT 1 0 38 " i=0..degsteps), insequence =true):\n" }{MPLTEXT 1 0 55 "B := animate(func,x=-2..2,y=-2..2,frames= degsteps+1):\n" }{MPLTEXT 1 0 45 "print(\" x vs its Fourier approximat ion\");\n" }{MPLTEXT 1 0 32 "display(A,B,view=[-2..2,-2..2]);" }}} {EXCHG {PARA 206 "" 0 "" {TEXT 201 79 "It is also useful to plot the e rror between the function and the approximation." }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 205 40 "plot(Fapprox(x,10)-x,x=-1..1,y=-1..1, \n" }{MPLTEXT 1 205 112 " title = \"error in 10th Order Fourier approx imation to y = x\", titlefont = [HELVETICA,12], color = red);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT 200 57 "Similarly, we can animate the plo t of the error function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "mindeg := 2: degsteps := 20: bydeg :=4:\n" }{MPLTEXT 1 0 61 "print(\" Error in nth order Fourier approximation to y=x\"):\n" }{MPLTEXT 1 0 14 "display(seq(\n" }{MPLTEXT 1 0 39 " plot(Fapprox(x,mindeg + bydeg* i)-x,\n" }{MPLTEXT 1 0 34 " x=-1..1, y=-1..1, color=blue,\n" } {MPLTEXT 1 0 73 " title=\"order = \"||(mindeg + bydeg*i), titlefont= [HELVETICA, 14]), \n" }{MPLTEXT 1 0 37 " i=0..degsteps), insequence=t rue);\n" }}{PARA 210 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 206 " " 0 "" {TEXT 201 67 "Higher order approximations match the function f \+ even more closely!" }}}{EXCHG {PARA 202 "> " 0 "" {MPLTEXT 1 0 0 "" }} }{PARA 211 "" 0 "" {TEXT -1 0 "" }}} {MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 15 10 1804 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }