# relation between first law of thermodynamics and statistical mechanics definition of entropy

From the definition of entropy as $S= - Tr (\rho\, ln \rho)$ one obtains that $S = \frac{\langle E \rangle}{T} + \log Z.$

The first law of thermodynamics has

$dS = {dE \over T}$.

Why is there no $d (\log Z)$ in there?

Intuitively I see that $S$ and $E$ are thermodynamic quantities and $\log Z$ is not but formally I don't see why the change in $log Z$ (which is also a function of energy) does not affect the change in entropy.

-

In your simplified forms of the equations (where you omit $p\cdot dV$ in the first law etc.), the term $d(\log Z)$ is absent simply because it cancels against the other term in $dS$ you have forgotten, $-dT \langle E \rangle / T^2$. Note what is the right differentiation of your second (middle) expression for $S$. This cancellation holds because $\rho\sim \exp(-E/kT)$ allows you to rewrite $d(\log Z)=dZ / Z$ as a multiple of $\langle E\rangle$.
@Judy note that $\log Z = TS-\langle E \rangle$, so if $T$ is fixed then $d\log Z / d\langle E\rangle$ = $TdS/d\langle E\rangle - d\langle E\rangle/d\langle E\rangle = T/T-1 = 0$, i.e. if T is fixed then $\log Z$ does not depend on $T$. – Nathaniel Feb 13 '13 at 13:42