 So we've already done, you know, lots of arithmetic operations, calculations, plots and things like that. And we have not explicitly included units in anything that we're doing. Now I have to make a couple of, let's say, caveats or warnings about using units. If you're doing very complicated or somewhat complicated to very complicated manipulations, it's probably best to leave the units out. And in fact, in most of the things that I'm going to ask you to do this quarter, you probably shouldn't include units. Although, in the next homework, I will ask you to explicitly include units. The reason is because as we'll see here, they're like excess baggage that gets carried around as you're doing manipulations. And if you're not really careful about keeping them consistent and properly formatted, they could actually screw up something that shouldn't be very easy to screw up, all right? If you want to use units, and in general, of course, units are extremely important when you make calculations, my suggestion is that you do them at the end of your calculation. You figure out, you know, what's the units in the final answer. But don't necessarily carry them around with you during the whole thing, okay? All right, so hopefully that'll become more obvious as time goes on. But in any case, I'm going to show you two different ways to include units in your manipulations, all right? The first one I'll refer to as symbolic units, okay? So symbolic units are ones that you define yourself. And then if you include them in your calculations, they'll be carried around as if they were unassigned variables. Okay, so let's do a simple example to see how it works. All right, so I'm going to define a quantity of variable, distance, and set it equal to 10. And then I'm going to put a space and put an M after it, okay? So this is an example of a symbolic unit. I've decided that I'm going to use the letter M to stand for meters, okay? Now, the next thing I'm going to do, let's put a little semicolon there, is I'm going to define time equals to space seconds, okay? So this is another symbolic unit. I've just put the S in there. And I know that to me, that means seconds. And now I'm going to calculate a speed, all right? So speed equals distance divided by time. And if I enter that, you'll see that it gives me the answer 5 meters per second, all right? So Mathematica just, you know, did this division and the M and the S ended up in the right place as they should because all I did was divide 10 M by 2S so I get 5 times M over S. So this is symbolic units. Mathematica does not necessarily know, in fact, doesn't know what M and S mean except that they're just symbols that get included and carried around in the expression, all right? Let's do another example. So I'm going to define C, the speed of light equals 2.998 space 10 to the minus, or 10 to the 8 space meters per second, okay? So I've defined the speed of light in meters per second, all right? Now I'm going to define a wavelength. Lambda equals 1.0 space 10 to the minus 6 meters, okay? So it's like an infrared photon, all right? And now I'm going to calculate the frequency of that photon. New equals C over lambda. Enter. Actually, I have to spell it right. B. And sure enough, I get 2.998 times 10 to the 14 inverse seconds, or hertz, okay? So here the M's canceled and they didn't show up. Again, it's just symbolic units. But they get properly handled when I do these manipulations. All right, let's do one more. Actually, we'll do a couple more. All right, now I'm going to define Planck's constant. H equals 6.626 space 10 to the minus 34. Does anybody remember what the units are? Joules times, so space second, all right? And now I can define the energy of the photon. A la Planck, E equals H times nu. Enter. And so I get an energy in J, which I've used to symbolize joules. All right, let's do an ideal gas calculation. And we'll do it in the common units. So I'm going to define the number of moles. N equals 1.00 space mole, semicolon. And the gas constant R equals 0.08206. And this is, I'm going to use parentheses to keep things properly together. Leaders space atmospheres, parentheses divided by kelvin space mole, okay, semicolon. The temperature T equals 273 space kelvin. And the volume equals 1.00 space liters. All right, now I'm going to calculate the pressure. P equals N times R times T divided by V. It's ideal gas law. And so what I get is an answer in atmospheres. All right, so there you have it, symbolic units. Now, I'm going to show you one little thing that, you know, obviously this can be kind of nice, but sometimes you get funny results and you do have to remember sometimes how to interpret the units. So let's do one where you get a funny result and then we'll convince ourself that it's actually correct. Okay, so now I'm going to calculate the average speed of a gas molecule using a formula that you learned in general chemistry, okay? So I'm going to do this in SI units. So I'm going to redefine R. R is going to equal 8.314 space and then it's joules per parentheses, K space mole, okay? I'm going to define the temperature equals 300 kelvin. I'm going to define the mass equals 0.02802 kilograms per mole. So this is nitrogen, N2. And now I'm going to define my average speed which is U average equals parentheses, parentheses 8 times R times T parentheses divided by pi times M, parentheses, parentheses. And then I'm going to raise the whole thing to the one half power. This is the kinetic theory expression for the average speed of a gas molecule in an ideal gas. Okay, now what should the units be in SI units for a speed? Meters per second. So let's see what we get. Well, the number looks reasonable, right? I told you last time and you probably already knew this from general chemistry, few hundred meters per second is a typical air molecule at room temperature. So you're getting bombarded in the head at 476, well that's the average speed of the N2 molecules hitting you in the head right now. Good thing they're light. Anyway, so what do you think of the units? The square root of joules per kilogram. Is that right? Well, let's see if we can figure that out. So what's a joule? Kilograms, meters, squared. Over second squared, all right? So then a joule per kilogram is equal to meters squared per second squared and the square root of that is equal to meters per second. So it's correct. But this shows you one of the things that you have to keep in mind when you're working with symbolic units. See, Mathematica doesn't know that the joule we've defined which is just the letter J is actually equal to kilograms meters squared per second squared, okay? All right, so there's a little intro to symbolic units. Any questions on that? Okay, well now I'm going to show you another kind of units. These are units that Mathematica actually knows what they mean, okay? And this is another thing that you have to load in via a package, okay? And the package has the very nonintuitive name of units, okay? So let's go ahead and load that in. So we say less than, less than. It's capital U, N-I-T-S. And then the backwards single quote, upper left-hand corner of your keyboard. Enter. We can do dollar packages to see if we got it. And we see that there it is. Okay, now I'm going to show you how you can actually find out what's in a package, all right? There's a command called names with capital N, bracket. And then what you do is you put the name of the package in there, so in quotes. So this is units, left single quote. And then we want to see everything that's in there, so that's, we put an asterisk here. And then double quotes, square bracket. In general, if you do this and put a package name here, you'll find out everything that's in that package. It'll be a list of everything in the package. So if we enter that, you get this long list. And these are all the units that are defined in Mathematica. And some of them look familiar, like here's a week. And here's a tablespoon. And maybe some more chemistry ones. Here's a kilogram. Okay, but some of them are kind of weird. Like, look at this one, a butt. What's a butt? Well, we can find out. So how do you find out? Question mark. And then put in the name. But a butt is a unit of volume. Yes, we know, there's big butts, there's little butts. Let's see how to find. You can click on this thing and it gives you more information. Butt is a unit of volume. See also, hog's head. We'll check that one in a minute. But let's have a look here. All right, so it turns out a butt is 126 gallons. See, you learn something new every day. I'm curious about hog's head. Let's check that one out. Also a unit of volume. And that's one half of a butt, so it's like one cheek. All right, let's go back to the list here. How about a newton? See what a newton is. We should know what a newton is, but let's just make sure we know what it is. Newton is the SI unit of force. And we see here, it's kilogram meter per second squared. Okay. Now, what can you do with these units? Well, for one thing, you can actually convert between them. That's kind of a useful thing to be able to do from time to time. So for example, suppose we want to convert between atmospheres and Pascal's. We want to know what's the conversion. Okay, so we have, first of all, you have to make sure that you know how it's spelled because if you don't spell it exactly as Mathematica lists it here, it won't know what it is. All right, so we go up here and we see atmosphere has a capital A. And then we go down here and we see Pascal has a capital P. Okay? So here's how we use the convert command. So we say convert, bracket, and then we say what thing we want to convert, so I want to convert one atmosphere. And then I put a comma and say what I want to convert to. So P-A-S-C-A-L, Pascal. And if I enter that, I see that it's 101,325 Pascal's, which is something that you, that may sound familiar to you from when you studied gases in GCAM. Okay? Let's do another one. Anybody in here ever run a 10K race? Okay. Do you know how many miles it is? Oh, we need more significant figures. Well, let's figure it out. All right, so let's convert 10 and we have to spell it right and that means capital K I-L-O and then capital M E-T-E-R. Wait, is that right? Better check this. Kilo. Oh, yeah, there should be a space because look, we don't have kilometer here, right? We have kilo and meter, all right? So a good thing I checked. So I have to put a space in here and then I want to convert that to mile, all right? So we let it rip and lo and behold, there's an exact conversion and if we want to know that to a few decimal places, we can do N bracket percent and we find out that it's more than 6.2 miles, not much, but a little bit. Okay. Let's go up here and I'm very curious about this guy here. How many miles per hour is that nitrogen molecule moving on average in this room right now? Let's convert that number 476 meters per second to miles per hour, 474 meter per second, comma, mile per hour, N percent, over 1,000 miles an hour, pretty impressive. Okay, so this shows you a couple of examples of how you can use the predefined units and these actually mean something. They're not just symbols, all right? Obviously, we can convert between them. All right. Now, there's one other type of conversion that I want to mention to you and this one is a little bit idiosyncratic and that's the temperature conversions, all right? And the reason that this one is a little bit more complicated is because the different temperature scales have different reference points, all right? So Kelvin only goes as low as zero, whereas Fahrenheit and Celsius can be negative, okay? So there's not a common connection between them. So there's a special command for converting temperatures. It's called convert temperature, okay? And what you do is you say the number. So let's suppose we want to, let's suppose this room is 72 Fahrenheit and we want to know how many Celsius is that. So we say 72 and then we put in the units of that number and then we put in the name of the unit that we want to convert to which is in this case Celsius and then we enter and then so it's 200 over 9 so we can end percent and we see that 72 degrees Fahrenheit is 22.2 Celsius. All right? Let's do one more, convert, temperature, bracket. This time we're going to convert zero Celsius to Kelvin. What should the answer be? 273.15, okay? So there you have it, units conversions. All right, now there's one other thing that I want to tell you that's related and this is the set of physical constants. So we have Planck's constant, Boltzmann's constant, the gas constant and there are various constants that are commonly used in chemistry and physics and there is a package that includes those also and believe it or not it has the name physical constants. Okay, so if we want to load that package we say less than, less than physical, capital C, left single quote, enter, all right? Now we can see what's in it, names, bracket, double quote, physical constants, left single quote, star double quote, bracket. All right, so there you have it. So there are ones that make sense like acceleration due to gravity, that's the G constant, the age of universe, Avogadro's constant, Boltzmann constant, lots of familiar things in here, okay? All right, so let's have a look at a couple of those. I'll type in Avogadro constant, enter. Looks familiar doesn't it? How about the molar gas constant? That's our gas constant in SI units. How about the Faraday constant? Which you've learned about in electrochemistry, 96,485 coulombs per mole of electrons and one more speed of light, lots of precision in this one, okay? All right, so that's how you can refer to and if you ever want to look them up while you're in a mathematical session, you can have them at your fingertips here once you load the physical constants package. Okay, now let's see how we can use these things in calculations, okay? So I'm going to redo some of the calculations that we did previously with symbolic units, except this time we'll use the real units, all right? And we'll see that Mathematica does know how to convert these. All right, so let me define, actually Lambda is already defined but we want to define it differently now because we're not going to use a symbolic unit. We're going to use a real unit. So I'm going to say Lambda equals 1.0 space, 10 to the minus 6 and instead of putting a little M, I'm going to say big M meter, all right? Oh, yeah, I forgot the B, thank you, all right? Semi-colon and now I'm going to say the frequency nu is equal to not C but I'm going to use the one defined in the physical constants package, speed of light divided by Lambda, okay? And if I enter, I get the same number that we got before except now I have a real meaningful unit here, 1 over second or it hurts, okay? Now if I want to calculate the energy, I can say E equals Planck constant times nu and I get the same number as I got before but now instead of a J, a symbolic unit, I actually have the meaningful joule, all right? So there's some simple examples of using the units and physical constants as defined by Mathematica. Any questions on that? Now keep in mind my little warning to you, you don't necessarily always want to use units. In fact, most of the time I would recommend you don't use them and you only put them in at the end when you need them, if you need them, okay? You can try but sometimes bad things happen and you can trace it to the units, not getting properly handled through complicated calculations. All right, so what else are we going to do? The next thing we're going to do is I'm going to show you something that most, I know most students love to use and again I'm going to issue a caveat and that is if you use this, you may find that troubleshooting is more difficult than if you do at the old school way like I do and type things in explicitly. So what I'm going to show you now is how to actually format your input so that it looks nice, looks a lot more say like what you might see in the book or on the homework sheet, okay? And this is using what we call a palette, the math assistant palette and basic palette, okay? So let's go up here and have a look at this palette, all right? So notice under the palettes menu, there's three things up at the top, math assistant, classroom assistant, writing assistant, okay? So these, let's have a quick look here. Just pull that one up and we can scroll down, I think. Oh, I'm sorry, there's nothing to scroll. So there's this thing that comes up first and then there's additional things that you can get to by unlocking these additional palettes. And so as you can see, there's lots of little things that you can mouse or click on that will allow you to format your input, okay? So I want to show you a couple of examples how to use this and another thing that I'll point out to you is that if you hold the mouse over one of these buttons, so for example, pie here, there's keyboard shortcuts, right? So if you push escape, P escape, you'll get a pie. Some people really like to use these things. Okay, well anyway, let's see how to use them. So let's calculate the square root of 2. So to do that, I type that and notice I get a square root sign and then a little box where I can put my argument. So I type 2 and enter and I get the unremarkable answer, square root of 2 and I could say N percent and see that in fact it's the familiar square root of 2, okay? How about a cube root? Here I have two boxes, so I put the argument and then if I hit tab, it takes me to the other box and now I can put 3, so I can get the cube root and if I enter, I get 3, which is the cube root of 27, okay? Suppose I want to define an angle and I want to use the usual symbol, which is theta, I can go down here, click on this little guy here and now I get a little keyboard that has Greek letters and things in it, so I can choose theta and now I can define it as 2 times pi. Now for pi, I can go up here to the mathematical constants and this is important to do especially for things like E and I because those are special. Remember normally we would use capital letters for them, so you need to make sure that you're actually really getting the mathematical constant. So I click on the pi and semicolon and now I can ask for the cosine of theta and I get 1, okay? So what's the point of using these palettes while you can make your inputs look a lot more like the way they look in books and things like that? Okay, so now what we're going to do is we're actually going to format a function. We're going to define a function and we're going to use the palette to make it look pretty and then we'll just plot it, okay? And the function that I'm going to plot, I'll write it on the board, this is going to be the equation that defines the radial part of the hydrogen 1s orbital, okay? So you learned in G chem that the orbitals are the solutions of the Schrodinger equation for, in this case, the hydrogen atom, so an electron moving in the field of a positively charged nucleus and you're used to seeing the pictures of these things and we'll learn actually how to make those in about a week or so. And you can talk about both the radial part, in other words, how does the orbital vary as you, as a function of distance from the nucleus as well as the angular part? That's the, you know, the lobes in the orbitals that have greater than zero angular momentum, L greater than zero, okay? Anyway, the equation for the wave function of hydrogen 1s orbital looks like this, psi of r, r is the distance of the electron from the nucleus, is equal to 1 divided by pi times a constant, which is known as the Bohr radius, a zero, cubed, all right? And that's square root and then its dependence on the distance r from the nucleus is e to the minus r divided by the Bohr radius, okay? So this is the hydrogen 1s radial part. So we're going to use the palette to make something that looks a lot like this. We'll define the function and then we'll plot it. Okay, so we go over here to our Greek characters. We find our lowercase psi and since we're defining a function, we have to still obey the rules of defining functions. So I use a square bracket and an r. What else do I have to do here? Underscore, bracket, and then what's next? Colon equals, okay? All right, now, now I can do some fancy type setting. All right, so I go to this guy and I have this parentheses thing here, okay? And then within that parentheses, I want to put a fraction so I can go over here, all right? And in the numerator, I just put a 1 and then I hit tab, okay? And then in the denominator, I want to put pi and now I have to put a space or a star, an asterisk because remember, we have to still follow some rules and if I put a space in here, that will multiply, okay? Now I can type set my symbol. It's just going to be, you know, a variable by using the subscript character here, okay? So I can say a tab zero and now what I want to do is raise that whole guy to the power 3, okay? And now I want to raise this whole guy to the power a half, okay? All right. And now I have to put a space and then I can go up here and get my Mathematica E or I could have typed capital E, okay? Notice it's the correct one because it has this little line through it and I can make that a superscript and now I say minus r and then divided by a tab zero and now I can put a semicolon there, whoops, not there. You have to get out of the whole thing, see? Put a semicolon, all right. Now I want to plot this. If I want to plot it, what do I need to specify? Well, I'm going to have to specify in the plot command a range of r but if I try to plot this, it won't work because I need to actually say what a zero is, okay? So I'm going to type in a value for a zero. So I come over here and I say a tab zero. Equals, whoops, not in subscript mode, equals and it turns out that that number is 0.0529 and I can make a little comment to myself that this is the Bohr radius in nanometers, okay? All right and now finally let's go ahead and plot it. And we have to refer to the function by its proper name so we have to go get the psi bracket r comma and then I want to plot this between r equals zero and four times the Bohr radius. So I'll say r comma zero comma four times and I go back over here and type in a zero. Oops, wrong bracket, okay? All right, now if we did everything right, we should get a plot and hopefully you can recognize from the equation that it's just going to be an exponential decay as a function of r and we didn't get anything. All right, hmm, well, what do you suppose is wrong? Did anybody get anything? So what did I do wrong then? Huh? You don't have the asterisk here? I think it should, that's not probably not the problem. Hmm? It's probably something in the way my equation is formatted here, isn't it? Oh, you know what? So I can tell you what I did wrong. I didn't enter this cell. My psi is not defined, okay? Now let's try it. Ta-da. See? I accidentally clicked out of that cell and never entered it so my function was not actually defined. And so whenever you try to plot something and it doesn't come up like that, there's a couple of things to look at immediately. One is, did you enter the definition of the function? And then after that, well, you have to troubleshoot your function if you make sure you've formatted it or typed it incorrectly, okay? All right, so that looks kind of like what we expected, no? All right, well, let's make this plot look a little nicer. So suppose we want to put labels on our axes. What should we put? Axes, label, arrow, curly. I'm going to say that the x-axis is r in nanometer and the y-axis is just simply psi, which does not have units. So we go down to type setting and we go down to psi. Double quote, curly. And I want to put a title on my plot. So what should I type here? Plot label, arrow. Curly and then type in my title. So radial part of the hydrogen 1s orbital. Oops, double quotes. Curly. Okay. Oh, right, we don't need the curly brackets for plot label. Okay, so now you see we have a nice handsome plot. Very informative. What if, okay, so there's another quantity that you might remember from GCAM. There's a quantity called the radial distribution function or radial probability. And that's proportional to r squared times psi squared in general, psi is complex. So you normally put an absolute value. Why don't we plot that? Because that's the thing that's meaningful to tell us where's the electron. The wave function doesn't have a direct physical meaning, it's the probability that does. All right, so we can do that pretty easily here by just saying r squared times parentheses, parentheses squared and change the title. Oops. Aha, I didn't put a squared in here. Okay. And that you may, that may look familiar to you from your GCAM textbooks also. Okay. What does this tell us? Tells us we do not find the electron at the nucleus. And the most probable place to find it is here. That happens to be the definition of the Bohr radius. 0.0529177 nanometers. Okay. All right. So anyway, the main point of this little exercise was to show you how to use this palette to make your formulas look really nice. Now, the main warning that I already gave you and that I'll just, I'll give it to you again is that, you know, this looks right, doesn't it? But you have to be careful because it's a lot harder to troubleshoot complicated expressions that have been formatted. Okay. I can tell you that from experience. So suppose, for example, I didn't put a space in here. Okay. If I enter that and then try to plot it, I get nothing. Now, it's probably obvious what I did wrong because you just saw me remove the space. But in general, if you have a very complicated thing, you may stare at it for a while before you actually see that. One way to sort of get around that potential problem is you could just use the asterisk. It doesn't look quite as nice, but then you definitely know that you're multiplying. And that obviously should work. All right. Okay. Now, one more little thing. So as time goes on, you know, you'll be, well, you already did it in your first homework, but you'll be defining lots of equations and functions and you'll be plugging numbers into them. And sometimes you'll want to use them over and over. And so now I want to show you a nice little thing that you can do so as to maintain the integrity of an equation and be able to use it over and over with different values for the numbers, the parameters that are in the equation. Okay. So I want to illustrate this, the idea behind this, which is, it's called a replacement rule, with a simple example. All right. So I'm going to start just by clearing some things that we've used previously so I can start fresh and new. I'm going to say clear, E, nu, and H. We used those previously. All right. And now I'm going to redefine E equals H times nu. Okay. So I just have a simple equation there defining the variable E as being H times nu. And right now H and nu are just symbols. They don't have any values associated with them. Okay. Now I can put in a value for H, 6.626 space 10 to the minus 34. And I can ask for E again. And now I have what I expect. E is now, because I put in a value for H, it's equal to that value times the symbol nu. Okay. Now if I want to plug a number in, for nu, so for example, 3 space 10 to the minus 14 hertz and get E, notice that E is just a value now. Actually I meant to put in 10 to the 14 because 10 to the minus 14 is not a very reasonable frequency. In any case, you see that E is no longer an expression. It's a number. But what if I wanted to, you know, reuse the expression for E multiple times without converting it into a number every time? Well, this is the idea behind what's called a replacement rule. Okay. So I'm going to go back and clear E and nu, start fresh and define E equals H times nu. Okay. So we're back to where we were. A couple of steps ago. And now I want to plug in a value for nu and get a value for E, but do it in such a way that I don't ruin this expression. Okay. So the way that works is I say evaluate E and then there's this little sequence of characters slash dot. And then I say nu arrow and then I put in a value. So for example, this one here, control V, enter. And notice I get the same numerical result as I did here, but if I look at E, E is still defined in terms of nu as a variable. All right. So what's the interpretation of this? This construction slash dot variable arrow value, that's what's known as a replacement rule. What it means is evaluate E but replace the symbol nu with this value. Okay. And replacement rules are very, very useful in Mathematica and we will be using them a lot this quarter. So everybody understand it? It's kind of weird looking, but it's always the same. Variable or whatever, expression slash dot variable arrow value. It's always the same. Any questions on that? You see why it's useful? Now I can put in a different value of nu. So I could say E slash dot arrow and then I could say nu, I'm sorry I put the arrow in the wrong place, E slash dot nu arrow, I can put in some other number like 5 times 10 to the 15. And now I see as expected I get a different value for E but I maintain the integrity of my expression. So let me show you another useful thing you can do with the replacement rule. So what I'm going to do now is I'm going to make a plot of the ideal gas law for a given volume, given number of moles but at three different temperatures. So I can see how the pressure versus volume curve changes with temperature. All right. So let's go ahead and clear PV and T and I'm going to define R, the gas constant in terms of the common units, 0.08206, so that's in liter atmospheres per mole Kelvin. And now I'm going to define a function, pressure as a function of volume underscore colon equals N times R times T divided by V. Okay. Now what I want to do is I want to plot this guy as a function of volume at three different temperatures. So tell me, let's see if you guys can help me to figure out what the plot command should look like. And I'm going to use replacement rules to put in the temperatures. I want to plot pressure as a function of volume at three different temperatures on the same plot. Yeah. Yep, exactly, exactly. So what he said is I should say plot P of V slash dot V, I mean T arrow some value, comma P of V slash dot arrow T, I mean T arrow another value, et cetera. Okay. So that's kind of a nice thing, right? So let's go ahead and do that then. So we'll say plot and I need, since I'm making a list, I need a curly brace. So I'm going to say P of V slash dot T arrow. And so the first one I'm going to do at 100 Kelvin, okay. And then P of V slash dot T arrow 200 Kelvin and then P of V slash dot T arrow 300. Okay. My curly brace. And then I need to specify the range of volume. So I'm going to say do that for V goes from zero to 100 liters, all right? Something happened, something bad, it didn't work. What do you suppose it is? My function's N times R times T over V. I've specified T in the, using the replacement rules. V is the plotting variable so that gets values. I've actually defined R but I never defined N. So N is zero or it's a symbol here and the plot doesn't make sense. So let's go up here and put in a value for N. N equals 1. One mole and now it works. So which curve is which? Hmm? Yeah, blues is the first one. But does that make sense? So let's consider a given volume, 20 liters. What happens to the pressure as I increase temperature at a specified volume, at a given volume? It goes up. So we know then that this should be the lowest temperature, intermediate temperature and highest temperature. What else could we do? We could put a legend. Let's do it. How do we put legends? Let's go up here before we actually use the legend command we have to define. So we say less than, less than, plot, legends, backward single quote and now down here what was the command? Let's, so we don't get freaked out by the red. Let's go ahead and put this in a different cell above there. Make sure we got it loaded in. Okay. Now it turns black because we've got the legends package loaded in. All right. So now I have a curly. I'll say T equals 100 K for the first curve. T equals 200 K for the second curve. T equals 300 K for the third curve. Curly. And there you have it. And as we've seen previously, what we really should do is move that guy to a more sensible position. But in any case, there you have it. The main point of this little exercise was to show you another application of the replacement rules. As I said, we're going to use them a lot so get used to that notation. Okay. Any questions on the use of replacement rules? Yes. The first label, let's say only 200 and 300, we put like, how do we define the second one that we're only using? I don't know. Let's try this. Oops. I need a comment there. Oh, I need a quote here. I got a little too carried away with my backspacing. All right. Well, it looks like it's still going to put something there. Well, first of all, I'm not quite sure why you would ever want to do that. If you did really insist on wanting to do that, you could always make a custom legend yourself using, there's a bunch of graphics directives. You can make it by hand. Okay. Well, without seeing what you did, I guess I can't help you. But if you want, we can talk about it later. There is a way that you could do that, actually. We're going to learn shortly, soon, how to plot multiple plots in the same frame. Okay. And in that case, you could create one plot with two of these curves and legend. And then you create the second plot with the third curve and then just display them in the same plot. Again, I'm not quite sure why you'd really want to do that, but it is possible. Any other questions? Alrighty. So, our next subject has to do with lists and tables, which can also be thought of as vectors and matrices. And we'll learn how to manipulate them mathematically using vector and matrix operations later in the quarter. But for right now, I want to introduce them to you as what we might call data structures. So, convenient objects for storing data. Alright? So, for example, if you make a series of measurements, you may be making a series of measurements as a function of time. So, maybe you're measuring something like the concentration of a product in a chemical reaction as a function of time. So, what you would do is write in your lab notebook time zero, concentration one, time 10 seconds, concentration 1.6, et cetera. So, what these are, these are lists of numbers, okay? And the combination of those two lists, concentration versus time, you can think of as a table of numbers which has two columns and whatever number of rows, how many ever time points you recorded, okay? So, these are very nice things to be able to work with and I want to show you now how to define them and manipulate them using commands in Mathematica. Alright? So, the way you define a list is similar to the way you define a variable. You start out with a name. So, I'm going to say letters equals. And then a list in Mathematica is defined by something enclosed in curly brackets with commas separating the elements. Curly bracket and I can say A, B, C, D, E. Whoops, E. Okay? And then if I close my curly bracket, that's the end of the list and then I can enter it. Oh, that's interesting. Notice I've got values for C and E. So, what do I need to do if I want to get rid of those values? Clear? C and E. And now I'm back to just a pure list of letters. Okay? I could define integers. One, two, three. Okay? Just regurgitates it. But this actually means something. Mathematica knows what this means. Okay? It's keeping track of this list and it refers to it in the same way that we defined it. Okay? How about reels equals? Whatever you want, 61.3, 76.5, 88.1. Enter. Okay? So the point of this is lists can be of whatever you want. It can be objects like plots. It could be letters. It could be names. It could be numbers, integers. It could be complex numbers. It could be real numbers. Okay? It's just a list of something. Alright. Now, there's many ways in which we can actually manipulate lists. We can also automatically create them. Okay? And one of the ways to automatically create a list is to use a command called table. This is a quite useful command. And so what I'm going to do is show you how to use that by I'm going to create a list of the squares of the first 10 integers, but I'm not going to do it by actually calculating them in my head and then typing them in. I'm actually going to do them automatically using the table command. So here's how this works. So I'm going to say squares equals and then capital T table. Okay? And the way table works is you put in an expression that you want to have evaluated and then you put a list of the objects on which you want that evaluation to take place. Okay? So for example, if I want to square some number, I could put in a dummy variable. So let's just say I and square it. Okay? And then I just need to define what's the range of I. So I could say I, for example, goes from 1 to 10. Okay? So what this is going to do is it's going to create, in this case, a list because it's only got one dimension where for each value of I in this range here, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, it's going to square it and give that to me in the list called squares. All right? So if you enter that, you see that you get that. 1 times 1 is 1, 2 times 2 is 4, 3 times 3 is 9, et cetera, et cetera, but that's kind of cute, right? You've generated that easily. You can make it longer if you want just by changing that. Okay? All right. What if I wanted to do the same thing but in reverse order? Well, what I can do is say now I is going to go from 10 to 1. Now let's try that and see what happens. It doesn't work. Why doesn't it work? Because the mathematical looks at this and says, well, 1 is less than 10 so I don't need to evaluate this thing because I'm used to stepping 1 at a time in increasing order. Well, we can force it to go backwards by putting in, by actually defining the increment. So the increment is understood to be 1 unless otherwise noted. So if we put in here a minus 1, what that means is start with 10, i equals 10, and then subtract 1 from it, 9, subtract 1, 8, and go down until you reach 1. And if you do that, you see that you get the list of squares but now it's in the order from high to low. All right, so now let's suppose we want to define a list of reciprocals of odd numbers between 1 and 10. What should I do? All right, let's see. So I want to say table and then what should I put first? 1 over i. By the way, I could use x, I could use k, I could use my name to define the variable. It doesn't matter, but i is a convenient one. Okay, and then i, 1 to 10, but what if I only want the odd numbers? I put an increment of 2. So then it'll be 1, 3, 5, 7, 9, and then it doesn't do 10. Okay, so if I put in a 2 and there you have your reciprocals, 1, 1 over 3, 5, 7, 9. Okay, so you can see this table command is very versatile. Another thing you can do is you can tabulate values of functions. All right, so I could define f of x underscore colon equals 1 divided by x squared. And then I can ask for a table. I don't have to assign it to a variable if I don't want to. Of f of x, x ranging from 1 to 10. Whoops, I need a curly bracket. So like I say, I mean you can tabulate pretty much anything you want. Later on in the quarter we'll see a convenient application of tabulating graphs, actual plots and making a movie out of them. Okay, now I'll just show you a couple more commands. Once you have lists, there's lots of things you can do with them. One of the things that you can do is query their elements, find out information about them. So for example, if I want to know the number of elements in a list, in other words it's length, there's a command called length. So length of letters is 5, a, b, c, d, e. Length of squares is 10 because I made it from 1 to 10. What if I want to know the first element? First of letters is a. What if I want to know the last element? Last letters is e. What if I want to know the second? Is there a command second? No. But I can refer to a particular element using a certain format and the format is the following. So suppose I want to know the second element of letters. The way I do that is I say letters and then I give a double bracket and put in the number of the element that I want. Two. Oops. I have a capital here where I shouldn't have a capital. Sorry. And you see that the second element is b. And the third element is c. What if I want to create another list by using part of a list that I've already made? So for example, I want to make another list of letters but I only want to have a, b, and c in it. So I want the first three elements of letters. So I could say letters two equals, there's a command called take. And then I refer to the list and say how many of the elements I want to take. And you see now that letters two has been assigned to a, b, and c. What if I want the last three? I can say take letters and if I say minus three, that's an indication to start at the third from the last and give me the last three. So I get c, d, e. All right. So I think that's about it for today. So what we're going to do next time is we'll see a few other ways of manipulating lists and then we'll look at more than one dimension. So tables, essentially matrices. And then we will also start working on some curve fitting. Okay? So see you next time.