 All right, so on our course website, there's a file. There's actually a couple of files. Now, another thing that I need to tell you is that the data that you measure has amplitude and phase and it is represented or stored on the instrument as a complex signal. Okay, so it has a real part and an imaginary part. That's the raw data in an NMR experiment. So what we're going to do first is we'll look at just to see how ugly it looks the real part of the free induction decay, so the NMR raw data for that molecule that we just looked at. All right, and the way we can do that is we can define data equals import and then I'm going to put in the web address which is here, FID versus time.dat on our course website, the links page. All right, so mouse this in and put it in here and it's got a lot of points in it, so I'm going to put a semicolon. Okay, now let me just say something here. So what is this? Well, this is not a continuous function, right? The way this is done is that the data is acquired by sampling it at regular time intervals, so the data is actually discrete. Notice on the left, the first column here in this particular file is time in seconds, all right? And you can see that the spacing between these points is very, very close to 0.0002 seconds, all right, so 0.2 milliseconds. And then the column on the right is the real part of the free induction decay, so that's our signal. Okay, and that's what we just imported and now let's have a look at what it looks like. Since it's discrete data, we should say list plot and then data, all right, and we can say plot range or all. Okay, now here is a beautiful illustration of why you should love the Fourier transform. This is the NMR data. Can you look at this and tell me that this is the NMR data, the free induction decay of that molecule? No. Can you even tell me that there's eight oscillatory components to that signal? No. We can't see squat from that, but when we convert it to an NMR spectrum, which has eight peaks in it and we take organic chemistry and learn how to assign peaks and organic molecules, then we can actually turn the Fourier transform of that into a molecular structure. And maybe you haven't realized it, but that's pretty cool. The fact that you can look at an NMR spectrum in many cases and infer so much detailed structural information. But this is what you meant, and it's the Fourier transform that gives you the thing that you can interpret. All right, so that's what we're going to do here and there's going to be some aspects of this that are going to be over the head. All right, so don't worry about that. And the first aspect of it is that we have to use a technique called discrete Fourier transform because our data is discrete. All right, and I'm just going to show you very quickly what that means. So let's go to the documentation center and let's just look up Fourier. All right, and when we look up Fourier, we get this thing here and this command it says finds the discrete Fourier transform of a list of complex numbers. So that's what we want. So let's see what's actually going to be done here. I'm sorry, you probably can't see it, but you can look on your screen. Okay, so first of all, the general form which, you know, looks kind of ugly, but I think you can recognize that it looks something like the formulas we were writing down previously, this is actually what's being calculated, okay? We're taking a function u, well in this case a signal u which has, it's been sampled at points r go from 1 to n and it's the number of points in the signal, okay? So this is just a list of numbers u, which is what we have. And then depending on what b is, it will do a forward or reverse Fourier transform. Now b is going to be, we can have access to b through a Fourier parameters option, okay? So we're going to put in b equals minus 1 for a forward Fourier transform. Now what we're going to get out is a list of numbers that is the Fourier transform but also evaluated at discrete intervals. And so we're going to have to turn the numbers. We're just going to have 1 and then a value and then 2 and then a value and then 3 and then a value. We're going to have to turn that into frequency information by making use of the relation between an increment in time and an increment in frequency, okay? And they're basically just reciprocals of one another. All right? So another little thing is that there's a factor out in front which scales the Fourier transform by a number and there's a parameter a in there which is one of the Fourier parameters. For our NMR spectrum, we're going to set a equal to 1 which means we're not going to scale by anything because N to the 1 minus 1 is N to the 0 which is 1, okay? And this is the convention as it says here for signal processing which is what we're doing. All right? So the next thing we're going to do is we're going to read in the complex data, the free induction decay. All right? We're going to use this command to get the discrete Fourier transform of that and then we're going to make a table in which the discrete Fourier transform is lined up with the corresponding frequencies, all right? And then we're going to plot it and it's going to be an NMR spectrum of that molecule Phenanthrita known. Okay, so let's go ahead and do that. All right. So we don't need this thing. Get rid of that. Now, the data that we want is also on the website. So let's go ahead and mouse that and put it in, okay? And the name of the file is called FID only, all right? And we can have a look at that here. Let's go back. If you look at FID only, it doesn't have the time in it because the Fourier command just wants the signal, okay? And the first column is understood to be the real part and the second column is understood to be the imaginary part, all right? So this came off the NMR instrument, all right? And now we are going to read that in to a file that I'll call F, or to a table that I'll call FID for free induction decay, all right? So we enter that and now we have that list of numbers. And now what I want to do is make sure that the second column is an actual imaginary component by multiplying each of those numbers by I because as they come, they're just the imaginary, if you like, coefficients, all right? And we know how to do that. So what I'm going to do is say FID bracket bracket all comma 2, so that means all the numbers in the second column equals I times FID bracket bracket all comma 2 and put a semicolon, all right? And now I'm going to define a matrix that's going to be the real part of the Fourier transform. So I can see the absorptive part of the spectrum, all right? So I'm going to call that FT for Fourier transform. And now I'm going to say give me the real part, RE bracket. And then the discrete Fourier transform is Fourier bracket. What I want to take the Fourier transform of, so that's my FID and then I put in my option Fourier parameters, arrow and we said we wanted 1 for A and minus 1 for B, okay? And then I need a bracket, bracket, all right? Now it's a shame I don't have my pen, okay? So the next thing that I want to do is I want to create a list of the frequencies that correspond to the, well, that are related to the time points that I read in, okay? So I have a list of time points. They're sampled every 0.2 milliseconds and then they span a certain amount of time and I don't remember how much that is. But it turns out that the frequency interval in Hertz is equal to 1 over the full time range of the data, all right? So what I need to do is construct a frequency interval that I can use to create the frequencies that I'm going to plot my NMR as a function of, all right? So the way I'm going to do that is that I'm first going to find out what's the time interval? So I'm going to call that DT and I'll find that by just saying that's data, that FID versus time, 1 or 2 comma 1 minus data, 1 comma 1. Let me tell you what this is going to do, all right? So let's go back here, all right? So what that's going to do is it's going to take this number and subtract this number from it, all right? So it's going to tell me what's the time interval, okay? So we can see it's going to be 0.2 milliseconds. Actually, I don't really even need to do the subtraction because the first time point is 0. All right. Now, the next thing that I can do is create the spectrum. The spectrum is going to be a table of numbers where in the first column is going to be the frequencies and the second column is going to be the real part of my Fourier transform. All right? So I'm going to say spectrum equals table and then I'm going to have a curly. I'm going to put in an index J divided by and now this is going to be the length, I mean the full time spanned by my time data. So that's length of FT. So that's the number of points in my Fourier transform and then times DT, all right? Now, and then I'll put a parentheses. So what is this? This is a number which we're going to index through divided by this is basically the full length of the NMR data, the time spanned by the full list of NMR data, okay? That's just the number of points in that time data times the time interval between points, okay? So if this is 0.2 milliseconds and this is 100, then I get 20 milliseconds but it's not 100, it's more. I don't remember how many, okay? And then when we walk the table through 1, 2, 3, 4, 5, 6, et cetera, it's going to be multiplying that, all right? So if you like, 1 over this stuff is an interval and frequency. All right, so that's the frequencies. And then what we'll do is we'll put in Fourier transform and we want the real part, actually we already have the real part, so we'll say bracket, bracket, J comma 1, bracket, bracket and then J goes from 1 to the length of the Fourier transform, all right? Now, what this is going to do is create the table just to reiterate, this first is going to be frequencies and the second is our Fourier transform, the real part. Now, there's one little technical detail which is to get the units right from the data, the way the data came to us and this is something that's not obvious at all, so don't worry about it. We actually, to make the heights of the peaks correct, we have to multiply this guy by the time increment, dt, all right? So let's go ahead and put in dt. Now, the next thing we're going to do is we're going to plot it, all right? And this is discrete data and so we're going to use list plot, let's say list plot spectrum comma and then since I've already done this I know what a nice plot range is to be able to see it, so I'm going to put in plot range arrow, curly, curly, so the frequency is going to go between 0 and 1,000 and we'll talk about what the frequency is in just a minute. And then the amplitude, the height will go from minus 5 to 40, all right? I think we're ready to let it rip, so go ahead, whoops. Oh, I need two brackets here, all right? Mm-hmm, list plot spectrum. Oh, this thing here should be ft, yeah, okay. All right, now, well, you're jumping ahead by looking at the notes, so all right, so the first thing is this looks ugly, all right? Because we use list plot, it's plotting each point. Now, there's another plot command that I don't think we've used yet, which is called list line plot, which basically just connects the dots, okay, so let's put that in, all right, list line plot and something's wrong here, doesn't look very good, does it? So, let me see what did I screw up. So, we got our fid multiplied by i and we got dt, or no, we took the Fourier transform of the fid, we got the right Fourier parameters, all right? Now, we got our dt and our spectrum equals, like the ft times dt and then dt times ft, they have one. I'm sorry, I can't hear. I need to reload, you think? Well, we can try it. All right, let's try that and that, aha, thank you very much. Okay, so, what do we have here? Does that look like an NMR spectrum? It kind of does. Let's see how many peaks it has. How many were we supposed to have? Eight. One, double it, double it, double it, so that's three peaks, fourth is a triplet, fifth is a triplet, sixth is a triplet, seventh is a double it and eighth triplet, okay? So now, in principle, you could use all the tricks that they teach you in organic chemistry and see if you can assign the spectrum. This one's a bit tricky. But in any case, one other thing that I want to tell you about this is, look at the axis here. Do those numbers look fishy compared to your, based on your experience with the proton NMR spectra? What do you normally, when you go and measure it in the lab and then look up the various chemical shifts, what are you normally plotting as a function of? I just gave it away. The chemical shift, all right? This isn't the chemical shift. This is the frequency in hertz. Now, in order, so I don't know if they teach you this in organic chemistry, but I won't go into too much detail. This is the correct NMR spectrum plotted as a function of hertz, and we could convert it to chemical shift if we wanted. But if we need, if we want to convert it to chemical shift, we need to know something about the instrument on which this was measured that I don't know, so I can't do the conversion for you, all right? We basically need to know the magnetic field strength, and we also need to know the frequency at which TMS, our reference molecule, has its peak. Okay, but we're essentially done, right? This looks like an NMR spectrum. The relative positions of the peaks, you know, upfield, downfield are the same as they would be if we had a chemical shift, so in principle, you could assign this spectrum, all right? So, but what's the point of this exercise? The point of this exercise, even if it was a bit confusing or intimidating, was to give you a feeling for what it is that you're doing nowadays when you go in to, you know, a pulsed field NMR lab and take a spectrum. You measure this, all right? And the Fourier transform is what gives you your NMR spectrum. Okay, so what I hope this is for you is a practical example of a place where if you are a chemist, something that you use every day actually involves a Fourier transform, all right? Does anybody have any questions on this example? Okay, so to finish up this lesson, I'm going to show you one more example that involves a Fourier transform. Okay, well, this will be a simple example that we'll do sort of by hand if you like, okay? And for this to explain you the significance of this, I will go back to the notes. All right, now this is another Fourier entertainment only. Okay, I mentioned this before, and so here we'll actually see how it works. So all of you have seen pictures of molecular structures that were determined experimentally, three-dimensional structures. Probably you've all seen beautiful pictures of protein structures or nucleic acid structures. NMR is one of the ways that you can determine those structures, but especially in the realm of biological molecules, a technique called X-ray crystallography is the most prevalent. Now, what is crystallography? Well, we all know that a crystal is a regular array of identical objects, right? And if you look in a crystal and you look at it in the right directions, you can always find planes of atoms that are repeated, right? So you can draw planes through atoms in the crystal. Now, it turns out that those planes are like slits through which waves can be diffracted and interfere. And so when you shine waves on a crystal, waves in the form of either electromagnetic radiation or you can shine neutrons or electrons on crystals, the waves interfere with one another and they have construction and interference, constructive interference at places that are dictated by essentially Bragg's law, okay? And so what you measure is an interference pattern that carries the information on the structure of the crystal. Now, it turns out that you measure this interference pattern in a space called reciprocal space. It's actually momentum, essentially. It's related to the change in momentum of the waves as they are scattered, all right? Now, the question is how do you get the structure? So if I'm given information in momentum space and I want information in x, y, z space, what do you think I need to do? We have time and frequency and we have position and momentum and those spaces are related by Fourier transforms, okay? So here in more detail is essentially what's done, okay? So what you do is you measure intensities of your, the interference pattern is basically intensities as a function of indices which tell us the different directions or if you like, it carries information on the directions at which the planes are oriented in the crystal, all right? So they're typically, well, there are three indices for a three-dimensional system that define the interference pattern. They're called H, K and L, okay? And it turns out that the intensities, the theory of x-ray or the theory of let's say scattering in general, tells us that the intensity that we measure is actually the square of a complex quantity called the structure factor, okay? And the structure factor is given here. It's the sum over all the atoms in the unit cell of the crystal of some number that tells us how strong that atom scatters whatever it is that you're putting in. If it's x-rays it would be a measure of the number of electrons in the atom. And then there's this thing that looks like a complex Fourier object, okay? So this guy is a function of these indices that are basically measurements of the momentum transfer in the experiment. And so now if we want to convert that into something in real space what we need to do is Fourier transform these guys. All right? And so what we do is we actually sum now over the indices the momentum variables if you like. That quantity, the structure factor amplitude and do the Fourier transform as indicated here, the discrete Fourier transform. All right? So we measure interference pattern in this momentum space that's quantified by these indices H, K and L. We take the Fourier transform and we get a quantity which tells us about the density of scatterers in real space. R here is a vector in x, y, z space, all right? So forget about the equations and then just the one thing that I want you to take home from this little exercises. When we do crystallographic experiments we're not measuring the structure. We're measuring objects in momentum space called structure factors essentially. And to get a structure in real space we have to do the Fourier transform, all right? Now another little thing to keep in mind is that we're actually measuring densities. So in an x-ray crystallography experiment you don't actually measure the positions of the atoms. You measure the electron density and then usually you have techniques to sort of snake a structure into the electron density. If you use neutron scattering you're actually measuring something related to the nuclear density because neutrons scatter from nuclei, all right? Okay, so what we're going to do to finish up day and it's just going to take a few minutes. It's a short example. It actually comes from the Atkins book on physical chemistry is that we're going to consider a hypothetical one-dimensional crystal, okay? And so we're basically just going to have one index, h, and then we'll have a few structure factors so there'll be a bunch of numbers called f of h. And then we're going to Fourier transform and get a density row of one variable we'll call x, okay? So you can imagine this is just a one-dimensional crystal and we're going to determine the electron density or whatever the density is, yeah, we can call it the electron density and see the structure of the crystal, the one-dimensional crystal, all right? And this is a simple example where we can type everything in by hand. All right, so the first thing that we're going to define is a variable or a number of structure factors that we're going to have, okay? So we're going to have structure factors that have magnitudes varying up to 15s. I'm going to call h max equals 15, okay? So h is going to go from minus 15 to 15. It's going to be minus 15, minus 14, da-da-da-da-da-da, 14, 15, all right? So that means we're going to have a total of 31 structure factors and now we're going to type them in, all right? They're just in the notes, so if you want, you can just get them from there. All right, so I'm going to call my structure factors fh, okay? And it's a list of numbers, minus 3, 2, minus 2, 3, minus 5, 6, minus 3, 2, minus 3, 8, minus 10, 7, minus 1, 2, minus 10, 16, minus 10 again, 2, minus 1, 7, minus 10, 8, minus 3, 2, minus 3, 6, minus 5, 3, minus 2, 2, and minus 3. All right, so sorry about that. That was kind of tedious. And let's just make sure we have 31. Let's check the length, length with a capital of fh. Okay, so we have 31, hopefully everybody. Now, what this is is the raw data that you would get from the actual scattering experiment, the diffraction experiment, okay? So there would be a bunch of spots in the interference pattern, 31 spots. Actually, in this case, the ones at minus and plus are related, so there's 16 unique spots. But in any case, these are the amplitudes of the structure factors at values of the index in momentum space, h, okay? So that's the raw data. And now what we're going to do is we're essentially going to just by hand do the Fourier transform and get out, if you like, the electron density of the crystal, the one-dimensional crystal as a function of x, the position along the x-axis for these structure factors. All right, so we'll define a function, rho of x underscore colon equals sum, all right? And what I'm going to sum now is we're going to, we're basically doing this formula here. V happens to be the unit cell volume, which we'll just assume is 1. We're going to do this sum, except we're not going to have y and z. We're going to do f of h times e to the minus 2 pi i hx, okay? That's our discrete Fourier transform that's going to take us from our structure factor amplitudes into an electron density, which will tell us about the structure of our one-dimensional molecule. All right, so then, okay, back to the exercise. So now we say exp, well, wait, I need to know, to first fh, fh, bracket, bracket, j, bracket, bracket, we're going to use j to sum times exp minus 2 times pi times i times x, and now what I need to do is my index j is going to go from 1 to 31, all right? And in order to get the h properly into the exponent, I have to do a little trick here. So I'm going to say times j minus h max minus 1. All right, I'll explain this to you in just a second, and then that's everything. And then we say j goes from 1 to 2 times h max plus 1, all right? So what's this going to do? What is this thing? Remember, our h goes from minus 15 to 15, but our j is going from 1 to 31. So what this does is it turns j, which goes from 1 to 31, into h, which goes from minus 15 to 15, all right? So we have h properly installed in the Fourier transform. All right, now we can put in a semicolon, and then we're going to plot the result, all right? So we're going to say plot rho of x, and x is going to go from 0 to 1, 1 is the length of my unit cell. And then we'll say plot range arrow all, all right? So let's go ahead and try that, and there you got it. So that's the structure of our one-dimensional crystal. Does that look like a molecule to you? No? Well, it does if you know how to interpret an electron density, all right? Remember, what we've plotted here, this would be the electron density if those structure factors were say coming from an x-ray diffraction experiment. And so what I see here is that we have some wiggles. This is just noise in the Fourier transform because it's not infinite. But I see a peak here that stands above the noise, which is the electron density in one dimension of an atom, one atom, and then I see another peak. So it must be another atom. And then I see a third peak, which looks a lot like this one. So what I see in this is the structure of a one-dimensional molecule that has three atoms, one of which is right in the middle of the unit cell, and is different from these two. Another thing that I see in this structure is that whatever this atom is, it's got a higher molar mass than these atoms. Why can I say that? There's more electron density here. Number of electrons in an atom is proportional to its atomic number, right? So I have two little atoms bonded to a big central single atom. It looks like the bond lengths are about the same here. Or it may be a, might be a crystal with ions in it. Okay, so that's going to do it for today. Sorry, I stole one minute from you. But hopefully you got a little bit of appreciation of the real practical applications of Fourier transforms to sort of everyday problems of molecular structure determination in chemistry. All right, so next time we'll start talking about vectors and matrices. And next time is going to be on Monday.