See attached file.
In my opinion this problem is a bit too straightforward as all you have to do is use the formula for P_r:
P_r = exp(-E_r)/Z
and do some simple manipulations with that.
So, I'm going to make it more difficult. We will derive the formula for the entropy, but without assuming the general formula for the entropy:
S = - k Sum over r of P_r Log(P_r)
We will also derive the validity of the above expression in the case of the canonical ensemble. The expression for the internal energy (equation (2) below) is derived in the Appendix. The harmonic oscillator problem follows after the Appendix.
It is fairly straightforward to express the pressure and internal energy of a system in terms of the partition function:
P = 1/beta d Log(Z)/dV (1)
E = -d Log(Z)/dbeta (2)
I'll give the proof below in the Appendix. Let's first see how we can derive an expression for the entropy using (1) an (2).
For a general differentiable function of two variables f(x,y) we have:
df = df/dx dx + df/dy dy
Where df/dx is the partial derivative of f w.r.t. x at constant y and df/dy is the partial derivative of f w.r.t. y at constant x.
So, if we take the function f to be Log(Z) and the variables x and y to be the volume V and temperature parameter beta, we can write:
d Log(Z) = d Log(Z)/dV dV + dLog(Z)/dbeta dbeta
Using (1) and (2) we can express the partial derivatives of Log(Z) in terms of the pressure and internal energy. We then get:
d Log(Z) = beta P dV - E dbeta (3)
We can rewrite the term E d beta using:
d[E beta] = E dbeta + beta dE ---------->
E dbeta = d[E beta] - beta dE
Inserting this in (3) gives:
d Log(Z) = beta P dV - d[E beta] + beta dE ------->
d[Log(Z) + E beta] = beta P dV + beta dE ------>
dE = 1/beta d[Log(Z) + E beta] - P dV -----> ...
The formula S = -k sum over r of P_r log(P_r) is derived from first principles. We also derive the expressions for the internal energy, entropy, and Helmholtz free energy in terms of the partition function. Finally we solve the problem about the Einstein model of a crystal.