 Okay, well, we'll go ahead and get started. So last time, we learned how to do differentiation in Mathematica. So we considered derivatives of functions of one variable and then we also did partial derivatives, which is when you have more than one variable. And then toward the end, we did a couple of examples where some derivatives appear in physical chemistry and we evaluated them using Mathematica. I'm going to finish up with one more example, chemistry-related example today and then we'll start talking about how to do integration in Mathematica. So the example I want to use here has to do with the force between two atoms and so I'm going to suppose that I have two atoms here and they could be like noble gas atoms and I'm going to define the distance between their centers as r and if you actually take two rare gas atoms separated at infinity, they don't interact. They have no forces between them, okay? They're too far apart and as you may recall from general chemistry when you were learning about intermolecular forces, interatomic forces, when you start to get the atoms somewhat close to each other, they interact through the induced dipole-induced dipole interaction or also known as induction or also known as London. I'm not induction, dispersion forces or London forces and those are attractive and so if I draw the energy relative to the infinitely separated atoms then as the atoms start to get closer and closer together, there's the energy decreases and then at some point I start to push the atoms on top of each other and they don't like that so the energy increases very rapidly, okay? And so this is the energy as a function of distance between two atoms. All right, now if I want to know what the force is, if I know the potential energy, you may recall from physics, you can get the force by taking the derivative of the potential energy, okay? So if I want to calculate the force here then it's going to be f of r is equal to minus du of r by dr. Okay, so that'll be the force along the radial direction but the separation vector between the two atoms, the magnitude. Okay, so what we're going to do then is we're going to take a model for this shape, potential, it's a commonly used model and then we'll take its derivative and we'll plot both the energy and the force on the same plot and one of the reasons I like to do this example is because it's going to show us that there's, Mathematica has a little quirky thing that you should be aware of so this will be an example of that. Now the potential energy function that we're going to use here is what's called the Leonard Jones potential and according to that potential the energy is given by four times the parameter called epsilon and then there's two terms. One is sigma divided by r to the 12th power and the other is sigma divided by r to the 6th power. So it's the minus sigma over r to the 6th term that gives rise to the attractive part and then the repulsive part is sigma over r to the 12th. And what are these parameters mean? Well, if you take the derivative of this and set it equal to zero, you find out that the value of the energy at the minimum is equal to minus epsilon. So that's what epsilon is. It's the depth of the well when the atoms are sort of at their optimal contact and if you set this equal to zero you find out that the point at which the potential is equal to zero that's when r is equal to sigma. So sigma is a measure of the atomic size. Okay. All right. Well, for us here in Chem 5 it'll be a function that we will put into Mathematica. We'll take the derivative and then we'll plot them on the same plot. Okay. So that's what we'll do now. All right. So then I will start with defining the potential. So u of r underscore colon equals and then I have 4 times epsilon and then times parentheses and then parentheses sigma over r oops r to the power 12 and I should spell this correctly and then minus sigma over r to the power 6 parentheses. Okay. Now the next thing I'm going to do is define f of r underscore so I'm going to make it a function colon equals and then I'm going to say minus the derivative d of u of r with respect to r. So that's going to be the force. All right. And now I'm going to specify epsilon. This is going to be equal to 0.929 and this is the value that is meant to represent argon atoms and the units are kilojoules per mole and then sigma the size parameter is going to be 0.362 and this is in nanometers. All right. Now what I want to try to do is plot both of those functions the energy and the force so we can kind of see how they're related to one another. Okay. So we're going to plot u of r and f of r and I want to do this for r is going to go from 0.1 times sigma to 3 times sigma. Okay. And I want to specify the y plotting range so plot range arrow, curly bracket. I'm going to have it go from minus 8 times epsilon to 8 times epsilon. Okay. And I think that should do it. Okay. So if we enter this we get something that doesn't look very promising. Okay. Now we did get a plot. We got one curve and can we figure out which one it is? Well this, if it's the energy the energy should be 0 when r equals sigma. Okay. And sigma is 0.362 and that looks like about 0.362. So this is the energy and we got a bunch of complaints over here that are pretty hard to understand but one thing we know for sure is that the force did not get plotted. Okay. So this is a case that you may encounter from time to time. Interesting. Maybe we should go see what they're doing over there. So what's going on here see is when we use a plot command like this f, the derivative that's in f is only being evaluated, the derivative f is only being evaluated when needed which means in the plot command. Now the derivative is being taken, the derivative of u is being taken but see when u is in the plot command numbers are being plugged in. So it's being converted from a formula into a bunch of numbers and then when we ask for the derivative of that it's not defined, it's not a proper function anymore. So it's kind of a weird idiosyncrasy about the order in which things are done or when they're done. Okay. And there's several ways to get around that and so I'll show you three ways and these are useful not just in the context of this particular example but they're ways of finessing Mathematica to do exactly what you want in cases where it doesn't do what you want. Okay. So one of the ways to fix this problem is to use a different kind of equals here. Now in general we use this colon equals to define functions and the colon equals is literally interpreted as a delayed assignment meaning use it when you need it basically. And if you actually change that colon equals to just an equals what it will do is it will take the derivative immediately and assign it to f of r. Okay. And so to see what the consequences of that are you can enter and now you get two curves. Okay. So very subtle little thing. Now let's have a look and see if this makes sense and then we'll try a couple of other ways of getting around this problem. All right. So this is the energy. Looks kind of like what I drew on the board there and here is the force. Does that make sense, this force? Well, let's think. We can certainly figure out what it should be at at least one of the points. So what should the derivative be at the minimum of the function? Should be zero at all extrema and you can see it looks like it's zero right there at the minimum. Right. So that looks good. So what else can we say? Okay. Well as we pass through the minimum notice that the slope of the curve starts to increase very rapidly correspondingly then the force which is the slope of that curve increases very rapidly. And the sign is correct also because the slope over here on this side of the minimum is negative. All right. Wait a minute. Sorry. At the slope on this, yeah, this is negative but we're plotting minus the slope so we have a number that's becoming more and more positive after we pass through the minimum and as soon as we pass through the minimum in that direction minus the slope goes negative. Okay. So it makes sense. All right. Now let's go ahead and put this back, the colon and now I'm going to show you another way in which you can get around this problem. So one way is to introduce a dummy variable and what I mean by that is we put a different variable in here, S and then we can use a replacement rule to set S equal to R. So that's another way to trick into getting the proper derivative. All right. So if you enter that, you get the same thing. It works. Okay. All right. Now there's yet another way to force the derivative to be done properly and that is we can go back to what we started with. Okay. And what we can do is actually force the derivative to be done here properly by putting a wrapper around it called evaluate and actually try that. You'll see it won't work. Okay. However, you could say evaluate this derivative and that will work. Okay. So that one. Oops. Oh, I'm sorry. No, no, no, no. We want F of R here and we evaluate up above. Sorry for all the confusion. All right. So we put F here and get rid of that one and here we say evaluate. This is similar to just using the plain old equals instead of the colon equals. All right. So this forces the derivative to be done here before we actually use it in the plot command. All right. Well, that should work, but let's go ahead and put it in here. Oh, okay. Well, that's strange. In any case, so what's the point of all this aside from being very, very confusing probably? The point is that occasionally you run into these funny things having to do with the way, the order in which things are done when you enter them into Mathematica. And these three examples show you things that you may try if you ever run into this kind of problem. Okay? You can get around it. All right. Are there any questions on that? Okay. Well, then if they're not, then I'm going to move on to the next subject, which is integration. All right. So let's just remind ourselves something. Okay. So what we've done already is differentiation. So if we have a function y equals f of x, then we can define the derivative dy by dx equals f prime of x. Okay. And the next step we can do is we could say dy is equal to f prime of x dx. All right? So integration is essentially the way to undo the differentiation. It's like anti-differentiation. And essentially what it means is if you do this, then you should get y on the left side and then that's equal to the integral of the derivative. Okay? So the integral is essentially the anti-derivative. The Kidnick store liked that a lot. And for my next trick, wow. Okay. Well, that's actually fitting fun music because as you all know, from taking calculus, integration is fun. All right? Actually, what we're going to be reminded of here very shortly is I think most people would agree that once you know the rules, differentiation is easy. I mean, if a derivative exists and you don't have to do some strange limits or things like that, differentiation is straightforward. You would think that doing anti-differentiation should also be straightforward, but it's not. All right? So we'll see that. So that's sort of going to be the moral of the story. It's integration is hard. All right. Now, the good news is when an anti-derivative exists, Mathematica will find it. Mathematica knows how to integrate. Sometimes they don't exist. Well, let's start out with a simple one. Okay? The command is integrate. All right? And the way it works is you say what's the function you want to integrate, so I'm just going to put in x squared. And then you say the variable with respect, well, with which you want to do the integration. All right? So what should this be? What's the answer here? X cubed over 3. All right? Let's see. Sure enough, it is. Okay? Okay. What if we want to integrate a trigonometric function like cosine of x? What should we get? Oops. Did I hear a sign? Sign. Okay? So far, not very impressive, right? We can define a function and then put it in. So I can say f of x underscore colon equals 1 over x. Then I can say integrate f of x. X. Lots of entertainment today. All right? So we get the familiar log x. All right? So far, so good. But if you're not impressed, I'm with you on that one. Okay, let's see if any of you are real good at integration. What's the integral of the arc tangent of x? Anybody know that one? Anybody remember that one? Well, let's find out. Okay, so you see things start getting a little more complicated. Probably if I gave you a pencil and paper and said if you can't solve that integral, you'll flunk the class. You could have worked that one out, all right? But it's much easier to use Mathematica. How about another one? Let's do integrate. Oh, wait. No, I want to show you the pallet. Sorry. So you can use the pallet to do integrals also. All right? So notice down here we have this indefinite integral. So what we're doing here so far, I should have said we're doing indefinite integrals because we have not specified any limits of integration. And so all of these results are to be understood to have a constant of integration hooked on to the end. Okay? All right. So if you want to do an indefinite integral with Mathematica, you choose from the pallet here and then you just put in the function. So for example, e to the x times sine of some constant b times x. Anybody know that one? The x. All right. So that's it. Looks like it makes sense. Okay? So sometimes you get interesting results when you do integrals. Even for functions that look like they ought to have reasonably simple integrals, it's not so simple. So for example, here's a good one. If I say integrate cosine not of x but of x squared, anybody know that one? Does it look easy? I got something that looks strange. Square root of pi over 2 times Fresnel C of square root of 2 over pi x. What is that? Well, we can find out by saying question mark. Fresnel C. Enter. And we get the very informative answer. Fresnel C gives the Fresnel integral C of z. All right? Well, we can get more information. And we see that essentially Fresnel C is the integral that we seek. So that integral doesn't have a closed form, expression. It actually defines a mathematical function coefficient called the Fresnel coefficient. Okay? All right. So what's the point? Sometimes you get interesting results when you do integration. All right, here's another one. I'm going to do the palette again. So remember before we integrated arc tangent, let's try the square root of arc tangent. So square root arc tan of x. What does that mean? Couldn't do it. Square root of arc tangent doesn't have an anti-derivative. So a mathematical just spits it back at you. Integration is hard sometimes. All right. So there's a few examples of indefinite integrals. What if we want to do definite integrals? Well, it's more or less the same thing. We just have to specify the range over which we want to do the integration. All right? So let's start by doing an indefinite integral. So I'm going to do integrate. Oops. And this is going to be 1 minus x squared. Okay? With respect to x. All right? So we know how to do that one. But here you go. It's x minus x cubed over 3. All right. Now what if you want to instead evaluate a definite integral? So if I want to do the same integral, but I want to do it between x equals 0 and 3. Well, all I have to do is put the range in instead of just the variable. All right? And you get minus x, which for this one you could verify. Probably in your head is correct. All right? So that's the indefinite. Another indefinite. We can use the palette. I mean another definite integral. We can use the palette. We grab the definite integral here. Now we have some limits. So suppose I want to integrate sign between 0 and 2 pi. What should I get? That's a complete cycle. The first half cycle is positive. The second half cycle is the same, but it's negative so I should get 0. What if instead you wanted to do sign squared? You get pi. All right? Now, next thing I'm going to do is an example of an improper integral. What's an improper integral? Anyone? Improper integral is one for which one of the limits is infinity, one or more of the limits. All right? So let's do that. Let's do, let's integrate the Gaussian function from minus infinity to infinity. Oops. All right? So I'm going to put an infinity down at the bottom, minus infinity, and then plus infinity at the top here. And then I'm going to put in a sort of generic Gaussian function, so e carat minus a times x squared and then dx. All right? Let it rip. What does that mean? How do we interpret this thing? Well, when you get something like this, it means that there may be more than one answer depending on the properties of your parameters in your function. Okay? So what this is telling us is that if this constant a, if the real part of that constant, which in general, Mathematica is going to assume that anything like that could be complex, it says if the real part of that is greater than zero, then the answer is square root of pi over square root of a. All right? Now, if you know how to read this, that may be what you want. But maybe you want just a nice compact answer without all that stuff. And maybe you know that a is in fact real. Then it's helpful if you tell Mathematica, especially when you're doing integrals, that a is real and greater than zero. Okay? So how do we do that? Well, there's a couple of ways. So one is I can use the integrate command and put an option in. Okay? So I'm just going to pull this function out, put it here. And then my range is going to be x goes from minus infinity with a capital I to plus infinity. Okay? And now I can put in my list of assumptions. So I can say assumptions, arrow, nice. A is greater than zero. All right? And now I get a nice compact form, which is nice because you may want to actually use that in a subsequent calculation. You can use that if you set this equal to something. You can say integral equals integrate blah, blah, blah. And then later you might want to use integral in a subsequent calculation. If you did that and had the conditional expression, then you wouldn't be able to use it. Another way to do the same thing is if I mouse in the first part of this and put a bracket, there's a wrapper which is assuming and then you put in what you're assuming, A greater than zero, comma, do the integral and you get the same thing. Okay? So that's a couple of different ways to specify assumptions. And like I say, when you're doing integrals, even if they're fairly straightforward looking integrals, there may be a variety of results depending on whether or not the numbers that you would normally be assuming are real numbers or whatever have assigned to them, and you may get complicated results. All right. So I want to show you a couple other little idiosyncrasies about integration. So let's go back to a simple one. Let's just do 1 over x. Okay? And we know that's log of x. That's the indefinite integral. All right? So now let's do it for a definite case. All right? So I'm going to integrate that from 1 to infinity. Oops. So tab and then infinity, dx. All right. Try that and now you get an error. And why do we get this error? Well, the reason we get this error is because we know already that the indefinite integral is log of x, when we plug in log of infinity, we get infinity. So that is an example of a case of an integral that does not converge. All right? It doesn't give us a number. All right? So that's something to be aware of. All righty. One last little thing here about it is sometimes you see in books like in physics books, for example, you'll be integrating a function and you write down the integral in terms of say a dummy variable. Okay? So I want to illustrate that you can do that with Mathematica if you want. So I'm going to define some function. It's going to be f of t. Okay? It might be something that depends on time. And it's going to be a plus b times t plus c times t squared. And now I'm going to do an integral of this function between time goes from zero to some later time t. Okay? Because I want t to be in my answer. So how do I do that? Get my definite integral. Say zero is the lower limit. t is the upper limit. And now I introduce my function f but I put in a dummy variable. All right? So you do that then you get a nice expression that has t in the result where t might be equal to time, say. Okay? So that's something you can do. All right. Now, what happens, how can you get around a case like this one? All right? So remember when we tried to do the square root of the arc tangent of x, we didn't get a nice expression for that. Well, in those cases, you still may want a number for a definite integral. All right? You may really want to integrate that function between two limits. And if you do, you can perform what's called a numerical integration. Now, there's lots of different ways to do numerical integrals that have varying levels of sophistication and accuracy. But you all know how to do a numerical integral essentially. The idea is that you split up the function into a bunch of rectangles, right? And the integral is the area under the curve. So you just add up the areas of all the little rectangles that fall under your function. Okay? So that's the basis for numerical integration. Now, how do you actually do that in Mathematica? Well, the command is called n-integrate for numerical integration. Capital N, capital I. And then you put in your function. So let's go ahead and do that one. Square root of arc tangent of x, okay? And then you have to put in your limits, all right? So this is only good for definite integrals. So let's say we want it for x goes from zero to one. Okay? So you get a number. Now, is it right? Detrust that? Shall we check? Let's have a look at the function and see if we trust that answer. So I'm going to plot it. Square root arc tan of x, x goes from zero to one. And then I'm going to use filling, goes to arrow axis to shade the area under the curve for me so I can estimate visually what its value should be. Okay? All right. Now, so here's the function that we're integrating. And the value of our integral is this area. Does it look reasonable? Well, suppose I complete a rectangle by just drawing over to here. I can estimate the area of the whole rectangle. Which is what? Point nine times one. So that whole rectangle is point nine. That would be its area. Does this look like it's about 63% of that? It looks pretty close just by eyeballing it, wouldn't you say? No? Okay, thank you. All right. So sometimes it's useful to do stuff like this, right? To check, make sure your results are reasonable. All right. Any questions on the basics of integration? Using Mathematica. All right, so what I want to do now is, maybe for the rest of today, is to do some chemistry related examples. All right? So let me tell you what the first one is. Go over to the board. All right, so when you get to Chem 131C, I believe it is, you'll be studying thermodynamics. And one of the important quantities that you learn about in thermodynamics is called the work. And one important type of work, especially for illustrating thermodynamic concepts, is called PV work. So this is the work of associated with expanding or compressing a gas, say, in a cylinder, okay? And the way that's defined is DW, so some small amount of work is equal to minus the pressure on the piston times a small change in volume. Okay, so this is what's called mechanical work or PV work for an infinitesimal volume change. Now what if you want to calculate the work for a finite volume change? Actually, let's first ask if this makes sense. So do you remember in G Chem what the sign convention is for work? Do you remember? We would say that work is greater than zero if work is done on a system. Remember that? Remember their system and surroundings. If the work is greater than zero, our sign convention in chemistry is that that means work is done on the system. And conversely, less than zero means bye. And this formula, it's worthwhile to check or even to use this formula to remember this. So what happens when I suppose I have a gas in a cylinder here and I've got a piston and I push in the piston? Am I doing work on the gas? Yes. Now, is the volume increasing or decreasing when I push in the piston? It's decreasing. So compression of a gas corresponds to DV less than zero. Right? So that's negative. Negative times negative gives me a positive DW. Okay? So DW greater than zero. I did work on the system. And the other way around, if I expand the gas, the gas is doing work on the surroundings or work is being done by the gas, DV is greater than zero, pressure is positive, minus sign so that means DW is less than zero. Okay? All right. Now, if I want now to change the volume from some initial volume V1 to a final volume V2, and this is now, it's not an infinitesimal change but it's a finite change. Then how do I get the value of the work? I do an integral, right? So W now, the work over the finite interval will be equal to minus the integral from V1, V2, and I'll put in the fact that pressure depends on volume through an equation of state. So if I have some equation of state, for example, the ideal gas law, then I could calculate the work associated with changing the volume of the ideal gas. But that one's easy, so let's do a harder one. Let's do the Van der Waals gas. Does anybody remember the Van der Waals equation of state? Well, what you do is you start with the ideal gas law. What does the Van der Waals equation of state have in it that makes it more realistic than the ideal gas equation of state? Come on, you guys, help me out here, please. Okay, I'll remind you. First of all, it says gas molecules have a finite size. So the volume that appears in the equation of state needs to be reduced from the container volume because not all the volume is accessible to the gas molecules. Some of it's occupied by other gas molecules. So I have to reduce the available volume to account for the molecular volume. And the way that's done is by inducing you take parameter B which is meant to be the molar volume of the gas molecules, multiply that by the number of moles and subtract it from the volume. Then there's a second correction which acknowledges what we were talking about earlier that all atoms or molecules have some form of attractive force between them, at least dispersion interactions. And the influence of attractive interactions is to actually make the gas more cohesive so that it exerts less pressure on the container walls. And Van der Waals told us that we could put that in by introducing a parameter A. And then multiply by the square of the gas density. Where A now is a measure of the strength of the attractive forces. Does that look familiar? Sort of? Okay. Well, so what we're going to do now after this long-winded introduction is we're just going to work out this integral for this function. All right? And one of the reasons I choose this one is because it looks easy. In fact, probably if I gave you a pencil and a paper, you could work it out in very quickly. But let's go ahead and just do it in Mathematica because it illustrates some fun things that happen when you do integrals in Mathematica. All right. So I'm going to define the equation of state pressure as a function of volume, colon equals. And then I'm just going to type in Van der Waals equation. So N times R times T divided by V minus N times B. Okay? And then I need minus A times N over V squared. Hmm. Okay. So there's our Van der Waals equation of state. And now I can say work equals W equals integrate P of V and I want now V to go from V1 to V2. Now, what I'm seeking here is an expression for the work of compressing or expanding the Van der Waals gas and later if I want I can plug in numbers for AB, V1 and V2. All right? But let's see what happens. This looks like a fairly simple function, right? But let's see what happens when we enter that. So first of all it takes a while which is always a bad sign. And the reason I moved the screen up is because we're going to get a big hairball of information coming out which is another bad sign. Hmm. It's taken longer than I remembered. Okay. Well we're going to get something at some point here and I'll give you the reason why. We have lots of things in this expression that if you don't make if you don't tell Mathematica what your assumptions are they create all kind of scenarios for doing this integration depending on what those things are. And all of those scenarios are actually going to be presented to us when it gets done crunching. Oh come on. It's fairly impressive actually. Unfortunately it's taking much longer than I thought. Okay. So then what we're going to do afterwards is we're going to go ahead and put in some assumptions. There we go. Yes sir? Do you have a question? Oh yeah. Sorry about that. Yeah. I could put them, that's right because the work should be minus. Yeah. Thank you for pointing that out. We can put minus in there. We'll do that for next time. I mean the next time we try to do this. Here's the point though. We know certain things about those parameters. Mathematica does not. So it goes through and considers all kind of scenarios. Okay. So it says that the first one to consider was all of this stuff having to do with whether the imaginary part of V1 is greater than or equal to the imaginary part of V2 assuming that it's a complex number for example. And then there's another scenario. After that there's several scenarios that are considered. And obviously we're not interested in all these scenarios. We're interested in the scenario where we know that the number of moles is a positive number. And we know that R, the gas constant, is also a real positive number, et cetera, et cetera. Okay. So when you're doing integration, you need to tell Mathematica everything you know about the things that are appearing in the integrand. Okay. So let's try it. All right. So the way I'm going to do this is I'm going to make a list of assumptions. All right. So it's just going to be a list. It's going to be V1 is greater than zero. Right? Volume is always greater than zero. V2 is greater than zero. Number of moles is greater than zero. Temperature is greater than zero. R is greater than zero. A is greater than zero. Yeah, you could. We don't know whether we want to use common units or some other units. We'll save that for later. B is greater than zero. Then there's a couple of other things. All right? So these are things that you might not have thought would be important, but I can tell you they are. So notice we have V minus NB. Okay? We know that the container volume has to be at least the same size as the molecule. So in other words, V is greater than NB. If it's not, it changes the sign of that first term and that could presumably lead to complications. All right? So we can say that we know that V1 is greater than NB, N times B, and we also know that V2 is greater than N times B. All right? So let's try that. It never hurts to say everything you know about your parameters when you're doing integration in Mathematica. Okay? So that's that. Now I can say, assuming bracket assumptions and then I can mouse, well, I can also say W equals and then mouse all this stuff in here and put a closing bracket. Okay? Notice there's still one left. The integration should be done from a smaller volume to a larger volume. All right? So we could put that in here too if we wanted. And now you get an expression that looks like it makes sense, right? The first terms, well, let's go up, scroll up a little bit. So this first term is like 1 over V minus NB, so that should give us something that's got a log in it, all right? And this is 1 over V squared, so that gives us a term that has 1 over V's in it. All right? So now we have a nice clean expression that we could use to evaluate the work. So here it is. We get it by just doing W. All right? And if we wanted, we could plug numbers in with the replacement rules or whatever we wanted. Okay? So what's the point of this example? Well, it's to really emphasize the fact that if you want to get a useful expression by doing an integration in Mathematica, you should tell it everything you know about your parameters and variables. All right? Okay. Now, the next example, back to the board, it's hard not to be distracted by that. Okay. Now, those of you who are in Chem 131A know that when you solve the Schrodinger equation, what you normally do first is you figure out what's the functional form of the wave function, all right? And then you fix it up later by doing a process called normalization, okay? So for example, if we're doing the one-dimensional particle in a box, what you first did was you found out that the solution was of the form A where A is some constant to be determined, okay? And we've seen this function and we plotted the two-dimensional version, okay? This A is what's called a normalization constant, okay? And it's determined by making use of the fact that the square of the wave function integrated over the range of space accessible to the particle is the sum of all the probabilities of finding the particle and that that should be equal to 1, right? So Born tells us that psi sub n squared times, in this case, dx, so that's the probability density or the probability, probability density times volume. So this is the probability of finding the particle between x and x plus dx. And then if I just now add that up or in other words, integrate over the space available to the particle, then I should get 1. Does that look familiar to anybody? Okay, so for our present example then, that means that if we wanted to determine this constant A, we would need to evaluate an integral that looks like that, all right? So in other words, A is then going to be equal to the square root of 1 divided by that integral. So that's how we determine the normalization constant. Okay, so let's do that for this wave function using Mathematica. Okay. All right, so here's what we're going to do. I'll just call the wave function f, f of x underscore colon equals sine, well, define the function sine n pi x, pi, whoops, it should be little n times pi times x divided by l. Okay. All right. Now I'm going to say A equals square root 1 divided by integrate f of x and I want to go x from 0 to l, okay? And I need another bracket. All right, so let's try it. Does that look like what you got in Chem 131A? Mm-hmm. Why is that? You sure? What's it supposed to be? Uh-huh. But we know something about n, don't we? n is an integer. What's the cosine of an integer times pi? What's the cosine of pi? The point is here we didn't say anything about what n is but we know from the physics or from solving the Schrodinger equation the boundary conditions that n is an integer. So let's see if we get a different answer if we say n is an integer. All right, so I'm going to say assuming, oh, no, sorry, assumptions arrow. Now how do I say n is an integer? There's a nice way I can say that is n and now I go to this over here in the palette. There is somewhere here, isn't it here? Yeah, here. Okay. So this thing here, do you remember this one from when you learned about sets in whatever grade it is that you learned about sets is an element of? So this is a way to say n is an element of and then we say integers. All right, so let's try that. Oh, that one didn't work. Okay, let's try it using assuming which is what's in the notes. Actually we can put it in front of the integrate. Comma and then square bracket and then square bracket. No. Oh, I have to get rid of this assumptions here. Okay. All right, let's try that. What the heck? All right, what am I doing wrong? Oh, okay, so first of all I did something really stupid. Okay? I should have been all along integrating f squared. Okay? That's what we want. Okay, so now we get the right answer. Square root of 2 times the square root of 1 over L which is the square root of 2 over L. And let's see what would have happened if we would have gotten rid of this assuming thing. So I'll see you get the messier expression. And here because n is an integer, the sign of 2n pi is equal to 0 so you get square root of 1 over 2 L and then times 2, so that's equivalent. But only if you know what n is. All right? So another case where putting in some additional information about what you know about the actual parameters in your integrand helps you to get a more useful expression. Okay, so now I'm going to finish up by just giving you the background for the next example that we're going to do and then we'll actually do it in class. I want to tell you a little bit about calculating statistical quantities for using continuous probability distributions. And this is one example here. But we'll consider a more general case so we can do other examples. And this also comes up in physical chemistry and the examples that I'm going to do are from kinetic theory of gases which you'll do in probably in 131B or C. Okay? So the idea is that we're going to have a probability density which I'll call P of x. And if I multiply it by dx that's the probability that the variable is between x and x plus dx. Okay? And I'm going to assume that it's normalized so that if I integrate, in other words sum up all the probabilities over the whole range of the variable x, then I get 1. Okay? Now, the next thing I want to introduce you to is how it is that you actually calculate an average using such a continuous probability distribution. And those of you who are in 131A now know that the thing you call the expectation value in quantum mechanics is calculated this way. Okay? So if I want, for example, to calculate the average of a function of x and I use the angular brackets to denote the average, then what I would do is do the integral over all space of that function times the probability density times dx. Okay? So this can be any function of x. So for example, the mean value of x would be just the integral of x times P of x dx. And the quantity that we might call the RMS value, root mean squared, that's defined as the square root of the average of x squared. That would be x squared P of x dx, the integral of that, square root. Okay? So this is what we might call x RMS. Okay? So there's your little introduction to using continuous probability distributions. And what we'll do next time is we'll actually, we'll use, remember we did before the Maxwell-Boltzmann distribution, we plotted it and I reminded you what it was. F of u times du is the probability of finding gas molecule with a speed between u and u plus du. So what we'll do next time is we'll calculate expressions for the average speed and the RMS speed, which you learned about in GCAM. So we'll actually derive those expressions using the Maxwell-Boltzmann distribution and doing the appropriate integration. Okay? So we'll see you on Monday.