# Taming Infinity (Stat Mech Part 3)

The canonical example of quantum mechanics in action is the harmonic oscillator, which is something like a mass on a spring. In classical mechanics, it wobbles back and forth periodically when it is given energy, if it's at a position $x$, wobbling about $x_0$ and moving with velocty $v$ we can say its energy contains a potential term $V$ proportional to $(x-x_0)^2$, and a kinetic term $T$ proportional to $v^2$, with an overall form:

$E = \frac12k(x-x_0)^2 + \frac12mv^2$

We could try and find a distribution over $x$ and $v$, but continuous distributions tend not to "play well" with entropy. They're dependent on a choice of characteristic unit. Instead we'll go to the quantum world.

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/930959ac44d4c616a0a8d60fc377dfab04cd7a96a56a8fc7.png)

One of the major results of quantum mechanics is that systems like this can only exist in certain energy levels. In the harmonic oscillator these levels are equally-spaced, with a spacing proportional to the frequency associated with the classical oscillator. Since the levels are equally-spaced, we can think about the energy coming in discrete units called "phonons".

Our beliefs about the number of phonons $N$ in our system can be expressed as a probability distribution $\mathrm P(N = n)$ over $n \in \mathbb N$:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/7d642ee6f21f66af39bcf8a530164c4538a272e28853b9e2.png)

This is progress: we've reduced an uncountably infinite set of states to a countable one, which is a factor of infinity! But if we do our normal trick and try to find the maximum entropy distribution, we'll still hit a problem: we get $\mathrm P(N = n) = 0$ for all $n \in \mathbb N$.

The Trick: Distribution Families
================================

Thinking back to our previous post, an answer presents itself: phonons are a form of energy, which is conserved. Since we're uncertain over $N$, we'll place a restriction on $\mathbb E(N)$ of our distribution. We can solve the specific case here, but it's actually more useful to solve the general case.

### Maths, Lots of Maths, Skippable:

Consider a set of states of a system $s \in \mathcal S$. To each of these we assign a real numeric value written as  $s \to x_s \in \mathbb R$. We also assign a probability $s \to p_s \in \mathbb R^+$ constrained by the usual condition$\underset {s \in \mathcal S} \sum p_s = 1$.

Next, define $\mathbb E(X) = \underset{s \in \mathcal S} \sum p_sx_s$ and $\mathrm H(S) = - \underset{s \in \mathcal S} \sum p_s \ln p_s$.

Imagine we perform a transformation to our distribution, such that the distribution is still valid and $\mathbb E(X)$ remains the same. We will consider an arbitrary transformation over elements $\{1,2,3\}$:

$p_1 \to p_1 + \mathrm dp_1, p_2 \to p_2 + \mathrm dp_2, p_3 \to p_3 + \mathrm dp_3$

$\mathrm dp_1 + \mathrm dp_2 + \mathrm dp_3 = 0$

$x_1\mathrm dp_1 + x_2\mathrm dp_2 + x_3\mathrm dp_3 = 0$

Now let us assume that our original distribution was a minimum of $\mathrm H(S)$, which can also be expressed as $\mathrm d\mathrm H(S) = 0$.

$\mathrm d\mathrm H(S) = -\mathrm d(p_1 \ln p_1 + p_2 \ln p_2 + p_3 \ln p_3) = 0$

$\mathrm d(p_1 \ln p_1 + p_2 \ln p_2 + p_3 \ln p_3) = 0$

$\ln p_1\mathrm dp_1 + \mathrm dp_1 + \ln p_2\mathrm dp_2 + \mathrm dp_2 + \ln p_3\mathrm dp_3 + \mathrm dp_3 = 0$

$\ln p_1\mathrm dp_1 + \ln p_2\mathrm dp_2 +  \ln p_3\mathrm dp_3 = 0$

The solution for this to be equal to zero in all cases is the following relation:

$\ln p_s \propto  x_s  + \mathrm{const} \implies p_s = A \exp(-Bx_s)$

We can plug this back into our equation to verify that we do in fact get zero:

$\ln A (\mathrm dp_1 + \mathrm dp_2 + \mathrm dp_3) - B(x_1\mathrm dp_1 + x_2\mathrm dp_2 + x_3\mathrm dp_3) = 0 - 0 = 0$

The choice of a negative value for $B$ is so that our distribution converges when values of $x_s$ extend up to $\infty$, which is common for things like energy. We will then get a distribution with the following form:

$\mathrm P(S = s) = A \exp(- B \times x_s)$

Where $B$ parameterizes the shape of the distribution and $A$ normalizes it such that our probabilities sum to $1$. We might want to write down $A$ in terms of $B$:

