 Alright, so let's take another look at this equilibrium condition for chemical equilibrium and see what we can understand about it in a more general case, more than just a specific case for an ideal gas. So just as a reminder, when we tried to understand this equation, chemical equilibrium condition for this H2 and Br2 reaction, a case where that condition specifies that the chemical potential of H2 and Br2 have to add up to the same thing as the chemical potential of the products, two molecules of HBr, that led eventually to the condition that this ratio of pressures of HBr and H2 and Br2 had to be equal to some particular constant that we called the equilibrium constant under conditions of equilibrium. We made an assumption during that process, we assumed that these gases were ideal gases, that's not an assumption we have to make, and it was specific for this particular reaction. So if we consider what happens more generally when we're at equilibrium, we can say, if we go back to this equilibrium condition, let's actually say the chemical potentials that we're going to deal with here, the chemical potential we know is the rate of change of the Gibbs free energy as we add or subtract molecules of that particular species, that's how we think about the chemical potential if we're doing something at constant temperature and pressure. Equivalently, we've seen that we can think of the chemical potential as the rate of change of the Helmholtz free energy if we're doing the change at constant temperature and volume. Experimentally, of course, it's usually more convenient to deal with constant temperature and pressure. Mathematically, for the steps we're about to do, it turns out to be a little more convenient to deal with the Helmholtz free energy instead of the Gibbs free energy. Both these equations are equally true, so we'll start out with the one in terms of the Helmholtz free energy as a starting point. So what I'm going to do is I'm going to take this definition of what the chemical potential means and insert it into our equilibrium condition to find that actually the first thing I'm going to do, I take that back. So what we'll do is in order to compute the derivative of the Helmholtz free energy with respect to the number of moles of some species, let's go back to our statistical mechanics definition of what the Helmholtz free energy is. Helmholtz free energy is minus kT log of the partition function for the system. So the chemical potential then is the rate of change of that energy with respect to moles of some species. So I can write that as minus kT d log q d ni. This is an expression we've actually considered before, this capital Q, full partition function for a system involving multiple species. We've seen before that we can write that instead of d log big q d n, we can think of that as just a logarithm of little q divided by little n. And the reason that's true, I'll just remind you very quickly why that's true, if the big system partition function, if we can think of that as a bunch of indistinguishable particles that are identical, so each small particle has a partition function little q and of the big end of those particles have a partition function of q to the n, but if they're indistinguishable I divide by this n factorial. So log q is going to be the logarithm of 1 over n factorial, which using Sterling's approximation is the negative of n log n minus n. And I also have the log of q to the n, so that's n log q. If I take the derivative, remember we're interested in the derivative of log q with respect to n. If I take the derivative of log q with respect to big n, in this case, number of molecules. Derivative of minus n log n is minus log n and I have a minus 1 times 1 and I have a derivative of n is plus 1 and the derivative of n log q is plus log q. The 1 and the negative 1 cancel and so what I'm left with is natural log of q minus natural log of n or natural log of q divided by n. So that's just a quick reminder or recap of why it's true that d log big q dn is equal to the log of little q divided by n. So here's the expression we have for chemical potential in particular. Chemical potential of one of the species in this system that's undergoing some sort of chemical reaction. If I insert that expression into my chemical equilibrium condition, I will be at chemical equilibrium as long as the sum of stoichiometric coefficients times chemical potentials is equal to zero. So the sum of stoichiometric coefficients times chemical potentials. So chemical potential is minus kT natural log qi over ni. I'll leave the qi and ni inside the sum but the minus kT I'll throw outside the sum because they don't depend on the index. And in fact, since this product of things has to equal zero, I can just divide by kT on both sides and that kT in fact just completely goes away. So what must be true is zero must be equal to the sum of stoichiometric coefficients times natural log of little q divided by little n. That's feeling a little abstract at this point. So let's go back over to our H2 and Br2 system and see if we can understand what that means about a real chemical system. So translating this equation into the H2-Br2 case, I'll say that zero has to be equal to the sum of stoichiometric coefficients log little q over n. So in this case, my species are H2 and Br2 and HBr. So I've got negative log q of H2 over molecules of H2. For Br2 is also negative one. So I've got minus log q of Br2 over n Br2. And then the stoichiometric coefficient for HBr is 2. So I've got positive 2 log q of HBr over molecules of HBr. So that's all this expression says. We can clean that up a little bit. In fact, what we should do, I suppose, is combine all those logs into one big logarithm. So I've got log of qH2 over mH2 qBr2 over, actually, let me absorb the negative sign into that logarithm. So this negative sign means it's actually the log of big n over little q for H2. Negative sign here means I flip this one upside down as well. So log of big n Br2 over little q for Br2. And then twice it's positive, so I don't flip it upside down. But 2 means I square this term. I'm going to get the log of qHBr squared over nHBr also squared. Now that I've got all those in one gigantic logarithm, if I undo the logarithm and get a 1 on this side, e to the 0 is 1, e to the natural log on this side just gives me this ratio of n's and q's. I've got nH2 and nBr2 in the numerator. The other n I've got is in the denominator, nHBr squared. The q's, I've got a qHBr squared in the numerator and a qH2 and a qBr2 in the denominator. Next thing I'll do is rearrange this and put the q's on one side and the n's on the other. So let me leave the q's where they are on the right hand side. I'll bring all the n's over to the left hand side of the equation. Then when I turn those upside down I've got products on top. So nHBr squared is in the numerator, nH2 and nBr2 is in the denominator. That's all equal to this ratio of partition functions, qHBr squared in the numerator, q of H2, q of Br2 in the denominator. So this was an elaboration of what this equation means for a specific case, this H2Br2 reaction. Once we had it written in this form it became obvious that we should rearrange it a little bit and obtain this form. If I do the same thing over here, I've run out of room so let's bring that up to here, zero being equal to the sum of stoichiometric coefficients times this natural log. Remember what we did with those stoichiometric coefficients is we used them either to turn these ratios upside down or to square them. So what that means is we used the stoichiometric coefficient as an exponent, as a power inside the natural log. The next thing we did was to combine all those natural logs into a single natural log. So the sum of a bunch of logs is the log of the product. So I can write that as logarithm of the product of all these q sub i's and n sub i's. Now that I've got a gigantic logarithm, I can undo that logarithm by exponentiating both sides, e to the zero is one, e to the natural log is just this product of partition functions over molecule numbers. And now the last step was to bring the ends over to the left-hand side. So I've got product of molecules or moles on the left-hand side, leaving me with a product of partition functions on the right-hand side. So this is the general somewhat abstract version of this specific example we have here for the H2Br2 reaction. I'll point out that this is still just an equilibrium condition. We started with the condition that stoichiometric coefficients times chemical potentials have to equal zero when I'm at chemical equilibrium. Rearranged that in a bunch of ways and found that this is the condition that we have to obey for H2Br2. If the ratio of the number of molecules is equal to this particular constant, then we're in equilibrium. The constant is specific to the partition function for HBr and H2Br2. Those are particular values that have some numerical value at some temperature. They would have different values for some different reactants and products of a different reaction, different values at different temperatures. But knowing what we know about statistical mechanics and diatomic molecules, we can compute those partition functions. The ratio of those partition functions with these particular stoichiometric coefficients, we call it equilibrium constant. When this ratio of molecules is equal to that ratio of numerical values, then the system's in equilibrium. Notice also that the number of molecules, that would be proportional to the pressures if we had an ideal gas. If it's not an ideal gas, then perhaps the number of molecules is not exactly proportional to the pressure of the gas. But in general, this equilibrium condition, whether it's for this specific case of H2 and Br2, or the more general case, tells us that when I have a particular combination of numbers of molecules of some species, if that's equal to a ratio of partition functions that we call the equilibrium constant, then the reaction will be in equilibrium. This is understandably a bit vague, a bit abstract at this point, even for the specific case of H2 and Br2. So the next step will be to plug some actual numbers into this equilibrium constant, equilibrium condition, and see what that tells us about predicting where equilibrium lies for a chemical reaction.