Average energy from partition function
WHY do we even want this?
In statistical mechanics we describe a system in contact with a heat bath at temperature . Each microstate has energy and occurs with the Boltzmann probability The thing we can measure is the mean energy . Computing this sum directly is painful. The trick: notice that the same exponentials appear in , so a derivative of "manufactures" the factor of for us.
HOW: derive the average energy from scratch
Step 1 — Write the average energy honestly. Why this step? This is just the definition of an expectation value — sum of (value × probability).
Step 2 — Spot the derivative trick. Differentiate a single weight with respect to : Why this step? The factor we want appears naturally (with a minus sign) when we differentiate. So the cumbersome is just .
Step 3 — Replace the sum. Since , Substitute into Step 1:
Step 4 — Tidy with a log. Recall . Hence:
Why the ? Because is by the chain rule. Taking the log turns "divide by then differentiate" into a single clean operation — and is exactly the object that gives the free energy .
Bonus: energy fluctuations (second derivative)
Differentiate once more and you get the variance, hence the heat capacity:
C_V=\frac{\partial\langle E\rangle}{\partial T}=k_B\beta^2\,\sigma_E^2.$$ *Why care?* It shows $Z$ generates **every** moment: first derivative → mean, second → variance. ![[2.4.11-Average-energy-from-partition-function.png]] --- ## Worked examples > [!example] 1. Two-level system (e.g. a spin in a field) > Energies $0$ and $\varepsilon$. Then $Z=e^{0}+e^{-\beta\varepsilon}=1+e^{-\beta\varepsilon}$. > **Why:** only two microstates, so the sum has two terms. > $$\langle E\rangle=-\partial_\beta\ln Z=-\frac{-\varepsilon e^{-\beta\varepsilon}}{1+e^{-\beta\varepsilon}}=\frac{\varepsilon}{e^{\beta\varepsilon}+1}.$$ > **Why this step?** $\partial_\beta\ln Z=\frac1Z\partial_\beta Z$, and $\partial_\beta Z=-\varepsilon e^{-\beta\varepsilon}$. > **Checks (Forecast-then-verify):** as $T\to0$ ($\beta\to\infty$), $\langle E\rangle\to 0$ (frozen in ground state, ✓). As $T\to\infty$ ($\beta\to0$), $\langle E\rangle\to \varepsilon/2$ (both states equally likely, average of $0,\varepsilon$, ✓). > [!example] 2. Quantum harmonic oscillator (1D, discrete energy levels) > $E_n=n\hbar\omega$, $n=0,1,2,\dots$ Then $Z=\sum_{n}e^{-\beta n\hbar\omega}=\dfrac{1}{1-e^{-\beta\hbar\omega}}$ (geometric series). > **Why:** ratio $r=e^{-\beta\hbar\omega}<1$, so $\sum r^n = 1/(1-r)$. > $\ln Z=-\ln(1-e^{-\beta\hbar\omega})$, so > $$\langle E\rangle=-\partial_\beta\ln Z=\frac{\hbar\omega\,e^{-\beta\hbar\omega}}{1-e^{-\beta\hbar\omega}}=\frac{\hbar\omega}{e^{\beta\hbar\omega}-1}.$$ > **Why this step?** Differentiate the log; the chain rule gives the numerator $\hbar\omega e^{-\beta\hbar\omega}$. > **Check:** high $T$ → $\langle E\rangle\to k_BT$ (classical equipartition for an oscillator, ✓). > [!example] 3. Equipartition from a continuous quadratic mode > A degree of freedom with $E=\tfrac12 ax^2$, $x\in(-\infty,\infty)$: $Z=\int e^{-\beta a x^2/2}dx=\sqrt{2\pi/(\beta a)}\propto\beta^{-1/2}$. > $\ln Z=-\tfrac12\ln\beta+\text{const}$, so > $$\langle E\rangle=-\partial_\beta\ln Z=\frac{1}{2\beta}=\tfrac12 k_BT.$$ > **Why this matters:** each quadratic term in the energy contributes $\tfrac12 k_BT$ — the **equipartition theorem**, derived in two lines from $Z$. --- ## Common mistakes (steel-manned) > [!mistake] "Differentiate with respect to $T$ to get $\langle E\rangle$." > **Why it feels right:** energy depends on temperature, so you reach for $\partial_T$. > **The fix:** the clean formula is $\langle E\rangle=-\partial_\beta\ln Z$. If you insist on $T$, > you must carry the Jacobian: $\langle E\rangle=k_BT^2\,\partial_T\ln Z$ (note the $k_BT^2$, easy to drop). > [!mistake] Forgetting the minus sign. > **Why it feels right:** "derivative of $\ln Z$" sounds positive. > **The fix:** $\partial_\beta e^{-\beta E}=-E e^{-\beta E}$ — the minus comes from the exponent. > Sanity check: $\langle E\rangle$ must be **positive** for $E_i\ge0$; the minus sign delivers that. > [!mistake] Putting $\langle E\rangle = -\partial_\beta Z$ (forgetting the $1/Z$). > **Why it feels right:** the sum $\sum E_i e^{-\beta E_i}=-\partial_\beta Z$ looks like the answer. > **The fix:** that sum is **unnormalized**. You must divide by $Z$, which is exactly why the $\ln$ form ($\frac1Z\partial_\beta Z$) is so convenient. --- > [!recall]- Feynman: explain to a 12-year-old > Imagine a big jar of dice where smaller numbers show up more often when it's cold and all numbers > show up equally when it's hot. $Z$ is a magic counter that adds up "how likely each number is." > Here's the cool part: if you nudge $Z$ a tiny bit (a derivative) and look how it changes, the math > *automatically* multiplies each outcome by its own number — giving you the **average roll** without > manually averaging. So one clever nudge of the counter tells you the typical energy of the system. > [!mnemonic] Remember the formula > **"Log it, slope it, flip it."** Take $\ln Z$, take its slope in $\beta$ ($\partial_\beta$), flip the sign: > $\langle E\rangle=-\partial_\beta\ln Z$. (Flip = the minus from the Boltzmann exponent.) --- ## Active recall > [!recall] Quick self-test > 1. Why does differentiating $Z$ produce a factor of $E_i$? > 2. Where does the minus sign in $\langle E\rangle=-\partial_\beta\ln Z$ come from? > 3. What does the *second* derivative of $\ln Z$ give you? #flashcards/physics What is the partition function $Z$? ::: $Z=\sum_i e^{-\beta E_i}$, the normalizing sum of Boltzmann weights over all microstates. Formula for average energy from $Z$? ::: $\langle E\rangle=-\dfrac{\partial \ln Z}{\partial\beta}=k_BT^2\dfrac{\partial\ln Z}{\partial T}$. Why does $\partial_\beta$ pull out the energy? ::: Because $\partial_\beta e^{-\beta E_i}=-E_i e^{-\beta E_i}$, so the derivative generates a factor of $E_i$ inside the sum. Where does the minus sign come from? ::: From the Boltzmann exponent: differentiating $e^{-\beta E}$ gives $-E e^{-\beta E}$. What does $\partial^2\ln Z/\partial\beta^2$ equal? ::: The energy variance $\langle E^2\rangle-\langle E\rangle^2=\sigma_E^2$. Average energy of a two-level system ($0,\varepsilon$)? ::: $\langle E\rangle=\dfrac{\varepsilon}{e^{\beta\varepsilon}+1}$. Average energy of a quantum oscillator ($E_n=n\hbar\omega$)? ::: $\langle E\rangle=\dfrac{\hbar\omega}{e^{\beta\hbar\omega}-1}$. Equipartition result for one quadratic mode? ::: $\langle E\rangle=\tfrac12 k_BT$, since $Z\propto\beta^{-1/2}$ so $\langle E\rangle=1/(2\beta)$. Relation between heat capacity and fluctuations? ::: $C_V=k_B\beta^2\sigma_E^2$, i.e. heat capacity measures energy fluctuations. Why use $\ln Z$ instead of $Z$ directly? ::: Because $\frac1Z\partial_\beta Z=\partial_\beta\ln Z$, so the log folds the required $1/Z$ normalization into one clean derivative. --- ## Connections - [[Partition function (canonical ensemble)]] - [[Boltzmann distribution]] - [[Helmholtz free energy F = -kT ln Z]] - [[Equipartition theorem]] - [[Heat capacity and energy fluctuations]] - [[Quantum harmonic oscillator — thermal]] - [[Two-level system / Schottky anomaly]] ## 🖼️ Concept Map ```mermaid flowchart TD Z[Partition function Z] P[Boltzmann probability p_i] AE[Mean energy langle E rangle] DEF[Definition sum e^-beta E_i] DERIV[Differentiate wrt beta] LNZ[ln Z] FORM[langle E rangle = -d ln Z / d beta] VAR[Energy variance] HC[Heat capacity] F[Free energy F = -kT ln Z] Z -->|normalizes| P P -->|weighted sum| AE Z -->|defined by| DEF DERIV -->|pulls out E_i| Z Z -->|log of| LNZ LNZ -->|first derivative| FORM FORM -->|equals| AE LNZ -->|second derivative| VAR VAR -->|yields| HC LNZ -->|gives| F ``` ## 🔊 Hinglish (regional understanding) > [!intuition]- Hinglish mein samjho > Dekho, idea bahut simple hai. Statistical mechanics mein har microstate ki energy $E_i$ hoti hai aur uski probability $p_i=e^{-\beta E_i}/Z$ hoti hai, jahan $\beta=1/k_BT$. Hum jo cheez actually measure karte hain wo hai **average energy** $\langle E\rangle=\sum p_i E_i$. Direct sum karna boring hai, isliye ek smart trick use karte hain. > > Trick yeh hai: jab tum $e^{-\beta E_i}$ ko $\beta$ ke respect mein differentiate karte ho, toh khud-ba-khud ek factor $-E_i$ neeche aa jaata hai. Matlab $\partial_\beta Z = -\sum E_i e^{-\beta E_i}$. Ab isko $Z$ se divide karo aur tumhe seedha mil jaata hai $\langle E\rangle = -\frac{1}{Z}\partial_\beta Z = -\partial_\beta \ln Z$. Yaad rakhne ka mantra: **"Log it, slope it, flip it"** — pehle $\ln Z$, phir $\beta$ ka slope, phir minus sign (jo Boltzmann exponent se aata hai). > > Do classic example dekho. Two-level system mein $\langle E\rangle = \varepsilon/(e^{\beta\varepsilon}+1)$: thanda karoge (T chhota) toh energy $\to 0$ (sab ground state mein), bahut garam karoge toh $\to \varepsilon/2$ (dono states barabar). Quantum oscillator mein $\langle E\rangle=\hbar\omega/(e^{\beta\hbar\omega}-1)$, aur high $T$ pe yeh $k_BT$ ban jaata hai — yahi equipartition hai. > > Ek aur bonus: agar $\ln Z$ ko do baar differentiate karo, toh energy ka **variance** mil jaata hai, jisse heat capacity nikalti hai. Iska matlab $Z$ ek "generating machine" hai — ek hi function se mean, fluctuation, sab kuch nikal aata hai. Isliye $Z$ ko poori thermodynamics ki master key bolte hain. ![[audio/2.4.11-Average-energy-from-partition-function.mp3]]