 So, we have a thermodynamic definition for the chemical potential, defining it in terms of, let's say, the Gibbs free energy, rate of change of the Gibbs free energy as I change the number of moles, the partial molar Gibbs free energy, or we could also think of it as the rate at which the Helmholtz free energy is changing as I change the number of moles, not at constant T and P, but at constant T and V, that should say, or equivalently in terms of the enthalpy or the internal energy. It's useful, though, to also have a definition of the chemical potential in terms of statistical mechanics, in terms of partition functions, as we've seen before for the various other forms of thermodynamic energies. Being able to write them down in terms of partition functions has led to a lot of interesting results. So, we can also write down a thermodynamic connection formula that tells us how to get the chemical potential from a partition function. The reason I've reminded us of this particular form of the chemical potential is because probably the easiest place to start is with the Helmholtz free energy, because the thermodynamic connection formula for the Helmholtz free energy has a particularly simple form, just minus kT times the log of a partition function. So, we just need to take the derivative of, all right, dA, dN, and I'm going to make a slight change here. Instead of taking the derivative with respect to the number of moles, I'm going to take the derivative with respect to the number of molecules of component I, because that's usually how we think of partition functions in terms of number of molecules rather than number of moles. So, all I've done when I made this change from moles to molecules is I'm going to be thinking about the chemical potential. Instead of a certain number of joules per mole, it's going to be a certain number of joules per individual molecule. So, since we know what a is equal to, I just need to be able to take the derivative of log Q with respect to the number of molecules. So, we need to remember now, what is the partition function for some arbitrary system? In general, this is a system that has more than one component, and each one of those components has some number of moles or molecules of that substance because we're taking the derivative as we change the number of molecules. So, if this were a single component system, I would write, if I know the partition function for a single molecule, I have n of those molecules. If all the molecules are the same, I would say that the whole system partition function is the individual molecule partition function raised to the n, and if they're indistinguishable from one another, which identical molecules usually are, then I'd divide by this factor of n factorial. That would be true for a single component system where I only have one type of molecule and they're all the same as each other. If I have a multi-component system, clearly the components are not all the same as one another, so I have to remember that I'm doing this for a multi-component system, and what I'll do is I'll say, we're really only interested in component i, one of the particular components. So, there may be a partition function for that type of molecule, a certain number of those type of molecules. So, the part of the partition function that depends on component i is its partition function raised to the number of molecules of that component. Those n sub i molecules are all indistinguishable from each other, but there's also a piece of the partition function that depends on compounds. If this is compound one, then there's a part that depends on compounds two and maybe three and four and five and so on. So, this depends on the number of molecules of all the other components in the system. So, it turns out I don't need to think too carefully about what this part of the partition function looks like as long as compound i is independent from not interacting with the other compounds, then I can write the partition function this way, breaking it up into a piece that depends on compound i and a piece that depends on all the other components. That's enough for me to now take this derivative. I need to be able to take, so I've got minus kT times the derivative with respect to n sub i of the natural log of this partition function, the natural log of this expression, the natural log of this product is minus the log of ni factorial because it's in the denominator, plus log of little q this many times, so n sub i natural log of little q, and then plus natural log of q prime. And since I have the natural log of a factorial, I can rewrite that using Strowing's approximation. I've got d d ni ln n factorial is n ln n minus an n, and the negative sign changes the signs of each of these terms. So that's log of n factorial with a negative sign. I've also got ni log q still and log of all the rest of the partition function. So now those are in a form where I can take the derivative. Derivative with respect to n sub i, remember that the rest of the partition function is q prime only depends on the other components of the system. So that derivative is going to go away once I take the derivative. So let me write the result up here. Chemical potential is going to look like minus kT. Derivative of n log n with the negative sign is going to be minus log n minus 1. Derivative of n sub i is going to be plus 1. Derivative of n log q is going to be plus log q. And this piece has a derivative that goes away. The negative 1 and the 1 cancel. So I've got minus kT ln q sub i minus ln n sub i. And now I can combine those two natural logs into the natural log of the quotient. So I've got minus kT log of individual molecule partition function divided by the number of molecules of that compound. So this is the result that we, I'll stick in a box that we'll use again. Later, that's the partition function calculated from the, I'm sorry, that's the chemical potential of compound i calculated from the partition function. So if we happen to have a partition function for a particular molecule, a particular type of molecule, we know how many of them we have. We can use this expression, this thermodynamic connection formula to calculate the particle, the chemical potential. That's going to come in very handy. In particular, where we'll make most use of this is when we start talking about chemical equilibrium, when we want to convert one type of molecule into another with a chemical reaction. Knowing using this expression to calculate the chemical potential of each of the compounds in the reaction will tell us whether the reaction is going to go forwards or backwards by how much. That's a little ways off in the future. What we'll do for now is continue thinking about the chemical potential and talk about how we can use it to determine for just one type of compound at a time which phase it's going to belong in, which phase is more stable.