$A = 1/\Big( \underset{s \in \mathcal S} \sum \exp(- B \times x_s)\Big)$

But we will actually get more use out of the following function $Z = 1/A$:

$Z = \underset{s \in \mathcal S} \sum \exp(-B \times x_s)$

First consider the derivative $\frac{\mathrm dZ}{\mathrm dB}$:

$\frac{\mathrm dZ}{\mathrm dB} = \underset {s \in \mathcal S} \sum -x_s\exp(-B \times x_s)$

$\frac{\mathrm dZ}{\mathrm dB} = -Z\underset {s \in \mathcal S} \sum x_s p_s$

Which gives us the remarkable result:

$\mathbb E(X) = - \frac1Z \frac{\mathrm dZ}{\mathrm dB} = - \frac{\mathrm d \ln Z}{\mathrm dB}$

We can also expand out the value of $\mathrm H(S)$:

$\mathrm H(S) = - \underset{s \in \mathcal S} \sum p_s \ln p_s$

$\mathrm H(S) = - \underset{s \in \mathcal S} \sum p_s \ln (\exp(-B \times x_s)/Z)$

$\mathrm H(S) = - \underset{s \in \mathcal S} \sum p_s (-B \times x_s- \ln Z)$

$\mathrm H(S) = \underset{s \in \mathcal S}\sum(B \times p_s x_s+ p_s \ln Z)$

$\mathrm H(S) = B\underset{s \in \mathcal S} \sum p_sx_s + \ln Z\underset{s \in \mathcal S} \sum p_s$

$\mathrm H(S) = B \mathbb E(X) + \ln Z$

$\mathrm H(S) = - B \frac {\mathrm d \ln Z}{\mathrm dB} + \ln Z$

And get this in terms of $Z$ too! We also get one of the most important results from all of statistical mechanics:

$\frac{\mathrm {dH}(S)}{\mathrm d \mathbb E(X)} = B + \mathbb E(X)\frac{\mathrm d B}{\mathrm d \mathbb E(X)} +\frac{\mathrm d \ln Z}{\mathrm d \mathbb E(X)}$

Now use the substitution:

$\mathbb E(X)\frac{\mathrm d B}{\mathrm d \mathbb E(X)} = - \frac1Z \frac{\mathrm dZ}{\mathrm dB} \frac{\mathrm d B}{\mathrm d \mathbb E(X)} = - \frac1Z \frac{\mathrm dZ} ={\mathrm d \mathbb E(X)} = - \frac{\mathrm d \ln Z}{\mathrm d \mathbb E(X)}$

To get our final result:

$\frac{\mathrm {dH}(S)}{\mathrm d \mathbb E(X)} = B$

So $B$ is not "just" a parameter for our distributions, it's actually telling us something about the system. As we saw last time, finding the derivative of entropy with respect to some constraint is absolutely critical to finding the behaviour of that system when it can interface with the environment.

### <\\Maths>

To recap the key findings:

1.  The probability of a system state $s$ with value $x_s$ is proportional to $\exp(-B  \times x_s)$
2.  This parameter $B$ is also the (very important to specify) value of $\frac{\mathrm{dH}(S)}{\mathrm d \mathbb E(X)}$
3.  We can define a function $Z(B) = \underset {s \in S} \sum \exp(-B \times x_s)$
4.  $\mathbb E(X) = - \frac{\mathrm d \ln Z}{\mathrm dB}$
5.  $\mathrm H(S) = - B \frac {\mathrm d \ln Z}{\mathrm dB} + \ln Z$

Which we can now apply back to the harmonic oscillator.

Back to the Harmonic Oscillator
===============================

So we want to find a family of distributions over $n \in \mathcal N \equiv \mathbb N$. We can in fact assign a real number to each value of n, trivially (the inclusion $\mathbb N \ni n \hookrightarrow n \in  \mathbb R$ if you want to be fancy). Now we know that our distribution over $\mathbb N$ must take the form:

$\mathrm P(N = n) = A \exp(- B\times n)$

But we also know that the most important thing about our system is the value of our partition function $Z(B)$:

$Z = \overset \infty{\underset {n = 0} \sum} \exp(-B \times n)$

Which is just the sum of a geometric series with $a = 1$, $r = e^{-B}$:

$Z = \frac1{1-e^{-B}}$

$\ln Z = - \ln(1 - e^{-B})$

Which gives us $\mathbb E(N)$ and $\mathrm H(N)$ in terms of $B$:

$\mathbb E(N) = \frac{e^{-B}}{1-e^{-B}}$

$\mathrm H(N) = B\frac{e^{-B}}{1-e^{-B}} - \ln(1-e^{-B})$

