 Hi! This is the second screen recording I will try. Let me know how these works actually, because if they're just useless to you, you might as well skip them, but it's always fun to try something new. The second part I want to take you through here has to do with the partition function that is very much based on the Boltzmann distribution as we talked about in the lecture. If you actually, rather than having these proportional two sides, if I want to have proper weights or proper probabilities of being in a particular state, I need to normalize them. And by far the easiest way of normalizing something, if I have properties for say 10 different states, well just sum up all those states and then I put that sum in the denominator. If we put that sum in the denominator, I'm guaranteed that when I take the sum of all these things, the denominator and the denominator, they will sum to 1. And then I have proper probabilities that will sum to 1.0, exactly. So this capital Z of t here, it's a fairly boring sum, it's just literally a sum over the Boltzmann factors for every single individual state I taken of the sum of all possible states in the system. Physicists, in particular theoretical physicists like I have a background of at least, they get something t-ride when you talk about the partition function because this is a beautiful function. Not per se, but the concept here really is that if we know all the individual states of a system, we know everything about the system. And you might argue that that's completely irrelevant. You will never know everything for a real system, but bear with me for a second and we will get there. In the meantime, if you've done the first hand in task, you realize for a simple system or only a handful of states, you can actually understand all your states in the system. And the partition function is literally just the sum over the Boltzmann factors for all those states. So let's see where that takes us. Well, in general, if I know all my states, I can calculate any property that I can easily calculate for each such state. I can calculate the average property over all states by the way the probability is. So if I have a small system like the ones you had in the lab with three to four different states, if I know the energy of each such state, the total energy of the system here is just going to be the sum over each state I. And in the sum of each state, I should say what is the weight of that state? Say that it's 10% likelihood of being in the state multiplied by the energy in this particular sub-state. If you sum this up, you're literally going to get the weighted average over the energy in each state, and that's going to be the total energy of the system. That makes us happy. I can calculate the average energy in the system. And that we can do for entropy two. Or can we? Well, you see, the reason why the first equation here worked is that if this was a protein as we've gone through, remember that I spent a lecture to talk about all those interactions. That worked because I could calculate the energy from the conformations of the system, bonds, angles, torsions, electrostatics, Leonard Jones, whatever. The entropy, I can't just calculate this SI from the value of a single conformation. It's not that easy. So in general, while this is technically true, if I knew the entropy of each system, I could calculate it. The problem is I don't know what that SI is yet, at least. So we're going to see if we can find a way to derive that. And I wouldn't be doing this unless we could. So the challenge here is that how to calculate those individual SI's. Remember that when we talked about entropy, we talked a whole lot about the probabilities or the disorder or the number of the logarithm of the number of microstates or something. All this is intimately related to how likely is it to be in a particular way state and how many different ways are that we could put the entire macroscopic system in different substates. That sounds abstract, so I will cover this with equations instead. If you've taken mathematical statistics, you probably spent weeks going through and putting red and blue balls in different canisters and then arguing how many ways are there to draw things or how many ways are there to distribute things. So in general, if you have say different systems and then we want to argue how many are ways that we can distribute things in the weight one in system two, weight two in system two, weight three in system three, etc., all the weight up to weight J, a system J. And these weights, well if I have a total say of a thousand balls here, if the weight of one system is 10%, that would mean that 10% of the balls, i.e. 100 balls would be in that particular system. So these weights really correspond to the number of things I put in system one, in system two, in system three, etc., all the way up to system J. And of course, the sum of all these by definition has to be the total number of systems. There are ways to handle this in mathematical statistics. The question is how many ways can these systems be distributed over J states, literally. I don't expect to remember that, but you can look up the formulas for permutation online. I will just draw all the equations here, so I don't have to show them one by one. The way to handle this is the faculty, N faculty, where N, capital N is the total number of systems divided by the faculty of each subpart. So uppercase N in the denominator and then the product of all the lowercase and in the denominator, taken from mathematical statistics. Those faculties are difficult to work with, and they're not going to get us anywhere. So for large numbers, we can approximate the faculty with the Stirling formula. I'm not sure if you've seen it. Well, actually, I am sure you've seen it because you're looking at it right now. For large N, you can approximate N faculty as N divided by the base of the natural logarithm raised to the power of N. And I'm going to introduce that both in the denominators and the denominators. I will also use the fact that, okay, let's start with the nominator. So there we have capital N faculty. So capital N divided by the base of the natural logarithm raised to the power of capital N. But I'm going to prepare things a little bit. Capital N is the sum of all the individual Ns from the previous slide, right? So I'm going to write that out. There is no faculty or anything I take, so I'm allowed to do that. And then I do the same thing for each faculty term in the denominator. N1 faculty is N1 divided by e raised to the power of N1, and then a product over that all the way up to Nj. Let's see if we can simplify this a bit. And of course I can. In the nominator here, that long sum of the Ns in the exponent, I could separate that into separate terms. So capital N divided by e raised to the power of N1, multiplied by capital N divided by e raised to the power of N2, etc. And then for each such term, I want to try to simplify that against the corresponding term in the denominator. So the first term here, N divided by e raised to N1, I'm going to try to simplify against that term. Do you see that you have e in both of these? And both of them are raised to N1. So I can strike out that e. That makes my life easier. So that the N is going to be in the nominator here and the N1 in the denominator. So I get N divided by N1 raised to the power of N1 that I had in both of them. And then I do that for N2 and N3, NN4, all the way up to Nj. And that gives me this term. And in principle, this is perfectly fine. I can work with Ns, but the only problem with Ns is that they're literally numbers, right? And then I have to think, do you have a thousand or do you have a million or something to talk about things in general? At least I much prefer to talk about probabilities or weights. So let's use the fact that N1 divided by capital N, that is the fraction of things in state one. Well, that was exactly the weight, W1. And it's, but here's not N1 divided by N, but it's N divided by N1. So it's one over that weight. Same thing here in the exponent N1. Well, that was the weight multiplied by N. Oh, I still have capital uppercase N here. We'll have to live with that for now. And then I expand that to all the terms out here. Do you see here that the uppercase N occurs in every single factor here? So why don't we break all those out into a separate parenthesis and raise that to the power of N and then I strike out all the N's individual terms here. That gets me to the next part here. So I have a parenthesis of one over long sum over the weight raised to the power of the weight or the probability raised to the power of the probability, weight and probability is the same here. And then I just have N in the outer exponent here. But this was when I did this for a complicated general system N. And the reason why I had to do that was to be able to use this permutation laws up here. In practice, I'm just interested in one system here. And if uppercase N is one, well, that somewhat simplifies our life, right? If you replace N with one, I can strike it out. So that the number of ways I can do this is one divided by this strange product of terms. That was proportional to the number of ways I could do it, actually not just proportional to, it is the number of ways I could do it. And that is really this M term. And we already know that the entropy is the Boltzmann factor multiplied by the logarithm of that, right? So we're going to take the logarithm of this term. That looks a bit complicated, but it's actually not. So first it's very, there are a couple of logarithms laws that you might or might not remember. You will see them now otherwise. So the first logarithm law is that if you have the logarithm of A multiplied by B, that is the logarithm of A plus the logarithm of B. So first, remember, you see that the logarithm here, that was of the entire system, that is going to turn into the sum of the logarithms of each sub-state. So that's the sum over the states A. So I can take the logarithm of that expression plus the logarithm of the second expression plus the logarithm of the third expression, etc. The second logarithm law we're going to apply is that if you have logarithm of x to the power of y, I'm allowed to write that as y multiplied by the logarithm of x. And that's what I've done here. You see that instead of having the logarithm of w i raised to the power of w y, I have taken that and put that w i in front of it instead. So this now simplifies that the entropy is the sum of the weight multiplied by the logarithm of one over the weight or the probability. And you see that this sum now only contains the probability of being in each state. I don't know exactly what the probability of being in this state is, but if I could do that with sampling or knowing the system or something, then I could actually evaluate the entropy. Let's see where that gets us. So let's now assume that I already showed that we calculated this for the entity, right? Let's try to calculate this for the entropy S again. That was exactly this formula I had on the previous slide. There is one simplification that I like to do and it's up to you whether you want to do it or not. One over this w, that is really the logarithm of w i raised to the power of minus one. I dislike to have that one over w simply because I don't like the typing. So this minus one I can just break out and put in front of the sum. So that's the logarithm law I've used here. The logarithm of one over w is minus the logarithm of w. And if I now combine this, let's say that I would like to calculate the free energy, then I take the energy part and I take the entropy part. I need the temperature too. And that literally means I just inserting those two expressions in the sum. I get the weight multiplied by the energy, that's the energy part, minus the weight multiplied by the logarithm of the weight and then the minus sign due to one over the weight and then the temperature. So this entire part comes from the entropy. Well, you need the weight there too. I know that this doesn't look beautiful to you, but the point here is that what I now only need to know, I need to know the energy of each state, the confirmation of a protein for instance, and I know to need the weight. But the weight is really just how likely it is. And if you now go back to your first handling task, you kind of know this, right? Because at the end of the day, you know how likely is it to be in state one, how likely is it to be in state two and how likely is it to be in state three. So you can't get it directly just by looking at state one. But if you do a computer simulation and allow all the states, you can let the computer simulation calculate how likely it is to be in different states. So that means that for your handling task, you could even calculate the free energy of each state, even though there might be multiple energy levels of some states. And what makes this beautiful, that if you know this partition function Z, exactly, you can calculate not only the free energy, but actually any property of the system, exactly. Friend of order would then say, yeah, but the first handling task, that was ridiculously simple. That was just three states. How on earth will you be able to calculate this for a protein? Well, the sad story is that you can't calculate that exactly for a protein. But on the other hand, for a protein of all these trillions of states, the protein can be in a whole lot of them are going to have very high energy. And if they have very high energy, you know that from the Boltzmann distribution that it's going to be very, very, very unlikely to be in those high energies. So if I can sample the partition function approximately, for instance, that I can sample it all the states of low to medium energy, maybe that covers 99.99% of the states we can be in. That is enough to make a very good approximation. And the beautiful thing with the computers here is that if I know the partition function approximately, for instance, through a computer simulation, I can calculate the free energy approximately or any other property of the system for that matter. And that is the beauty of computers. We couldn't do this with paper and pen, but with computers we can even for something as complicated as a protein. And that's the beauty of the partition function.