 Okay, it's one o'clock, so let's get started. I have an important announcement to make about what we're going to do in here on Thursday. So one of the things, most of this class is about learning how to use the Mathematica software to do calculations, data manipulations that are relevant to chemistry, problems, experiments, et cetera. But another one of the things that we like to teach you in this course is how to use online resources for finding chemical information. So for example, from the literature and also how to search the literature and databases for chemistry data. And so on Thursday, in order to give you a quick crash course on some of the many resources that are at your disposal through the UCI Science Library, the Science Librarian for Chemistry, Mitchell Brown, will be coming to give a presentation during Thursday's lecture. And there will be a homework assignment that will involve using the tools that he shows you how to use on Thursday. So you should all make sure to come to that. In addition, stay tuned to your email because one of the tools, very powerful tools that you're going to learn how to use is called SciFinder Scholar from the American Chemical Society. In order to have access to that, you have to register. And I'll be sending you registration information soon, probably as soon as this afternoon or evening. So as soon as you get that information, please go ahead and sign up to be registered for SciFinder Scholar so that you'll be able to use it to do your homework and also to follow along on Thursday. Okay, so that's one thing. Another thing is that you should have gotten an email from me that told you that I activated mid-term evaluations. And I know you're all very, very busy, but if you have any comments about how things are going so far in this course, good, bad, or otherwise, please let me know because it's still not too late to make some changes to make the course more effective. And then, of course, at the end of the quarter, you'll be asked to do the final evaluations which will be submitted to my department. And those will be ones that will be formal and taken very seriously. But in any case, if you have anything to say about the course so far, please let me know. You don't have to write long essays unless you want to. Okay. All right. So the next thing I'm going to do here is we'll go over this week's homework assignment. And notice that in addition to the homework assignment, there's two other files. These are the mid-terms. And that's because the first problems, the first two problems in the homework, I'm asking you to solve problems from the other sections mid-term. So we're in section A here, all right? And so since we're in section A, what I want you to do for problem number one is to do problem number two from the mid-term B. And then for problem number two, I want you to do problem number three for mid-term B. And the reason for this is that as I was walking around in both sections during the mid-term and looking at what people were doing, it became evident to me that probably a little more practice doing derivatives and integrals and interpreting equations and typing them into Mathematica properly would be helpful. So that's the point there. And then the rest of the assignment has to do with series and expansions. Okay. So problem three, I want you to enter that sum that you see there, that series, and evaluate it in Mathematica. And if you did it correctly, you should get a relatively simple closed form expression for that sum that involves trigonometric functions, all right? And then in problem four, we're going to consider the relation between the energy and momentum in relativistic mechanics, all right? So these formulas are different from those of classical mechanics when you take relativistic effects into account. And here each of these, the energy and the momentum is written in terms of the velocity. And the velocity here is in units where the speed of light is equal to 1. Okay. So I want you to do a few things here. This is basically to give you some experience with expansions and then seeing actually how they work and how useful they can be. So the first thing I want you to do is go ahead and just enter these in to Mathematica. And then I want you to evaluate the first one squared and then the second one squared plus the mass squared, okay? And I instruct you for the second one to go ahead and put the post fix full simplify on there because it will give you a form that will make it easier to compare to the expression for E. And if you do that right then you should see that in fact this one equals this one so this is an important relation in relativistic mechanics, all right? Now in part B what I want you to do is take both of these and expand them to fourth order in V. And around the point V equals zero so it's a Maclaurin expansion of each of those formulas and put them inside the normal wrapper thing so it will truncate the of the order of V to the fifth that comes out if you don't do that. And also assign each of these to a variable because you're going to use those series in the next part, all right? So the next part what you're going to do is you're going to use your series to evaluate the square of the energy and then the square of the momentum plus the mass squared, all right? And what you should find is that the two expansions give the same identity E squared equals P squared plus M squared to fourth order in the velocity. In other words the expansions reproduce the identity to the same order of accuracy that they're carried out, okay? So that's an interesting thing to see. Now in order to see that properly what I want you to do is enclose each of these evaluations inside this new thing that you haven't seen yet but you'll see how it works, try it with and without, it's kind of cool this one which is called expand, all right? So that will multiply everything out so that you'll have expressions that you can easily compare between those two and like I say you should find that they're identical up to the terms of order V to the fourth. Okay. And then in the last problem what I want you to do is a so-called harmonic analysis of an energy function that's meant to represent the energy as a function of bond length and a diatomic molecule. It's called the Morse function. It has a pretty realistic shape and it's given by this formula here where B is the position of the minimum in the energy where the preferred bond length is, R is the distance between the two atoms, D is the dissociation energy or the depth of the energy well and A here is just a parameter determining the shape of the potential, okay? So what I want to do is enter that in and then I want you to generate what's called a harmonic approximation to that function. Harmonic approximation means a second order Taylor expansion around the minimum which in this case is equal to B, all right? So you can type that in and then you're going to make the second order Taylor expansion which you should assign to a variable and then I want you to plot the actual function V of R on the same graph as your expansion so that you can see how the harmonic approximation works and what you should find is that the harmonic approximation which is out to terms in R squared should be a good approximation to the shape of the potential energy V of R when you're close to the minimum and those of you who are in Chem 131 will hear more, you've already heard about that I guess in discussing the harmonic oscillator approximation to the vibrations of molecules, all right? So probably you already saw something like this but now you get to do it yourself and I give you some details here about the values that you should put in as well as the range over which you should plot the function, all right? So that's this week's homework due Saturday as usual and are there any questions on that, all right? Okay, so last time we finished up our treatment of expansions by looking at the Taylor and McClurrin expansions of functions. Now this time what I'd like to do today is talk about a useful way of expressing periodic functions, okay? So these are series representations of periodic functions and they're called the Fourier series named after Joseph Fourier who's a mathematician who studied the properties of these series, okay? So I'm going to go to the board so I can make some definitions and then we'll play around with it and see how it works. All right, so the first thing is that we're going to consider that our function is going to be periodic on the interval x goes from minus pi to pi, all right? So this just means that one cycle is over the 2 pi range from minus pi to pi and then it just repeats itself infinitely in both directions, okay? And now the Fourier series representation of the function and this is just some arbitrary function. All we're saying is that it's periodic over that interval. We write this function in terms of sines and cosines because sines and cosines are functions that are periodic and therefore we ought to, if we add up enough of them, be able to reproduce the behavior of f of x and so that's what we're going to see how that works today and this will be our introduction to how we can represent periodic functions and then analyze their oscillatory behavior using a transformation that we'll learn about shortly. All right, so the way this works is that there's a constant term and then there's a sum which in principle can go to infinity and this is, the first sum is the cosines and then we have another sum which contains the sines, okay? So in practice you might represent it by a finite number of terms and we'll see how that works. Now, it turns out that these coefficients you can calculate as integrals of the function, all right? So the first one, a0 happens to be equal to and we'll verify this in a minute. The integral from minus pi to pi of the function and then the rest of the a sub n's equal to 1 over pi integral minus pi to pi of f of x times sine, sorry, cosine nx dx and then the b's are the same thing but with sines, all right? You can kind of see how this works by taking into consideration the symmetries of cosine and sine, even and odd symmetries. You can see that when you multiply this guy by sines, odd times even gives you odd, we're integrating over an even interval so all the terms in the integral of f of x times cosine nx go away and you only left with the cosines and same story for the sines, okay? But in any case, we'll verify these for a couple of terms. All right, so that's the introduction, all right? So what we're going to see is that there's a function in Mathematica that allows us to take an arbitrary function f of x and then generate the Fourier series to whatever number of terms that we want. So, yes, right, so if you look at the functions for the coefficients a, what they say is take the function which we're writing in this form and multiply by cos and then integrate, all right? So the first term here gives me a sub n times cos squared whereas the second term gives me b sub n times a sine times a cosine, okay? Sine times cosine is an odd function, cos squared is an even function. If I integrate an odd function over a symmetric interval minus pi to pi, I get zero. And a good example of that is if you take, right, if you take sine, all these areas cancel, right? So the one thing to keep in mind, it's just like with numbers, odd function times even function gives you odd, even times even gives you even, and odd times odd gives you even. So these terms in principle survive in this particular integral where we multiply by cos and then conversely when we multiply by sine, all these go away when we integrate and these are left. All right, so let's go ahead then and play around with this a little bit, see how it works. All right, so first thing, let's just define a simple function. So I'm going to define f of x underscore colon equals x, okay? And the assumption here is that that's ranging from minus pi to pi, so this is just a line with the slope of one and interceptive zero. Is that an odd or an even function or can you tell? If I plug in minus one, I get minus one. If I plug in plus one, I get plus one, so that means f of minus one is equal to minus f of one, so it's an odd function, okay? All right, so now what we're going to do, and this is, you know, it's just a straight line. So if you like when it repeats, it looks like a sawtooth, right? So if I draw that line here, okay, if I draw that line again and again, because remember, we're assuming it's periodic, you can see it's like a sawtooth function. It just keeps going on and on, okay? All right, so now let's go ahead and generate a Fourier series of that. And being a purely odd function, what do you suppose that we'll get in terms of the terms that we get? Will we get only signs? Will we get signs and cosines? Or will we get only cosines? If you had to guess, we represent an odd function by other odd functions, so it should be the signs, right? So let's try it. So there's our function, and then the command is, it's called Fourier trig with capital T series, all right? And we put, what we do is we put in the function we want to expand, and then we say what's our variable, X, and then we say how many terms we want. So the maximum N. So I'm just going to do three terms here. When you enter that, you see that you get three terms with only signs. One of them is proportional to sine of X, the second one, sine of 2X, and the third one, sine of 3X. And you notice in this case, we didn't get an A0, and we didn't get an A0 because F of X equals X is an odd function when we integrate it over the even interval, it gives us a 0. Okay? And we can verify those things. So let's do, for example, integrate F of X, and then we're going to say X goes from minus pi to pi. So according to the formulas for the coefficients on the board over there, this should be the A0 term, right? And we get 0. Now let's verify the formula for the B1 term. Well, actually the A1 term. So if we take F of X and multiply it by cosine of X, that should be, oops, cosine of X, that should be A1. Notice what we're doing. We're multiplying an odd function, F of X equals X, times an even function, so we get an odd function, and we should see that the integral is 0 and it is. All right? Now let's see if we can reproduce the first B coefficient, so there, we should multiply by sine. Now we have odd times odd, which gives us even, and we see that, in fact, oh, we have to divide by pi to get the actual coefficient, so we get 2, which you can see here is the first B coefficient. And we can do one more just to make it clear that we're consistent with the formulas. Now we can get the B2 coefficient by putting in 2 times X here, and what we find is that it's minus 1, which is what you can see here. Okay, so this is just a verification that the series we get is consistent with the definition of the Fourier series there. Okay, so now let's see how it actually works. How it is that we can take a line, a sawtooth here, and actually reproduce the shape of that thing by using sines and cosines, which are, you know, round functions. And the way I'm going to do this is similar to the way we checked how a Taylor series better and better approximates a function as we add more and more terms, we'll do the same thing here with the Fourier series, okay? So the way I'm going to do that is I'm going to make a table of Fourier series with increasing number of terms, all right? And I'm going to call that expansions, okay? So I'm going to say table and then Fourier trig series and then put in f of x and then x and now i and i is going to range up to some maximum number of terms, okay? And now we'll say i goes from 1 to 5, okay? So we're going to generate 5 Fourier series with maximum numbers of terms, 1, 2, 3, 4, 5, okay? So if you enter that, you get your list of the 5 series and the last one here, as you can see, goes out to sine 5x, okay? Now I'm going to define a plot, which I'm going to call function plot equals and then I'm just going to plot the line f of x and it's going to be from x going from minus pi to pi. So we're going to plot 1, period. And I'm going to make the line thick and black so we can distinguish it from our Fourier representations. So we'll say a plot style, arrow, gray level, bracket 0 and then thickness, bracket 0.005, okay? So that's just going to generate this plot, which you can see here, and stored it in function plot. And now we'll generate a plot of our Fourier series expansions and then we'll draw the two plots together using the show command, all right? So I'll call that set of expansions, expansion's plots equals plot expansions. And now just to make it look a little more interesting, rather than just going from minus pi to pi, we'll go from minus 3 pi to 3 pi. So we can actually see the reproduction of the periodicity. So we'll say x goes from minus 3 times pi to 3 times pi, all right? So I'll put a semi-colon there and then say show function plot. Whoops, I need a square bracket there, function plot. And which one? Oh, okay, let me correct that, sorry, thanks for pointing that out. Just re-enter, so we're consistent now and then we put in expansion plots, all right? And now let's put in, let's see, I'm going to put in here plot range arrow all so we see everything because that's only one cycle, okay? So there you can see how it works, all right? So here's our line and then you can see how the line here, the sawtooth, is more and more accurately reproduced as you add in more signs in this case, all right? So here's the first one. You can see the first one is not a very good representation of the function, that's just one sign, all right? But then you build up and, you know, you have coefficients that can build in more character of the signs that have more oscillations per period. And let's just add a couple more in here so you can see a little better, all right? So let's go ahead and make this go up to 10. I'll put a semicolon so I don't have to look at it, all right? And now go down here and re-enter this, all right? So you see that as you add in more and more, you tighten up the representation of the straightness and you also build up more and more of a point, okay? Notice that it's not perfect but it's interesting to see how you can take such a non-round function and represent it in terms of these signs and cosines, okay? All right, now the next thing that I want to show you, so I'm going to go back to the board now, all right? So here we have a very special case. The very special case is that, you know, the full period here is 2 pi, all right? It's very strict 2 pi, intervals minus pi to pi. Now in general, you can't insist that every periodic function that you would be interested in has 2 pi as its period, all right? So you can generalize, though, to another interval. This is the default interval assumed by Mathematica and I'll show you in a minute how it is that you can actually change that interval. And so the way this goes is we're going to make the interval arbitrary by saying now that the function is periodic between minus L and L, okay? Where L is now a variable that we can specify. And what that does is it causes a slight adjustment of the formulas. Now we have these arguments are N pi X over L. The intervals should go from minus L to L and the 1 over pi factors now go to 1 over L, okay? So a generalization for an arbitrary interval. And we'll do an example of this in just a minute. But now that we've changed the interval from minus L to L, it's no longer the default situation in Mathematica so we actually have to tell Mathematica that we've changed our interval. And unfortunately, the option that we add to the Fourier trig series command here is a little bit confusing, okay? So what I want to do is go from minus pi to pi the default. Now I want to go from minus L to L. Now the way Mathematica would write this is minus pi over some number that I'm going to call B to pi over B. B is what's called a Fourier parameter in Mathematica, okay? So suppose I wanted, for example, suppose I wanted L to be equal to 1. What should I set B equal to? Pi over B equals 1 so B equals, please help me. Pi divided by B equals 1 so B equals pi, yes, okay? Now the way we specify that in Mathematica then is we use an option, it's called Fourier parameters. There's actually two but I won't get into what the first one is just yet. And then we put the option 1 and then the value of B that we want. So if we want to go minus 1 to 1 we would say Fourier parameters arrow 1 pi, okay? So now we'll do an example where we change the interval from minus pi to pi to minus 1 to 1. Can you guys see if I don't have the lights on over here because I forgot to tell you what function we're going to do? Okay, now we're going to do what we just considered in the first example was the sawtooth wave. Now we're going to consider a function called the square wave, okay? And basically what that looks like is the following, okay? It's going to be, let me see how am I defining this one, yes, okay? It's going to be equal to 1. When X is between 0 and 1 and then it's going to be equal to minus 1 when X is between 0 and minus 1, okay? So you can see that if I repeat this guy over and over and then draw dotted lines this makes this thing that we call the square wave. Okay? All right, so that's what we're going to do. We're going to develop a Fourier series for the square wave defined over the interval from X equals 1 here to minus 1. Now in order to define this function we have to do something a little tricky. So let me go ahead and put it in and then I'll explain to you how it works. So now I'm going to define F of X underscore colon equals and we're going to see something new here which is if X and then I'm going to go over here and grab less than or equal to 0 minus 1, 1, okay? Enter. Now what does this mean? This is kind of a cool little way to define this square wave. What it says is the function F is defined as follows. If X is less than or equal to 0 it's minus 1. Otherwise it's 1, okay? And you could put any things in here you want and any condition you want. So this is a way to define some discontinuous function. You see how that works? If whatever this is is true it gets the first value or function and if it's not it gets that one, okay? So what this does is it says over here where X is less than 0 it's minus 1 and then otherwise meaning greater than 0 it's 1, okay? So that's our square wave and now we're going to do more or less the same thing that we did before. So I'll go ahead up here and grab this and then we'll grab function plot, put it there. I'm going to put a semicolon and then we'll grab this here and put it in and then I'm going to make a few modifications because first of all I said that now we're defining, we're going to define f of X between minus 1 and 1. So we'll go minus 1 to 1 and then down here I'll go so we can see some extra cycles will go from minus 3 to 3. Now since I changed the interval from minus pi to pi I have to tell Mathematica what's my new interval and as we just discussed over on the board I'm going to put in the option Fourier parameters arrow 1, pi. Where? Well we've changed f but this command is essentially the same except because we changed the interval we need this, okay? I think I'll start out with a few less. Well we can go ahead and keep 10 why not? There was one other thing I think we need to change here. No I guess not. Okay well let's go ahead and let that rip and see what it looks like. Oops well I have a problem there. Oh okay, right let's see what we have here. Oh this Fourier parameters has to go inside the Fourier trig series command, thank you. Yeah that was my problem. So let's do that, let's get rid of that comma and we'll put it in here. All right now let's see if that'll work. Ah there we go. Okay so how does that look? Well one thing I can point out is maybe you notice this also on the previous one the number of curves that we get is not 10. How many is it? It's actually half because remember this is an odd function so our expansions are going to only have the sine terms, right? And so, wait a minute what am I saying here? Let's have a look at what we got here. If we undo this, all right, it looks like there's half as many curves because there's a repetition, right? Notice there's two of each. So if we wanted we could get rid of all the extra stuff by just saying go i from 1 to 10 and put in an increment of 2 so we'll get 1, 3, 5, 7 and then it looks a little nicer because we're not drawing curves on top of one another. So what do you think? How well is that square wave being represented by the Fourier series? As you add more and more terms you see you tighten up the wiggles around the square. One thing that's interesting and this is beyond the scope of the class is that you could add in an infinite number of terms here and you'll still have a finite amount of this what's called the overshoot. So this function is not, you cannot represent it perfectly in a Fourier series even with an infinite number of terms. There's always going to be a little overshoot which is kind of an interesting thing about that but you can see that you get better and better at reproducing the interior there as you add more and more terms and also that this straight part, discontinuous part gets better and better and you can see that, you can crank up the number a little bit more, let's go up to 20 and you see it's getting tighter and tighter in here. Okay, so there's your introduction to Fourier series. I think we'll go ahead and quit now but what we're going to do next time is we're going to generalize the Fourier series and then turn it into a continuous version which is known as the Fourier transform and then we're going to see that the Fourier transform is a very, very useful mathematical function that allows us to take, let's say for an example, a time signal that has some oscillations in it and to pull out those oscillations in terms of their frequencies. So in other words, we take a wiggly time signal and we can then decompose it into oscillatory components that have particular frequencies. It's a very, very important transformation that's used in signal processing, spectroscopy, there are many, many applications, all right? So we'll see how that works next time, tomorrow.