Wolfram Alpha:

```The basic equations:

Pi = (1/Z)exp(-βEi)

Z = Σie-βEi

E  = -∂lnZ/∂β

KBT = 1/β

S = βE + lnZ

A = -KBTlnZ

The Harmonic Oscillator
-----------------------

Consider the classical harmonic oscillator.

E = p2/2m + kx2/2  (KE + PE)

Z = ∫dxdpexp(-β[p2/2m +  kx2/2]

= ∫dpexp(-βp2/2m) ∫exp(-βkx2/2)dx

= √(2πm/β)√(2π/βk)

= 2πm/βω where ω = √(k/m)

Now,

-lnZ = -ln(2π/ω) + lnβ

and.

E = -∂lnZ/∂β

= 1/β

= KBT

If we only consider the kinetic energy term then,

-lnZ = -(1/2)ln(2πm) + (1/2)lnβ

and.

E = -∂lnZ/∂β

= (1/2)β

= KBT/2

Likewise, if we only consider the potential energy term
then,

-lnZ = -(1/2)ln(2π/k) + (1/2)lnβ

and.

E = -∂lnZ/∂β

= (1/2)β

= KBT/2

This is in agreement with the EQUIPARTION OF ENERGY theorem
that states in a system in thermal equilibrium there will be an
average energy of KBT/2 associated with each degree of freedom.
Thus, for a system of n kinetic degrees of freedom and m
associated potential energy degrees of freedom, the total
average energy of the system will be (1/2)(n + m)KBT.

Now consider the quantum harmonic oscillator.

E = nhω

Z = Σnexp(-βnhω)

= 1 + exp(-βhω) +(exp(-βhω))2 + ...

This is the geometric series:

= 1/(1 - exp(-βhω))

Now,

-lnZ = ln(1 - exp(-βhω))

and,

E = -∂lnZ/∂β

= hω/(exp(βhω) - 1)```