# MATH 3150 MAPLE PROJECT 2, SUMMER 99 # CONVERGENCE OF SERIES AND ANIMATED SOLUTIONS OF THE HEAT EQUATION # # A. CONVERGENCE OF SERIES # # We are going to discuss this in terms of Fourier sine series, that is, # series of the form # # f(x)=sum(b(n)*sin(lambda(n)*x), n=1..infinity) # # where lambda(n)=n*Pi/L , the b(n) are the coefficients of the # expansion, and x can take any value in the interval [0,L]. The # question is, what exactly does the equals sign mean in this # situation? Since we can only compute the sum of a finite number of # terms, as a practical matter we are interested in how "good" an # approximation we can get if we take at least N terms in the sum. I # have put "good" in quotes because we have not yet defined what it # means. Here we will talk about three (out of many) possible meanings # that can be given to this word. # # 1. Pointwise Convergence # Given a specified error epsilon>0, then for any fixed x in the # interval [0,L] there is an integer N(x), depending on x, such that # whenever more than N(x) terms are taken in the sum, then the absolute # value of the difference between f(x) and the sum is less than epsilon. # # # 2. Uniform Convergence # Given a specified error epsilon>0, then for every x in the # interval [0,L] there is an integer N, not depending on x, such that # whenever more than N terms are taken in the sum, then the absolute # value of the difference between f(x) and the sum is less than epsilon. # # # The difference between 1 and 2 is this: if the series converges # uniformly, it is possible to choose a single N such that taking more # than N terms will give a small error for every single x in the # interval [0,L], whereas, if the series converges pointwise, it is in # general only possible to choose N so as to quarantee a small error at # any finite number of points chosen in the interval, the error at # other points might be large. # # 3. Mean Square Convergence # Given a specified error epsilon>0, then there is an integer N # such that whenever more than N terms are taken in the sum, then the # integral of the square of the difference between f(x) and the sum is # less than epsilon^2, the integral being over the interval [0,L] # # The "Mean" in the name means: take the integral. # # It is worth noting that in cases 2 and 3, "goodness" can be measured # by a single number: in case 2 this number is the maximum error which # occurs in the interval [0,L], whereas in case 3 this number is the # integral of the squared difference (or the square root of this # integral). It is not generally possible to characterize pointwise # convergence by a single number. # # So what does the equals mean? In the case of expansions in orthogonal # functions, it means mean square convergence . However, this does not # exclude the possibility that the other types of convergence also hold, # and in fact we will have a theorem covering these cases later on. # # What does all this look like? We will work out two examples. But # first, lets load up the plotting package so we can see the results. > restart;with(plots): # For the first example, we will expand the function f(x)=1 on the # interval [0,1] in terms of sines. Note that we use the Maple command # "assume" to tell Maple that n is an integer, so that Maple will know # that sin(n*Pi) is zero. We will use "un" for the function # sin(lambda(n)*x) and use the inner product method. > assume(n,integer); > innerprod:=(f,g)->int(f*g,x=0..1); > lambda:=n->n*Pi/1; > un:=(x,n)->sin(lambda(n)*x); 1 / | innerprod := (f, g) -> | f g dx | / 0 lambda := n -> n Pi un := (x, n) -> sin(lambda(n) x) # Recall that for sine series we have # = L/2, or in this case, 1/2 since L=1. Lets just check this. > innerprod(un(x,n),un(x,n)); 1/2 # Perfect! Let us now find the coefficients in the expansion. > an:=2*innerprod(1,un(x,n)); > a:=unapply(an,n); n~ (-1) - 1 an := -2 ---------- n~ Pi n~ (-1) - 1 a := n~ -> -2 ---------- n~ Pi # Note that we have used the Maple command "unapply" to turn the # expression "an" into a function of "n". We need this in order to # define the partial sums "psum", which we make a function of x and the # number of terms to be included in the sum. > psum:=(x,n)->sum(a(k)*un(x,k),k=1..n); n ----- \ psum := (x, n) -> ) a(k) un(x, k) / ----- k = 1 # We now display the result in sequence for different numbers of terms # in the sum starting at 1 and going up to 50. This is an animation, so # in order to see what happens you need to select the plot by clicking # on it (it should become surrouded by a square) and then go up to the # toolbar, select animation, and then run it. > S:=[seq(plot(psum(x,j),x=0..1),j=1..50)]: > display(S,insequence=true); # As the animation runs, fix your eye on some point near the center and # note how the error - the difference from 1 in this case- trends # towards zero, this is pointwise convergence. However the maximum error # remains about the same, although it gets pushed out towards the ends. # Thus the convergence is not uniform. Lets check the trend on the mean # square error. We have cheated here to save computation time. The # result used here will later be covered in class. > error:=[seq([jj,1-(1/2)*sum(a(kk)^2,kk=1..jj)],jj=1..50)]: > plot(error,x=1..50); # Note that the trend is indeed towards zero. # # # B. ANIMATED SOLUTION OF THE HEAT EQUATION # # OK, all we need to do make the previous results a solution of the heat # equation in a rod with the ends held at zero degress is to add in the # time terms. However, we are also going to change the interval to # [0,50] and take the heat diffusivity K=1. Again we will use the # innerproduct method, so we need to redefine the innerproduct to apply # to the new interval. So.. > innerprod:=(f,g)->int(f*g,x=0..50); > lambda:=n->n*Pi/50; > un:=(x,n)->sin(lambda(n)*x); > K:=1; > f:=x->1; 50 / | innerprod := (f, g) -> | f g dx | / 0 lambda := n -> 1/50 n Pi un := (x, n) -> sin(lambda(n) x) K := 1 f := 1 # We now compute the coefficients in the expansion. > an:=innerprod(f(x),un(x,n))/innerprod(un(x,n),un(x,n)); > a:=unapply(an,n); n~ (-1) - 1 an := -2 ---------- n~ Pi n~ (-1) - 1 a := n~ -> -2 ---------- n~ Pi # Our solution is now of the form # T(x)=sum(a(k)*exp(-K*lambda(k)^2*t)*un(x,k),k=1..infinity), where T is # the temperature. Since we can't actually sum up to infinity, we will # take fifty term as a good approximation. From the previous results, we # know that this will not work well near the ends of the interval, # however this effects disappears rapidly as soon as time starts to run. # Thus we will actually start the plot ofter a bit of time has passed to # minimise the "rabbit" ears. Again, you will have to select the plot # and then run the animation from the toolbar. > T:=(x,t)->sum(a(k)*exp(-K*lambda(k)^2*t)*un(x,k),k=1..50); 50 ----- \ 2 T := (x, t) -> ) a(k) exp(-K lambda(k) t) un(x, k) / ----- k = 1 > animate(T(x,t),x=0..50,t=.5..200,frames=50,color=black); # Notice how at the starting time of .5 sec the wiggles at the corners # have mostly gone away, leaving us something which is pretty much the # initial condition of T(x,0)=1, but also satisfying the boundary # conditions T(0,t)=T(50,t)=0.