T instead of B
--------------

Instead of $B$, we usually use a variable $T = 1/B$ for a few reasons. If we want to increase the amount of $X$ in our system (i.e. increase $\mathbb E(X)$) we have to decrease the value of $B$, whereas when $B$ gets big, $\mathbb E(X)$ just approaches the minimum value of $x_s$ and our probability distribution just approaches uniform over the corresponding $s$. Empirically, $T$ is often easier to measure for physical systems, and variations in $T$ tend to feel more "linear" than variations in $B$.

Let's plot both $\mathbb E(N)$ and $\mathrm H(N)$ of our systems as a function of $T$:

![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/97a461323fbdd48e0ee58bbb2442a147895dc0ae7c17f2d0.png)

$\mathbb E(N)$ converges on the line $T - \frac 12$. Rather pleasingly the energy of a quantum harmonic oscillator is actually proportional to $N + \frac12$, not $N$. This little correction is called the "zero point energy" and is another fundamental result of quantum mechanics. If we plot the energy $E$ instead of $\mathbb E(N)$, it will converge on $T$. $\mathrm H(N)$ converges on $\ln (T) - 1$.

These are general rules. $E$ is in general proportional to $T$, and $\mathrm H$ is almost always 

So far we've ignored the fact that our values of $N$ actually correspond to energy, and therefore there must be a spacing involved. What we've been calling $T$ so far should actually be called $\frac T {E_{p}}$ where $E_p$ is the energy of a single phonon. This is the spacing of the ladder of energy levels.

If we swap $\frac T {E_p}$ into our equations and also substitute in the energy $E = E_p(\mathbb E(N) + \frac12)$(we will omit the $\mathbb E$ when talking about energy) we get the following equations:

$E = E_p\Big(\frac{e^{-E_p/T}}{1-e^{-E_p/T}}+ \frac 12 \Big)$

$\mathrm H(N) = \frac1T\frac{e^{-E_p/T}}{1-e^{-E_p/T}} - \ln(1-e^{-E_p/T})$

Both functions now have a "burn-in" region around $T = 0$, where the function is flat at zero. This is important. This region is common to almost all quantum thermodynamic systems, and it corresponds to a phenomenon when $T \ll E_p$. When this occurs  the exponential term $e^{-E_p/T}$ can be neglected for all states except the lowest energy one:

$\ln Z = \ln (e^{-BE_{min}}) \approx -BE_{min} \therefore E = \frac {\mathrm d \ln Z}{\mathrm dB} \approx E_{min}$

Showing $E$ doesn't respond to changes in $T$. This is the same as saying that the system has a probability $\approx 1$ of being in the lowest energy state, and therefore of having $E = E_{min}$.

True Names
----------

$T$ stands for temperature. Yep. The actual regular temperature appears as the inverse of a constant we've used to parameterized our distributions. $B$ is usually called $\beta$ in thermodynamics, and is sometimes called the "inverse temperature".

In thermodynamics, the energy of a system has a few definitions. What we've been calling $E$ should properly be called $U$, which is the internal energy of a system at constant volume.

Entropy in thermodynamics has the symbol $S$. I've made sure to use a roman $\mathrm H$ for our entropy because $H$ (italic) in thermodynamics is a sort of adjusted version of energy called "enthalpy".

In normal usage, temperature has different units to energy which is because, if written as energy, the temperature would be a very small number. It is also because they were discovered separately. Temperature is measured in Kelvin $\mathrm K$, which are converted to energy's Joules $\mathrm J$ with something known as the Boltzmann constant $k_B$. For historical reasons which are absolutely baffling, thermodynamics makes the choice to incorporate this conversion into their units of $S$, so $S = k_B \mathrm H(\mathrm{system})$. This makes entropy far, far more confusing than it needs to be.

Anyway, there are two reasons why I have done this:

1.  I want to avoid cached thoughts. If you already know what energy and entropy are in a normal thermodynamic context, you risk not understanding the system properly in terms of stat mech
2.  I want to extend stat mech beyond thermodynamics. I will be introducing a framework for understanding agents in the language of stat mech around the same time this post goes up.

Conclusions
===========

*   Maximum-entropy distributions with constrained $\mathbb E(X)$ always take the form $e^{-Bx}$
*   This $B$ represents the derivative $\frac{\mathrm d\mathrm H(\mathrm{system})}{\mathrm d\mathbb E(X)}$, if $X$ represents energy, we can write $B$ as $\beta$
*   $B$ is inverse to $T$ which, if $X$ is energy, is the familiar old temperature of the system

We have learnt how to apply these to one of the simplest systems available. Next time we will try them on a more complex system.