{VERSION 5 0 "IBM INTEL NT" "5.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 "" -1 256 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 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 "Heading 2" -1 4 1 {CSTYLE "" -1 -1 "Times " 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 2 1 0 1 0 2 2 0 1 } {PSTYLE "Heading 3" -1 5 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 1 1 2 2 2 2 1 1 1 1 }1 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 "Normal" -1 257 1 {CSTYLE "" -1 -1 "Times " 1 18 0 0 0 1 2 1 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 258 1 {CSTYLE "" -1 -1 "Times" 1 14 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 256 "" 0 "" {TEXT 257 24 "Linear Algebra Powertoo l" }}{PARA 256 "" 0 "" {TEXT 256 22 "Fourier Approximations" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 " " 0 "" {TEXT -1 10 "Online 4.3" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 60 "Worksheet by Michael K. May, S.J., revise d by Russell Blyth." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 258 "" 0 "" {TEXT -1 44 "More on the Example, and then more Examples! " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "We fi rst explore further the example given in class, and then tackle new on es." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "restart:with(plots): " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "Next, instruct Maple to assum e that i and j are integers." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "assume(i,integer): assume(j,integer):\ninterface(showassumed=0): " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "Compute the Fourier coefficie nts for the function f(x) = x" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 146 "Int(x*sin(j*Pi*x),x=-1..1) = int(x*sin(j*Pi*x),x=-1..1);\nInt(x *cos(j*Pi*x),x=-1..1) = int(x*cos(j*Pi*x),x=-1..1);\nInt(x,x=-1..1) = \+ int(x,x=-1..1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "We obtain the \+ following n term Fourier approximation to the function f(x) = x." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "Fapprox := (x,n) -> \n su m(-2*(-1)^j/(j*Pi)*sin(j*Pi*x),j=1..n);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 55 "Let's plot a 6 term approximation against the function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 172 "eval(Fapprox(x,6));\nplo t([Fapprox(x,6),x],x=-2..2,y = -2..2,\n title = \" 6th Order Fouri er approximation to y =x\", titlefont = [HELVETICA,12], color = [g reen,blue]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 104 "It is also usefu l to plot the error , that is, the diference between the function and \+ the approximation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 147 "plot (Fapprox(x,6)-x,x=-1..1,y=-1..1, \n title = \"error in 6th Order Fo urier approximation to y = x\", titlefont = [HELVETICA,10], color = red);" }}}{EXCHG {PARA 5 "" 0 "" {TEXT -1 10 "Exercises:" }}{PARA 0 " " 0 "" {TEXT -1 78 "1) Plot the function f(x) = x against the Fourier \+ approximation with 100 terms" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "2) Plot the error function for f(x) = x and its Fourie r approximation with 100 terms." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 242 "It is instructive to \+ see an animation of the Fourier approximations as they converge to the function that is being approximated. The following block of code set s up frames that plot a Fourier approximations Fapprox against the fun ction func." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 574 "func := x: \nFapprox := (x,n) -> sum(-2*(-1)^j/(j*Pi)*sin(j*Pi*x), j=1..n):\nfram er := proc(n)\n local A, B, C, D:\n A := plot([Fapprox(x,n),func],\n \+ x = -2..2, y = -2..2, color = [blue,green]):\n B := textplot(\{[0,1.8 , `The `||n||` term Fourier approximation (blue)`],\n [0,1.6, `gr aphed against the function (green)`]\},\n font = [HELVETICA, BOLD, \+ 12] ):\n C := textplot([-0.05,1.4, `f(x) = `], align=LEFT,\n font = [HELVETICA, BOLD, 12] ):\n D := textplot([0.05,1.4, func], align = RI GHT,\n font = [HELVETICA, BOLD, 12] ):\n display(\{A, B,C, D\},view =[-2..2,-2..2]);\nend:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 78 "With fr amer defined, it is a simple matter to animate a sequence of 30 frames ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 62 "display([seq(framer(co unt), count=1..30)], insequence = true);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 96 "To run the animation click once on the graph, then use th e playback controls on the control bar." }}}{EXCHG {PARA 5 "" 0 "" {TEXT -1 17 "A second example:" }}{PARA 0 "" 0 "" {TEXT -1 240 "We wou ld now like to look at approximations to the function that is -1 on [- 1,0) and 1 on [0,1). This is a piecewise defined function. Note that we are approximating a very discontinuous function with continuous tr igonometric polynomials." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "g:=x->piecewise(x<0,-1,1):\nplot(g(x),x=-2..2);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 37 "We determine the Fourier coefficients" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 167 "Int(g(x)*sin(j*Pi*x),x=-1..1) = \n int(g(x)*sin(j*Pi*x),x=-1..1);\nInt(g(x)*cos(j*Pi*x),x=-1..1) = \nint( g(x)*cos(j*Pi*x),x=-1..1);\nInt(g(x),x=-1..1) = \nint(g(x),x=-1..1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 104 "Again, the only Fourier coeffi cients that are nonzero are the sine ones, and even some of them are z ero." }}{PARA 0 "" 0 "" {TEXT -1 72 "Note that the sine coefficient is 0 if j is even and 4/(j\271) if j is odd." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 77 "Fapprox := (x,n) -> \n sum((-2*((-1)^j-1))/(j*Pi )*sin(j*Pi*x),\n j=1..n);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 170 "eval(Fapprox(x,10));\nplot([Fapprox(x,10),g(x)],x=-2..2,y=-2..2 ,\n title=\" 10th Order Fourier approximation to g(x)\", title font=[HELVETICA,12], color=[green,blue]);" }}}{EXCHG {PARA 5 "" 0 "" {TEXT -1 9 "Exercise:" }}{PARA 0 "" 0 "" {TEXT -1 125 "3) Write down \+ the 11th and 15th order Fourier approximations to g(x). Then animate t he Fourier approximations up to order 30" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "4) Find the \+ coefficients for the Fourier approximations of h(x) = " }{XPPEDIT 18 0 "x^3" "6#*$%\"xG\"\"$" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "5) Write dow n the 10th order Fourier approximation to h(x) = " }{XPPEDIT 18 0 "x^3 " "6#*$%\"xG\"\"$" }{TEXT -1 57 ". Then animate the Fourier approximat ions up to order 30." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }} }{EXCHG {PARA 4 "" 0 "" {TEXT -1 37 "An example with nonzero cosines t erms" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 85 "In this third example we find Fourier approximations for the ab solute value function." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "k :=x->abs(x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "Find the Fourier coefficients:. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 167 "Int(k (x)*sin(j*Pi*x),x=-1..1) = \nint(k(x)*sin(j*Pi*x),x=-1..1);\nInt(k(x)* cos(j*Pi*x),x=-1..1) = \nint(k(x)*cos(j*Pi*x),x=-1..1);\nInt(k(x),x=-1 ..1) = \nint(k(x),x=-1..1);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 208 "N ow the sine coefficients are all zero, along with half of the cosines \+ terms - not surprising since k is an even function. Recall that the co nstant term is half the integral of k on the interval. Let's check:" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "1/2*Int(k(x),x=-1..1) = 1/ 2*int(k(x),x=-1..1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "Fap prox := (x,n) -> 1/2 + sum(2*((-1)^j-1)*cos(j*Pi*x)/(j*Pi)^2,j=1..n); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 34 "Plot the 6th Fourier approxim ation" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "eval(Fapprox(x,6)) ;\nplot(\{k(x), Fapprox(x,6)\},x=-2..2,y=-2..2);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 5 "" 0 "" {TEXT -1 9 "Exercise:" }}{PARA 0 "" 0 "" {TEXT -1 123 "6) Write down the 11th and 15th order Fourier approximations \+ to k(x) = abs(x). Animate up to the 30th order approximation." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "7) Find the coefficients for the Fourier approximations \+ of f(x) = " }{XPPEDIT 18 0 "x^3-x^2" "6#,&*$%\"xG\"\"$\"\"\"*$F%\"\"#! \"\"" }{TEXT -1 68 ". (The series has coefficients for both sine and \+ cosine functions.)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "8) Write down the 6th order Fouri er approximation to f(x) = " }{XPPEDIT 18 0 "x^3-x^2" "6#,&*$%\"xG\"\" $\"\"\"*$F%\"\"#!\"\"" }{TEXT -1 91 ". Plot the function against the \+ approximation. Animate up to the 30th order approximation." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}} {MARK "0 5 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }