Set two isolated boxes side by side with a wall between them. No particle crosses, but energy may pass through the wall. The pair as a whole is isolated, so E_1 + E_2 = E does not move.
The division is then settled by E_1 alone. In the figure E_1 moves back and forth, and E_2 moves the opposite way by the same amount.
So which division does it settle into? The previous piece already fixed how to answer that: the one with the most microstates.
The number of microstates for a division E_1 is W_1(E_1) \, W_2(E - E_1). Take logarithms and it becomes \log W_1 + \log W_2, that is S_1 + S_2. Instead of hunting for the peak of a product we may hunt for the peak of a sum.
The rising curve in the figure is S_1 and the falling one is S_2. The left system gains states as it takes energy, the right one loses them as it gives energy away. Adding the two gives the curve below, with a peak in the middle.
The sum has a peak because there is a place where the rate of gaining and the rate of losing balance. Past that place, what is lost by giving outweighs what is gained by taking.
At the top of the peak, moving E_1 a little does not change S_1 + S_2. Written out, \dfrac{\partial S_1}{\partial E_1} = \dfrac{\partial S_2}{\partial E_2}. E_2 falls by exactly what E_1 gains, which is where the signs come out even.
The two panels in the figure are each system's S(E) with its tangent at the current division. Move E_1 and the two slopes change, and at exactly one place they agree. That place is the top of the peak, which is to say equilibrium.
What has appeared here is a single number shared by two systems. A quantity that takes the same value in two systems of different contents and different sizes once they have come to equilibrium. That is precisely the office of what we call temperature.
So we define \dfrac{1}{T} = \dfrac{\partial S}{\partial E}. How much the entropy rises when a little energy is added: the reciprocal of that rise is the temperature.
The figure shows S(E) with its tangent. The curve lies flatter the higher it goes. The more energy a system already holds, the less its state count grows on a little more. A smaller slope means a larger T.
What a thermometer measures, run all the way down, is this slope. A quantity that began as the feeling of hot and cold has been restated in the language of counting, as how fast the state count grows.
What if the two slopes differ? Move energy towards the steeper slope and what is gained there outweighs what is lost by the giver. The total S goes up.
A steeper slope means a smaller T, so this is the same as saying that heat flows from the hotter body to the colder one. The arrow in the figure is that direction, and as energy moves the two slopes draw together.
A direction that thermodynamics had laid down from experience has come out here from which number is larger. The reason it flows is that there are more cases that way, and nothing else. In the next chapter we make one of these two systems very large and treat it as a heat bath.