\documentclass[11pt]{article}

\topmargin=0.0in
\oddsidemargin=0.0in
\evensidemargin=0.0in
\textwidth=6.5in
\textheight=9.0in
\setlength{\parindent}{0cm}
\setlength{\parskip}{1em}
\usepackage{latexsym}

\begin{document}
\title{Physics 213 Midterm Review Notes}
\author{Anne C. Hanna\\ ahanna@uiuc.edu}
\date{\today}
\maketitle
\tableofcontents
\pagebreak
\section{Disclaimers and usage notes}
These midterm notes are not necessarily complete, correct, or even useful.  And even if they were, they shouldn't be your only review materials.  Look through the text and the lecture notes, and try some practice exams too, please!

Also, I would advise not becoming too dependent on the equation sheet during your studying.  It has valuable information on it, but it provides this information without context.  For example, it gives several different equations for the work done by an ideal gas during a thermodynamic transition, but it does not tell which equations are valid under which circumstances.  I have seen people unthinkingly use the adiabatic work equation for an isobaric problem and so forth, because they blindly copied the equation sheet instead of sitting back and saying, ``Okay, what's the physics here?  What is being held constant, and how does this affect the work integral?''  It is \emph{much} better to have a solid understanding of the concepts and the derivations which stand behind the equations, because then you can easily handle unfamiliar problems, or derive the correct equation for your purposes on the fly.

Okay, rant over.

\section{Internal energy}
\subsection{Macroscopic objects}
Let's say I have a block of mass $M$ whose center of mass is the point $P$, which is initially located at a postion $x=x_{P,i}$.  The block has a string attached to it at a point $Q$, which is initially located at $x=x_{Q,i}$.  The string runs over a pulley, and its other end is attached to a little mass, $m$.  If we let the little mass fall freely, it will exert a constant force $F_m=F=mg$ on the end of the string it is attached to, which creates a tension $T=F_m=F$ in the string, which then exerts a force $F_Q=T=F$ on the attachment point $Q$.

Assuming the block is rigid, and that it moves freely in the $x$ direction under the influence of this force, then we can say that the \emph{net} force on the block's center of mass is $F_P=F_Q=F$.  Depending on where the string is attached, the block may or may not experience torque due to the force, but this does not affect the fundamental Newton's law fact that the total force on the center of mass is the vector sum of all the individual forces on the object, and further that $F_Q = Ma_Q$.

So, suppose the little mass falls a distance $D$ during the time of interest.  (It does not necessarily \emph{stop} falling after this point, but we are only interested in the state of the system once it has fallen this distance $D$.)  As the mass falls, it converts its gravitational potential energy into kinetic energy, and then uses this kinetic energy to do work on the block.  Since we are assuming that there is no friction in this problem, we can say that every single bit of gravitational potential energy the little mass loses \emph{somehow} ends up in the block.  So, during this time, the block has gained energy $\Delta E_{\mathrm{tot}} = mgD = FD$.

Now, let's say that during the time it took the little mass to fall a distance $D$, the block's string attachment point $Q$ has moved from $x=x_{Q,i}$ to $x=x_{Q,f}$ and the block's center of mass $P$ has moved from $x=x_{P,i}$ to $x=x_{P,f}$.  Assuming the string is of fixed length (does not stretch or shrink) the attachment point $Q$ has to move the same distance as the little mass.  So $x_{Q,f}-x_{Q,i} = D$, and we know that the total work done on the block is:
\begin{equation}
\Delta E_{\mathrm{tot}} = \int_{x_{Q,i}}^{x_{Q,f}}F_Q\,dx = F_Q\left(x_{Q,f}-x_{Q,i}\right) = F\cdot D
\end{equation}
As expected, this is the same as the gravitational potential energy lost by the little block.  However, if the block's orientation has changed at all from its initial orientation, it is possible that its center of mass $P$ did not move as far as the attachment point $Q$.  Let's say that $x_{P,f}-x_{P,i} = d_{\mathrm{cm}} \leq D$.  ($d_{\mathrm{cm}}$ cannot be larger than $D$, for reasons which will be explained shortly.)  Then, the work done on the center of mass is:
\begin{equation}
\Delta E_{\mathrm{cm}} = \int_{x_{P,i}}^{x_{P,f}}F_P\,dx = F_P\left(x_{P,f}-x_{P,i}\right) = F\cdot d_{\mathrm{cm}}
\end{equation}
Note that even though the \emph{force} exerted on the center of mass was the same as that exerted at the attachment point $Q$, the \emph{work} done on the center of mass will not necessarily be the same.  This equation also shows the reason that $d_{\mathrm{cm}}$ cannot be greater than $D$: if it were, the block would have gained more center of mass energy than it did total energy, and this is impossible!

The question now arises of how to interpret these different energies.  The force exerted on the block's center of mass has served only to set it into motion, and the only form of motion a center of mass may have is translational kinetic energy.  So it is clear that we may interpret the work done on the block's center of mass as the change in its translational kinetic energy:
\begin{equation}
\Delta \mathrm{KE}_{\mathrm{trans}} = \Delta E_{\mathrm{cm}} = Fd_\mathrm{cm}
\end{equation}
If and only if the block's speed was initially zero, then its translational speed $v$ at the time of interest will satisfy:
\begin{equation}
\mathrm{KE}_{\mathrm{trans}} = Fd_{\mathrm{cm}} = \frac{1}{2}Mv^2
\end{equation}
If $d_{\mathrm{cm}} < D$, then the block has also gained some energy which did not go into translational kinetic energy.  In a general problem of this type (on involving balls of putty, or springs, or other types of objects) this other energy may have become heat energy, spring potential energy, internal vibrational energy, or something else.  In this particular case, the extra energy has gone into causing the block to rotate and so has become \emph{rotational} kinetic energy:
\begin{equation}
\Delta \mathrm{KE}_{\mathrm{rot}} = \Delta E_{\mathrm{tot}} - \Delta \mathrm{KE}_{\mathrm{trans}} = FD - Fd_{\mathrm{cm}} = F\left(D - d_{\mathrm{cm}}\right)
\end{equation}
In a general problem of this type, any energy which does not become \emph{translational} kinetic energy and instead becomes rotational, heat, spring potential, vibrational, or other energy is referred to as \emph{internal} energy.

\subsection{A brief reminder about springs}
Linear springs, the kind we all know and love from our mechanics classes, exert force in a relatively simple way.  They have some sort of equilibrium length for which they exert no force at all.  If they are stretched or compressed a distance $x$ from this equilibrium, they will exert a force $kx$ which opposes this stretching or compression.  The number $k$ is called the spring constant, and is a property of that particular spring.  If you want to change it, you need to get a new spring.  It has units of force per unit length, which in SI is N/m.  So an object of mass $m$ attached to a spring of constant $k$ which is stretched a distance $x$ experiences a force:
\begin{eqnarray*}
F &=& ma = m\frac{dv}{dt} = m\frac{d^2x}{dt^2}\\
  &=& -kx
\end{eqnarray*}
Newton's law for the force allows us to construct a linear second-order differential equation (above), which has the following solution:
\begin{equation}
x(t) = x_0\cos(\omega t) + \frac{v_0}{\omega}\sin(\omega t)
\end{equation}
where $x_0$ and $v_0$ are the position and velocity of the mass at time $t=0$ and $\omega = \sqrt{k/m}$ is the oscillation frequency of the system, in units of radians per second.  The number of cycles per second is $f = \omega/2\pi$, and the period of one full oscillation cycle is $T = 1/f$.

Another important feature of linear springs is that by stretching or compressing a linear spring we may store energy on it.  When we stretch a linear spring from equilibrium to an extension distance $A$, at each instant during the stretching we must exert a force $F_{\mathrm{on}} = kx$ to counteract the force $F_{by} = -kx$ which the spring exerts in its attempt to restore itself to equilibrium.  So, the work we do on it in extending it by this distance (and thus the spring potential energy that we store in it) is:
\begin{equation}
\mathrm{SPE} = W_{\mathrm{on}} = \int_0^A kx\,dx = \left[\frac{1}{2}kx^2\right]_0^A = \frac{1}{2}kA^2
\end{equation}
Note that in this computation it does not matter whether we have stretched or compressed the spring by a distance $A$, the result will be the same.

A mass attached to a spring and oscillating frictionlessly must have constant total energy, so if its maximum extension is $A$, then we may find its translational kinetic energy at any time by setting $\mathrm{KE} = k(A^2-x^2)/2$ where $x$ is its current position, since the spring's kinetic energy is zero at its maximum extension.  Note that this quadratic relationship between energy and position means that the energies will oscillate at \emph{twice} the frequency of the position oscillation. 

And that's the simple harmonic oscillator, as we need it for this course.


\subsection{Microscopic objects}
\subsubsection{A single molecule}
Let's suppose we have a bag of molecules at a temperature $T$.  Note that for our purposes in this course, the only meaningful value for $T$ is its absolute value, that is, its value in Kelvins.  A Kelvin is the same size as a Celsius degree, but the zero point is shifted, so that $0\ ^\circ\mathrm{C} = 273.15\ \mathrm{K}$.  Also, recall that a Celsius degree is $9/5$ of a Fahrenheit degree, and that $0\ ^\circ\mathrm{C} = 32\ ^\circ\mathrm{F}$.

Anyway, the \emph{meaning} of temperature is that it tells you something about the average energies of the moloecules in your bag.  Specifically, \emph{each} quadratic degree of freedom of \emph{each} molecule has an average energy of $k_BT/2$, so that if there are $q$ of these quadratic degrees of freedom, the molecule's total energy is $E_\mathrm{tot} = qk_BT/2$.  This is called \emph{equipartition}.  Quadratic degrees of freedom are ones for which the energy is propotional to the square of some important molecular property.  Examples include the translational kinetic energy $\mathrm{KE}_{\mathrm{trans}} = mv^2/2$, the rotational kinetic energy $\mathrm{KE}_{\mathrm{rot}} = I\omega^2/2$, and the spring potential energy, $\mathrm{SPE} = kx^2/2$.  The parameter $\alpha$ is defined as $\alpha = q/2$, so that the average energy of a single molecule is:
\begin{equation}
E_{\mathrm{tot}} = \alpha k_BT
\end{equation}

The number $k_B$ is Boltzmann's constant, which has units of energy per Kelvin per molecule.  (So a single molecule at one Kelvin has $k_B/2$ units of energy per quadratic degree of freedom.)  In SI units,
\begin{equation}
k_B = 1.381\cdot10^{-23}\ \mathrm{J/K/molecule}
\end{equation}
Since you often deal with units of liters and atmospheres, it is important to realize that a liter-atmosphere is also a unit of energy, and in these units

\begin{equation}
k_B = 1.363\cdot10^{-25}\ \mathrm{L\cdot atm/K/molecule}
\end{equation}

In a three dimensional situation, every single molecule, regardless of its type, will have \emph{three} translational degrees of freedom, and so it is \emph{always} true that:
\begin{equation}
\mathrm{KE}_\mathrm{trans} = \frac{1}{2}mv^2 = \frac{3}{2}k_BT\ (\mathrm{always})
\end{equation}
(It is extremely important in these computations to use the mass of a \emph{single} molecule.  Frequently you are given the ``molecular weight'' of a substance.  This is \emph{not} the mass of one molecule of the substance (nor is it a ``weight'', for that matter), but is actually the mass \emph{in grams} of one \emph{mole} of the substance.  A mole is defined to be Avogadro's number of molecules, that is, there are $N_A = 6.022\cdot10^{23}\ \mathrm{molecules/mole}$.  So for one molecule, $m = \mathrm{MW}/N_A$.  Also note that, since everything else is in SI units, you will need to convert grams to kilograms to get correct results.)

Anyway.  A monatomic molecule will only have the three translational degrees of freedom, no more, so the total average energy of a monatomic molecule in a bag at temperature $T$ is 
\begin{eqnarray*}
E_{\mathrm{tot,\ monatomic}} &=& \mathrm{KE_{trans}} = \frac{3}{2}k_BT\\
\alpha_{\mathrm{monatomic}} &=& \frac{3}{2}
\end{eqnarray*}

Diatomic molecules have the three translational degrees of freedom and an additional two degrees of rotational freedom, and so will have
\begin{eqnarray*}
\mathrm{KE_{rot,\ diatomic}} &=& k_BT\\
E_{\mathrm{tot,\ diatomic}} &=& \frac{5}{2}k_BT\\
\alpha_{\mathrm{diatomic}} &=& \frac{5}{2}
\end{eqnarray*}

Atoms in a solid and complex molecules have three translational and three vibrational degrees of freedom, so that
\begin{eqnarray*}
E_{\mathrm{vib,\ solid}} &=& \frac{3}{2}k_BT\\
E_{\mathrm{tot,\ solid}} &=& 3K_BT\\
\alpha_{\mathrm{solid}} = 3
\end{eqnarray*}

It is very important to distinguish amongst the three translational degrees of freedom and the others.  As in the macroscopic case, the translational kinetic energy gives the center of mass speed of the molecules.  Any other degrees of freedom are classified as ``internal'' energy and do not affect the molecule's speed.  The internal energy of a molecule is
\begin{equation}
E_{\mathrm{int}} = \left(\alpha - \frac{3}{2}\right)k_BT
\end{equation}

\subsubsection{$N$ molecules}
If there are $N$ molecules in the bag, then the total energy of all the stuff in the bag is:
\begin{equation}
U = N\cdot\alpha k_BT = \alpha Nk_BT
\end{equation}
This equation is sometimes written in term of the number of moles in the bag instead of the number of molecules.  Since there are $N_A$ molecules per mole, the number of moles is:
\begin{equation}
n = \frac{N}{N_A}
\end{equation}
so that:
\begin{equation}
U = \alpha nN_Ak_BT
\end{equation}
The number $N_Ak_B$ is sometimes called the gas constant, $R$.  It is in units of energy per Kelvin per mole, and its value is:
\begin{equation}
R = N_Ak_B = 8.314\ \mathrm{J/mol/K} = 0.08617\ \mathrm{L\cdot atm/mol/K}
\end{equation}
Be sure to use the value of $R$ with the appropriate units for your problem.

Finally, note that all the information above is not a precise description of any real materials.  It is simply a very very very good approximation of their behavior within a reasonable range of temperatures.  At very high or very low temperatures, other effects start to rear their ugly heads.  But we don't have to worry about them for right now...

\section{Ideal gases}
\subsection{Basics}
An ideal gas is a dilute mixture of particles which move freely in some confined region and do not interact with each other beyond some basic unwillingness to occupy the same region of space.  In thermal equilibrium, an ideal gas will have the macroscopic properties of temperature $T$, volume occupied $V$, pressure exerted on the container $P$, and number of moles $n$ or number of molecules $N$ of gas present.  These are related by the ideal gas law:
\begin{equation}
PV = nRT = Nk_BT
\end{equation}
If we have several different species of gases occupying the same region and at the same temperature ({\it eg.} a gas made of $N_{\mathrm{H_2}}$ hydrogen molecules, $N_{\mathrm{O_2}}$ oxygen molecules, and $N_{\mathrm{H_2O}}$ water molecules) then each species will individually satisfy the ideal gas law ($P_{\mathrm{H_2}} V = N_{\mathrm{H_2}} k_B T$ and so forth).  The total pressure will be the sum of the ``partial'' pressures of all the species of gas ($P = P_{\mathrm{H_2}} + P_{\mathrm{O_2}} + PN_{\mathrm{H_2O}}$), and the total particle number will be the sum of all the individual particle numbers ($N = {\mathrm{H_2}} + N_{\mathrm{O_2}} + N_{\mathrm{H_2O}}$).  So we can write:
\begin{eqnarray*}
P &=& \sum_i P_i\\
N &=& \sum_i N_i\\
n &=& \sum_i n_i\\
PV &=& V\sum_i P_i = k_BT\sum_i N_i = RT\sum_i n_i\\
   &=& \sum_i \left(P_i V\right) = \sum_i\left(N_ik_BT\right) = \sum_i\left(n_ik_BT\right)
\end{eqnarray*}

Note that the ideal gas relation does not depend on the type of molecules at all -- $\alpha$ never comes into it.  However, the total energy of the gas is of course governed by the relations described above, which \emph{do} depend on the type of molecules.  The total energy of the entire volume of gas is:
\begin{equation}
U = \alpha nRT = \alpha Nk_BT = \alpha PV
\end{equation}
The total energy of a single molecule in the gas is $U/N$.

\subsection{Changes in energy}
If a gas confined to a volume $V$ at a pressure $P$ is permitted to expand, this expansion can be used to do work (for example, by driving a piston).  Supposing for a moment that the gas is in a cylindrical chamber with a freely movable piston of area $A$ at one end, the force it exerts on the piston at any given time is $F = PA$, since pressure is a force per unit area.  So the work the gas can do is:
\begin{equation}
W_{\mathrm{by}} = \int_{x_i}^{x_f}F\,dx = \int_{x_i}^{x_f}PA\,dx = \int_{V_i}^{V_f}P\,dV
\end{equation}
since the change in the gas volume is just $A$ times the distance the piston has moved.  Conversely, we can compress the gas from some initial volume $V_i$ to some final volume $V_f$, in which case the work we must do to compress the gas is:
\begin{equation}
W_{\mathrm{on}} = -\int_{V_i}^{V_f}P\,dV
\end{equation}
Note that if the final volume is larger than the initial volume, then the gas has done positive work ($W_{\mathrm{by}}>0$), or we can also say that negative work has been done \emph{on} the gas ($W_{\mathrm{on}}<0$).  The reverse is true if the final volume is smaller than the initial volume.  Another way to put this is:
\begin{equation}
W_{\mathrm{by}} = -W_{\mathrm{on}} = \int_{V_i}^{V_f}P\,dV
\end{equation}
Note that if the initial and final volumes are the same, then the gas does no work at all, nor has any work been done on the gas.

Another thing we can do is add heat energy to the gas or remove heat energy from it.  This may be accomplished by putting it in thermal contact with a large ``reservoir'' at a different temperature (or by putting it out in the sun, or whatever).  A reservoir is an object at some fixed temperature $T_r$ which is so large (the object, not the temperature) in comparison to our little ideal gas system that whatever heat exchange occurs has essentially no effect on the temperature of the reservoir, although it may substantially change the temperature of the ideal gas.  If the gas and the reservoir are left in contact for a long enough period, the gas temperature $T_s$ will eventually become equal to $T_r$.  The heat energy added to the gas by the reservoir is designated $Q_{\mathrm{in}}$, while the heat energy added to the reservoir by the gas is $Q_{\mathrm{out}}$.  Note that we can write:
\begin{equation}
Q_{\mathrm{in}} = -Q_\mathrm{out}.
\end{equation}

It is important to know the effects of these changes on the total energy of the gas, and conservation of energy tells us the answer.  The change in the energy of the gas will be equal to the heat energy we have added minus the work the gas has done:
\begin{eqnarray*}
\Delta U &=& Q_{\mathrm{in}}-W_{\mathrm{by}} = W_{\mathrm{on}}-Q_{\mathrm{out}}\\
         &=& \Delta\left(\alpha Nk_BT\right) = \alpha Nk_B\,\Delta T = \alpha\cdot\Delta\left(PV\right)
\end{eqnarray*}

\subsection{Heat capacity}
\subsubsection{Constant volume}
It is sometimes useful to know how much energy we must add to a gas in order to raise its temperature by one Kelvin.  Let's say that we have $N$ molecules of a gas, initially at a temperature $T$.  Its energy is then $U_i = \alpha Nk_BT$.  If we add heat energy to raise its temperature by one Kelvin while holding its volume constant, the energy becomes $U_f = \alpha Nk_B(T+1\ \mathrm{K})$, and so the energy has changed by $\Delta U = \alpha Nk_B\cdot 1\ \mathrm{K}$.  So the heat capacity at constant volume, the amount of energy it takes to raise the gas temperature by one Kelvin when its volume is held constant is:
\begin{equation}
C_V = \alpha Nk_B = \alpha nR
\end{equation}
We also sometimes want the heat capacity per mole at constant volume (the amount of energy it takes to raise the temperature one mole of the gas by one Kelvin when its volume is held constant):
\begin{equation}
c_V = \frac{C_V}{n} = \frac{C_V}{N/N_A} = \alpha N_Ak_B = \alpha R
\end{equation}
or the heat capacity per unit mass at constant volume:
\begin{equation}
c_{V,\ \mathrm{mass}} = \frac{c_V}{\mathrm{MW}} = \frac{\alpha R}{\mathrm{MW}}
\end{equation}
So, the change in the energy of the gas when its temperature increases by $\Delta T$ and its volume remains constant is:
\begin{equation}
\Delta U_V = C_V\,\Delta T = nc_V\,\Delta T = Mc_{V,\ \mathrm{mass}}\,\Delta T
\end{equation}
where $M$ is the mass of the entire quantity of gas.

\subsubsection{Constant pressure}
Now what happens if we instead want to keep the gas at a constant \emph{pressure} while raising its temperature?  In this case the gas must be allowed to expand as we add heat energy to it, in order for its pressure to remain constant.  So the gas will be using some of the energy we provide it to do work on its surroundings instead of to increase its internal energy, so we will have to provide the gas with extra energy in order to increase its temperature by the requisite one Kelvin.  Since the gas pressure remains constant, the work done by the gas will be
\begin{eqnarray*}
W_{\mathrm{by},\ P} &=& \int_{V_i}^{V_f}P\,dV = P\left(V_f-V_i\right) = P\,\Delta V = P\,\Delta V + V\,\Delta P\\
 &=& \Delta\left(PV\right) = \Delta\left(Nk_BT\right) = Nk_B\,\Delta T
\end{eqnarray*}
where we have used the fact that $\Delta P = 0$ for a constant-pressure transition.  The internal energy must still change by $\Delta U_P = \alpha Nk_B\,\Delta T$, so then the total heat energy we must add is:
\begin{equation}
Q_{\mathrm{in},\ P} = \Delta U_P + W_{\mathrm{by},\ P} = \alpha Nk_B\,\Delta T + Nk_B\,\Delta T = \left(\alpha + 1\right)Nk_B\,\Delta T
\end{equation}
which gives:
\begin{eqnarray*}
C_P &=& \left(\alpha+1\right)Nk_B = \left(\alpha+1\right)nR = \frac{\alpha+1}{\alpha}C_V = C_V + nR\\
c_P &=& \left(\alpha+1\right)N_Ak_B = \left(\alpha+1\right)R = \frac{\alpha+1}{\alpha}c_V = c_V + R\\
c_{P,\ \mathrm{mass}} &=& \frac{c_P}{\mathrm{MW}}\\
\Delta U_P &=& \alpha Nk_B\,\Delta T
\end{eqnarray*}
The number $(\alpha+1)/\alpha$ is sometimes referred to as $\gamma$:
\begin{eqnarray*}
\gamma &=& \frac{\alpha+1}{\alpha} = \frac{c_P}{c_V} = \frac{C_P}{C_V}\\
\gamma_{\mathrm{monatomic}} &=& \frac{5}{3}\\
\gamma_{\mathrm{diatomic}} &=& \frac{7}{5}\\
\gamma_{\mathrm{complex}} &=& \frac{4}{3}
\end{eqnarray*}
Note that the last gamma only applies for complex gaseous molecules (and even then it's kind of questionable), not for solids, since the ideal gas law does not apply to solids.

\subsection{Ideal gas transitions}
Imagine we have an $N$ molecules of an ideal gas in a piston chamber at an initial pressure $P_i$, volume $V_i$, and temperature $T_i$.  These values are of course related by $P_iV_i = Nk_BT_i$.  There are several different ways we can change its energy.  In each case, you should imagine that the transition takes place very very slowly, so that the gas has time to reach equilibrium at every single instant, and so that it would be possible to very carefully run the transition in reverse and return it precisely to its initial condition.  In each case, we will be interested in the final values of the pressure, temperature, and volume, as a function of the initial parameters, and also the input heat energy, the work done by the gas, and the change in its total internal energy.  Note that each transition has a distinctive work equation, some of which are listed on the equation sheet, so be careful not to mix them up!

\subsubsection{Constant volume}
First, imagine that we fix the piston in place, so that the gas's volume cannot change.  Then we put it in thermal contact with a reservoir at the desired final temperature $T_f$.  So the final volume will be equal to the initial volume
\begin{equation}
V_f = V_i
\end{equation}

and the gas will not be able to do any work, as discussed above.  So

\begin{equation}
W_{\mathrm{by}} = -W_{\mathrm{on}} = 0
\end{equation}
Thus,
\begin{eqnarray*}
\Delta U &=& Q_{\mathrm{in}} - W_{\mathrm{by}}\\
         &=& Q_{\mathrm{in}} = -Q_{\mathrm{out}}\\
         &=& \alpha Nk_B\left(T_f-T_i\right)
\end{eqnarray*}
and 
\begin{equation}
P_f = \frac{Nk_BT_f}{V_f} = \frac{Nk_BT_f}{V_i} = \left(\frac{T_f}{T_i}\right)P_i
\end{equation}

Note that if the final temperature is higher than the initial temperature, the pressure must increase.

\subsubsection{Constant pressure}
An alternate type of transition for the gas is to allow the piston to move freely as we slowly change the temperature of the gas by putting it in contact with a reservoir at the desired final temperature $T_f$.  Then the piston will move to adjust the volume of the gas such that the gas pressure remains constant throughout the transition
\begin{equation}
P_f = P_i
\end{equation}
In this case the final volume will be:
\begin{equation}
V_f = \frac{Nk_BT_f}{P_f} = \frac{Nk_BT_f}{P_i} = \left(\frac{T_f}{T_i}\right)V_i
\end{equation}
So the work done by the gas will be:
\begin{equation}
W_{\mathrm{by}} = \int_{V_i}^{V_f}P\,dV = P_i\left(V_f-V_i\right) = P_iV_i\left(\frac{T_f}{T_i}-1\right) = Nk_B\left(T_f-T_i\right)
\end{equation}
and the change in its total energy will be:
\begin{equation}
\Delta U = \alpha Nk_B\left(T_f-T_i\right)
\end{equation}
which means that the heat energy added to the gas is:
\begin{equation}
Q_{\mathrm{in}} = \Delta U + W_{\mathrm{by}} = \left(\alpha+1\right)Nk_B\left(T_f-T_i\right)
\end{equation}
just as we derived before.

\subsubsection{Constant temperature}
Another type of transition requires using a reservoir whose temperature is the same as the initial temperature of the gas, so that we will have:
\begin{equation}
T_f = T_i
\end{equation}
We then deliberately move the piston in order to change the volume of the gas from $V_i$ to some desired final volume $V_f$.  The ideal gas law states that $PV=Nk_BT$ always, so since $Nk_BT$ must be constant in this transition, this means that $PV$ is also a constant during the transition and so at any time:
\begin{equation}
PV = P_iV_i = P_fV_f
\end{equation}
In particular:
\begin{equation}
P_f = \left(\frac{V_i}{V_f}\right)P_i
\end{equation}
This is a particularly nice transition, since in this case the change in internal energy is:
\begin{equation}
\Delta U = \alpha Nk_B\left(T_f-T_i\right) = 0
\end{equation}
which gives:
\begin{equation}
Q_{\mathrm{in}} = W_{\mathrm{by}} = \int_{V_i}^{V_f}P\,dV = \int_{V_i}^{V_f}P_i\left(\frac{V_i}{V}\right)\,dV = P_iV_i\ln\left(\frac{V_f}{V_i}\right) = Nk_BT_i\ln\left(\frac{V_f}{V_i}\right)
\end{equation}

\subsubsection{Adiabatic transitions}
The adiabatic transition is a little peculiar-seeming, but physically it's quite simple.  Instead of placing the gas in contact with a reservoir, we thermally isolate it (by putting it in a vacuum thermos or a styrofoam cup or something).  So this means that no heat energy can be added to or removed from the gas:
\begin{equation}
Q_{\mathrm{in}} = -Q_{\mathrm{out}} = 0
\end{equation}
The only way we can change the energy of the gas is by doing work on it or allowing it to do work, and all the work that is done on the gas will go straight into its internal energy:
\begin{eqnarray*}
\Delta U &=& W_{\mathrm{on}} = -W_{\mathrm{by}}\\
         &=& \alpha Nk_B\left(T_f-T_i\right)
\end{eqnarray*}
We can actually find constants of motion for an adiabatic transition by using the fact that $W_{\mathrm{by}} = \int P\,dV\Rightarrow dW_{\mathrm{by}}/dV = P = Nk_BT/V$.  Then:
\begin{equation}
\frac{dU}{dV} = \alpha Nk_B\frac{dT}{dV} = -\frac{dW_{\mathrm{by}}}{dV} = -\frac{Nk_BT}{V}
\end{equation}
\begin{equation}
\Rightarrow \int \alpha \frac{dT}{T} = -\int \frac{dV}{V}
\end{equation}
\begin{equation}
\Rightarrow \alpha\ln(T) = -\ln(V) + \mathrm{constant}
\end{equation}
\begin{equation}
\Rightarrow T^\alpha V = \mathrm{constant}
\end{equation}
and since $T\propto PV$, we also know that $P^\alpha V^{\alpha+1}$ is a constant during the transition, in other words, that:
\begin{equation}
PV^\gamma = \mathrm{constant}
\end{equation}
So, if we adiabatically change the volume of a gas from $V_i$ to $V_f$, then its final parameters will be:
\begin{eqnarray*}
P_f &=& P_i\left(\frac{V_i}{V_f}\right)^\gamma\\
T_f &=& T_i\left(\frac{V_i}{V_f}\right)^{1/\alpha}
\end{eqnarray*}
We can also use the $PV^\gamma=\mathrm{constant}$ relation to do the work integral:
\begin{equation}
W_\mathrm{by} = \int_{V_i}^{V_f}P\,dV = \int_{V_i}^{V_f} P_i\left(\frac{V_i}{V}\right)^\gamma\,dV = \left[\frac{1}{-\gamma+1}P_iV_i\left(\frac{V_i}{V}\right)^{-\gamma+1}\right]_{V_i}^{V_f} = \alpha\left(P_iV_i-P_fV_f\right)
\end{equation}

\subsection{Reversibility}
If an ideal gas transition is \emph{reversible} that means that all of the energy that was transferred around during the transition has remained in such a form that we can run the process backward without adding any additional energy to the system.

For example, in an adiabatic transition, the gas is thermally isolated.  We do a certain amount of work on the system (pushing on the plunger to decrease its volume and increase its pressure), which is all stored as internal energy of the gas.  If we release the plunger, the gas will expand freely back to its initial volume without any additional help.  So this transition is reversible.  Similarly, in an isothermal transition, we convert work done on the gas directly to thermal energy of the reservoir, and we can conversely convert the thermal energy stored in the reservoir right back into work.

However, in an isochoric transition, there is no work done.  We've simply transferred internal energy from the hot gas to the cold reservoir (or from a hot reservoir to the cold gas).  Heat flow from a hotter to a colder object is \emph{not} reversible.  Similarly, an isobaric transition involves heat flow from a hot to a cold object and so is not reversible.

Another way to look at this is just to remember that heat flow from hot to cold (isobaric and isochoric) is not reversible.  Heat flow between two objects at the same temperature (isothermal) \emph{is} reversible and a transition with no heat flow (adiabatic) is also reversible.

\section{Heat engines}
\subsection{Fundamentals}
A heat engine consists of two reservoirs, a hot one at $T_h$ and a cold one at $T_c$, and a plan of action for taking an ideal gas through transitions between these two temperature extremes.  The gas might, for example, start at the hotter temperature, be adiabatically cooled to some intermediate temperature, isobarically transitioned to $T_c$, isothermally returned to the initial volume (and another intermediate temperature) and then isochorically brought back to the initial temperature, pressure and volume.  But whatever the intermediate steps are, the final result will be that the gas has returned to its initial state, and so its final energy will be the same as its initial energy.  Thus, if we add together the $\Delta U$ values for all the intermediate steps, the result will be zero.
\begin{equation}
\Delta U_{\mathrm{tot}} = 0 \mathrm{\ for\ a\ complete\ cycle}
\end{equation}

This does \emph{not} mean, however, that the total heat energy input into the gas or the total work done by the gas will be zero.  In fact having a positive heat input ($Q_\mathrm{in}>0$) and a positive work done by the gas ($W_\mathrm{by}>0$) is precisely the point of the heat engine.  The gas experiences no net change during the cycle, but we use it as a medium to convert a certain amount of heat energy from the hotter reservoir into work done by the gas on its surroundings.  Specifically, we have extracted a certain amount of heat, $Q_{\mathrm{in},\ h}$ from the hotter reservoir.  Some of it, an amount $Q_{\mathrm{out},\ c}$, has been lost to the colder reservoir, but the rest, $Q_{\mathrm{in},\ h}-Q_{\mathrm{out},\ c}$ has been used to do work on the surroundings, so we have:
\begin{equation}
W_{\mathrm{by}} = Q_{\mathrm{in},\ h}-Q_{\mathrm{out},\ c}
\end{equation}

\subsection{Efficiency}
Our reservoirs are very very large, so a single cycle of the engine has a negligible effect on their temperatures, but if we run this cycle many many times eventually it will start to degrade the reservoirs.  The hot reservoir will cool down, and the cold reservoir will heat up, and we will be able to extract less and less work from them per cycle, until their temperatures are equalized and we can extract no work from them at all.  We would like have some way to measure how efficiently we are using our reservoirs.  How much work do we get out of them compared to the amount we are degrading them?  So we define a number called the efficiency, which is:
\begin{equation}
\varepsilon = \frac{W_{\mathrm{by}}}{Q_{\mathrm{in},\ h}} = \frac{Q_{\mathrm{in},\ h}-Q_{\mathrm{out},\ c}}{Q_{\mathrm{in},\ h}} = 1 - \frac{Q_{\mathrm{out},\ c}}{Q_{\mathrm{in},\ h}}
\end{equation}

\subsection{Carnot cycles}
There is a particular special cycle, called a Carnot cycle, which consists of an isothermal transition, followed by an adiabatic transition, another isothermal transition, and a final adiabatic transition back to the original state.  Since it is the only possible cycle composed entirely of reversible transitions, a Carnot cycle is the most efficient possible cycle you can run with a particular pair of reservoirs, so for any other cycle with maximum and minimum temperatures $T_h$ and $T_c$, the efficiency must be less than the Carnot efficiency:
\begin{equation}
\varepsilon < \varepsilon_{\mathrm{Carnot}} = 1-\frac{T_c}{T_h}
\end{equation}

\subsection{Refrigerators and heat pumps}
If you run a heat engine in reverse, you can use it as a refrigerator or a heat pump.  In this case, you have to do a certain amount of work on the gas, $W_\mathrm{on} = -W_\mathrm{by}$ in order to extract a certain amount of heat $Q_{\mathrm{in},\ c} = -Q_{\mathrm{out},\ c}$ from the cold reservoir.  Then a certain amount of waste heat, $Q_{\mathrm{out},\ h} = -Q_{\mathrm{in},\ h}$ is expelled into the hot reservoir.  Ideally, you want to be extracting as much heat as possible from the cold reservoir (or dumping as much heat as possible into the hot reservoir, if it's a heat pump) for the amount of work you have put into the engine.  We can measure this in terms of a coefficient of performance, defined for a refrigerator as:
\begin{equation}
K_{\mathrm{fridge}} = \frac{Q_{\mathrm{in},\ c}}{W_\mathrm{on}} = \frac{Q_{\mathrm{in},\ c}}{Q_{\mathrm{out},\ h} - Q_{\mathrm{in},\ c}}
\end{equation}
and for a heat pump as:
\begin{equation}
K_{\mathrm{pump}} = \frac{Q_{\mathrm{out},\ h}}{W_\mathrm{on}} = \frac{Q_{\mathrm{out},\ h}}{Q_{\mathrm{out},\ h} - Q_{\mathrm{in},\ c}}
\end{equation}

If and only if this is a Carnot engine, then the magnitude of the heat inputs, outputs, and work will be of the same magnitude for a work-consuming refrigerator or heat pump as they were for the work-generating engine, although all energy transfers will be in the opposite direction.  For non-Carnot engines, the relevant numerical values may change when you run them forward or backward.

On a related note, Carnot engines run in reverse make the best refrigerators, just as they make the best heat engines, since they are fully reversible engines, and thus waste as little of the available energy as possible.

\subsection{The work integral}
A final comment about heat engines: when you draw the path of the heat engine on a $P$-$V$ graph, you will see that it forms a loop.  The total work done by the gas in one cycle of the loop is equal to the area of the loop (since work is an integral of pressure with respect to volume).  The total work done is positive if the gas circulates clockwise around the loop and negative if it circulates counterclockwise.

\section{Diffusion}
\subsection{Random walks (one-dimensional diffusion)}
So, let's say you're drunk, and you're walking along a one-dimensional street.  Every $\tau = 10\mathrm{\ s}$ (your ``scattering time''), you bump into something, which in your confused state causes you to reverse direction half of the time.  Your average velocity is $v = 0.1\mathrm{\ m/s}$, and so between collisions you travel an average distance $\ell = v\tau = 1\mathrm{\ m}$.  On average, for every step you travel to the left, you travel another step to the right at a later time, and so at any time in the future, you will on average be right back where you started.  But your \emph{actual} position is not the same as your average postion.  On some trips, you may wander pretty far from your origin point before you make it back to the center.  So, even though we know that you're equally likely to be five meters to the left of the origin or five meters to the right, your average \emph{distance} from the origin will not be zero, even though your average \emph{position} is 0.  To find your average distance from the origin, we use the root mean square position.  Root mean square (RMS) means ``square your position, find the average, and then take the square root''.  So, for example, if you have been walking for 10 seconds (one timestep), you might be one meter to the left, or one meter to the right of your origin, and your average position will be zero ($<x_1> = 0$).  But your RMS position will be:
\begin{equation}
x_{1,\mathrm{RMS}} = \sqrt{<x_1^2>} = \sqrt{\frac{(-1\mathrm{\ m})^2}{2} + \frac{(1\mathrm{\ m})^2}{2}} = 1\mathrm{\ m}
\end{equation}
If you have been walking for $N$ timesteps, and your actual position is $X_N$, then your mean square distance after $N+1$ timesteps will be an average between the squares of $X_N+\ell$ and $X_N-\ell$:
\begin{equation}
<X_{N+1}^2> = \frac{(X_N+\ell)^2}{2} + \frac{(X_N-\ell)^2}{2} = X_N^2 + \ell^2
\end{equation}
So, your RMS position is:
\begin{eqnarray*}
x_{N+1,\mathrm{RMS}} &=& \sqrt{<x_{N+1}^2>} = \sqrt{\frac{1}{2N+1}\sum_{X_N=-N\ell}^{N\ell}<X_{N+1}^2>}\\
 &=& \sqrt{\frac{1}{2N+1}\sum_{X_N=-N\ell}^{N\ell}(X_N^2+\ell^2)} = \sqrt{<x_N^2> + \ell^2}
\end{eqnarray*}
and using the fact that $x_{1,\mathrm{RMS}} = \ell$, we can see that $x_{2,\mathrm{RMS}} = \ell\sqrt{2}$ and so forth, so that:
\begin{equation}
x_{N,\mathrm{RMS}} = \ell\sqrt{N}
\end{equation}

(I think Richard Feynman does this slightly more elegantly in volume one of his \emph{Lectures on Physics}, but I can't recall his exact method, so you'll have to look it up for yourself...)

Anyway, since the number of timesteps you've taken to get to your position at time $t$ is $N = t/\tau$, we can write your position in one dimension as a function of time:
\begin{equation}
x_{\mathrm{RMS}}(t) = \ell\sqrt{\frac{t}{\tau}} = \sqrt{2Dt}
\end{equation}
where the diffusion constant is defined as $D = \ell^2/2\tau = v\ell/2$.

If you have taken a very large number of steps, the probability that your position is $X$ is very nearly Gaussian, and so you can write:
\begin{equation}
P(x,t) = \frac{1}{\sqrt{4\pi Dt}}e^{-x^2/4Dt}
\end{equation}
Note that if, instead of a single randomly blundering drunk, your system consists of $N_{\mathrm{particles}}$ of particles released from a single origin, then the number of particles at a distance $x$ from the origin will be:
\begin{equation}
N_{\mathrm{particles}}(x,t) = N_{\mathrm{particles}}P(x,t)
\end{equation}

\subsection{Three dimensional diffusion with randomized step size}
Now suppose you (drunk again) are in a perfectly symmetrical (gravity-free but somehow still walkable) environment.  Your velocity is still $v=0.1\mathrm{\ m/s}$, and you still encounter obstacles on every $\tau=10\mathrm{\ s}$, so your mean free path is still $\ell = 1\mathrm{\ m}$.  But now, after each collision, you randomly choose an axis to move along ($x$, $y$, or $z$) and a direction to move along that axis ($+$ or $-$).  Your mean distance from the origin is still the same, since the derivation of $x_{\mathrm{RMS}}$ above is unaffected by the number of dimensions:
\begin{equation}
r_{\mathrm{RMS}}(t) = \ell\sqrt{\frac{t}{\tau}}
\end{equation}
but since $r^2 = x^2+y^2+z^2$, and all three dimensions are essentially identical, your rate of movement in any one dimension is smaller:
\begin{equation}
x_{\mathrm{RMS}}(t) = y_{\mathrm{RMS}}(t) = z_{\mathrm{RMS}}(t) = \ell\sqrt{\frac{t}{3\tau}}
\end{equation}
In the text, this is characterized as a change in the diffusion constant, which \emph{would} become $D = \ell^2/6\tau = v\ell/6$, except that the text also makes an additional change to the situation --- it takes into account the fact that the obstacles are not distributed regularly throughout space, so the distance between collisions is \emph{not} alway one mean free path.  This change doubles the diffusion constant, so that its final real-world three-dimensional value is:
\begin{equation}
D = \frac{\ell^2}{3\tau} = \frac{v\ell}{3}
\end{equation}
Then, for a particle which may freely travel in three dimensions, the average position at any given time is a distance of:
\begin{equation}
r_{\mathrm{RMS}}(t) = \sqrt{6Dt}
\end{equation}
from its origin point.  If we are only concerned about its distance in one dimension ({\it eg.} the particles are being generated at a wall and we want to know how far from the wall they can travel) then we need to use the one-dimensional distance:
\begin{equation}
x_{\mathrm{RMS}}(t) = y_{\mathrm{RMS}}(t) = z_{\mathrm{RMS}}(t) = \sqrt{2Dt}
\end{equation}

The probability of the particle being at a particular postion at a particular time is:
\begin{eqnarray*}
P_x(x,t) &=& \frac{1}{\sqrt{4\pi Dt}}e^{-x^2/4Dt}\\
P_y(y,t) &=& \frac{1}{\sqrt{4\pi Dt}}e^{-y^2/4Dt}\\
P_z(z,t) &=& \frac{1}{\sqrt{4\pi Dt}}e^{-z^2/4Dt}\\
P_r(r,t) &=& \frac{1}{\sqrt{12\pi Dt}}e^{-r^2/12Dt}
\end{eqnarray*}
and particle counts will be $N_{\mathrm{particles}}$ times these probabilities.

\section{Heat conduction}
\subsection{Fundamentals}
If an object has a thermal conductivity $\kappa$ and its internal temperature is a function of position $x$ within the object ($T = T(x)$), then heat energy will flow from hotter parts of the object to the cooler parts.  This heat flow is measured in terms of a heat current density $J_x$, which has units of energy per unit area per second:
\begin{equation}
J_x = -\kappa\frac{dT}{dx}
\end{equation}
Note the the direction of the heat flow is opposite the direction of the increase in temperature, as it should be.
If the object has a cross-sectional area $A$, then the total energy flowing across an imaginary ``heat flow detector'' at a position $x$ will be:
\begin{equation}
H = AJ_x = -\kappa A\frac{dT}{dx}
\end{equation}
This heat flow $H$ has units of energy per time (the SI unit is Watts), so this equation tells us the amount of energy that crosses our imaginary detector every second.

\subsection{Examples}
A specific example of this is a small object with initial temperature $T_i$ and heat capacity $C$ which is in contact with an enormous reservoir at temperature $T_r$.  The heat flow out of the object at any particular time $t$ is then:
\begin{eqnarray*}
H(t) &=& -\kappa A \left(T(t) - T_r\right) = \kappa A\,\Delta T\\
     &=& \frac{d}{dt}(U_{\mathrm{object}}) = \frac{d}{dt}\left(CT(t)\right) = C\frac{dT}{dt} = C\frac{d\,\Delta T}{dt}
\end{eqnarray*}
Solving this differential equation gives:
\begin{equation}
T(t) = T_r +\Delta T(t) = T_r + T_ie^{-\kappa At/C}
\end{equation}

Another common example is equilibrium heat flow along a rod or through a window pane.  The object in question has cross-sectional area $A$ (area perpendicular to heat flow), length $L$ (distance the heat flows in crossing from one side or end of the objec to the other), and heat capacity $\kappa$.  Each side or end of the object is held at a constant temperature --- at the left $T_\ell$ and at the right $T_r$.

We would like to know, perhaps, the equilibrium rate of energy loss by the hot side to the cold side.  This will be measured in Joules per second, or Watts.  Since we are in equilibrium, we know that there is no energy building up anywhere inside the window or rod, so we can state that the rate of heat flow, $H$ is constant through the entire thickness of the window or length of the rod.  Thus we can relate the rate of heat flow to the temperature difference across the object and the object's physical parameters using the above equations.  The leakage rate from the left side to the right side will be:
\begin{equation}
H_{\ell\rightarrow r} = -\kappa A\frac{\Delta T}{\Delta x} = -\kappa A\frac{T_r-T_\ell}{L} = \kappa A\frac{T_\ell-T_r}{L}
\end{equation}

\subsection{Thermal resistance}
An analogy is commonly made between the flow of heat energy ($H$, measured in Joules per second) in situations with temperature differences and the flow of electric charges ($I$, measured in Coulombs per second) in situations with differences of electric potential.  Comparing the equations, we see that charge flow is related to potential difference by:
\begin{equation}
I = -\frac{\Delta V}{R}
\end{equation}
where $R$, the constant of proportionality, is an electrical resistance and the negative sign comes from taking the direction of current flow {\it vs.} the direction of potential change into account.  Since heat energy flow is related to temperature difference by a similar proportionality:
\begin{equation}
H = -\kappa A \frac{\Delta T}{\Delta x} = -\frac{\Delta T}{\Delta x/\kappa A}
\end{equation}
This suggests that we can treat the constant of proportionality here as a thermal ``resistance'':
\begin{equation}
R_{\mathrm{th}} = \frac{\Delta x}{\kappa A}
\end{equation}

\section{Spin statistics}
Particle spins (up or down), coin flips (heads or tails), and weather forecasts (cloudy or sunny), are examples of binary choices.  You have an ordered sequence of objects (particles, coin flips, days) which must each fall into one of two categories.  In the simplest case (the only one we will discuss), the objects have an equal chance of falling into either category.

Supposing we have $N$ objects, the first question is, how many different possible ways are there for a particular sequence of random choices to come out?  For example, if I flip a coin five times, I may get the sequence HHTHT, or I may get HTHTH.  Both of these will be distinct possible outcomes.  And the computation of the number of possible states is relatively simple.  I have two possible outocmes for the first object (coin flip), which I must multiply times the two possible choices for the second, times the two possible choices for the third, and so forth.  So, in general, the total possible number of outcomes for an N-object binary choice system is:
\begin{equation}
\Omega_{\mathrm{tot}} = 2^N
\end{equation}
In later work, we will refer to this as the total number of possible microstates for the system.  Any single outcome has only one microstate corresponding to it, and so (since all microstates have equal probability) its probability is:
\begin{equation}
P_1 = \frac{1}{\Omega_{\mathrm{tot}}} = 2^{-N}
\end{equation}

The next possible question of interest might be something like, ``If I do five coin flips, how many different ways are there of getting three heads?''  In this case, I don't care \emph{which} coins are heads, only that there are exactly three heads (and two tails).  So I want to know how many ways there are to \emph{choose} exactly three of the five coin flips (order irrelevant) to be heads.  As you may recall from probility classes a million years ago, the number of possible states in this case is $5!/3!2!$.  In general, the macrostate with $N_{\mathrm{up}}$ heads has a microstate count of:
\begin{equation}
\Omega_{N_{\mathrm{up}}} = \frac{N!}{N_{\mathrm{up}}!(N-N_{\mathrm{up}})!}
\end{equation}
Note that the number of tails is $N_{\mathrm{down}} = N - N_{\mathrm{up}}$.  So, the probability of this particular macrostate, with exactly $N_{\mathrm{up}}$ heads, is simply the number of microstates corresponding to this macrostate times the probability of each microstate (or, the number of microstates corresponding to this macrostate divided by the total number of system microstates):
\begin{equation}
P_{N_{\mathrm{up}}} = \frac{\Omega_{N_{\mathrm{up}}}}{\Omega_{\mathrm{tot}}} = \frac{N!}{N_{\mathrm{up}}!(N-N_{\mathrm{up}})!2^N}
\end{equation}

For large $N$, we can approximate this probability with a normal distribution, so that:
\begin{equation}
P_{N_{\mathrm{up}}} \approx \sqrt{\frac{2}{\pi N}}e^{-(N_{\mathrm{up}}-N_{\mathrm{down}})^2/2N}
\end{equation}
Note that, since this is a normal distribution, the width of its peak is proportional to its standard deviation, $\sigma_N = \sqrt{N}$.

Finally, a spin system may be characterized by its magnetization:
\begin{equation}
\mathcal{M} = (N_{\mathrm{up}}-N_{\mathrm{down}})\mu = m\mu
\end{equation}
where $\mu$ is the magnetic moment of a single spin.
The magnetic potential energy of this system in a magnetic field $\vec{B}$ is:
\begin{equation}
U = -\vec{\mathcal{M}}\cdot\vec{B} = -\mathcal{M}B = -m\mu B
\end{equation}

\section{Bin statistics and entropy}
As mentioned previously, a system may have both macrostates and microstates.  A macrostate is a collection of parameters which it is possible to know without access to the detailed internals of the system.  For example, with the coin flips, I may know that out of 10 flips there were 6 heads.  But, I may not know what the exact sequence of heads and tails was.  There may be several different microstates (individual sequences of flips) corresponding to my macrostate (6 heads).  In this particular case, there are exactly $10!/6!4! = 210$ corresponding microstates.

Assuming all microstates are equally likely (the usual thermodynamic assumption) I can compare the probabilities of different macrostates in a couple different ways.  I can say that if macrostate $A$ has $\Omega_A$ microstates, macrostate $B$ has $\Omega_B$ microstates, and $\Omega_A>\Omega_B$, then state $A$ is more probable than state $B$.  In fact, it is $\Omega_A/\Omega_B$ times more probable.  I can also compare their entropies.  The entropy $\sigma$ is defined as the natural logarithm of the state count:
\begin{equation}
\sigma_A = \ln(\Omega_A)
\end{equation}
Note that if $\Omega_A>\Omega_B$ then $\sigma_A>\sigma_B$.  I can also use the entropy to combine two independent systems.  If systems 1 and 2 are independent and have state counts $\Omega_1$ and $\Omega_2$, then the state count of the joint system 12 is $\Omega_{12} = \Omega_1\Omega_2$.  Its entropy is $\sigma_{12} = \ln(\Omega_1\Omega_2) = \ln(\Omega_1)+\ln(\Omega_2) = \sigma_1+\sigma_2$.

This particular definition of the entropy is unitless, but there is also a united entropy $S = k_B\sigma = k_B\ln(\Omega)$, which has units of energy per molecule per Kelvin.  This entropy is related to the temperature $T$ and energy $U$ of a system by:
\begin{eqnarray*}
\frac{1}{T} &=& \left(\frac{dS}{dU}\right)_V\\
\frac{1}{k_BT} &=& \left(\frac{d\sigma}{dU}\right)_V = \beta
\end{eqnarray*}
where the subscript $V$ means that the volume is held constant while taking this derivative.

\subsection{Binning}
Anyway, computing entropies and probabilities and suchlike requires us to go back to state-counting for a bit.  The easiest way to visualize these problems (although it is not perfectly accurate) is to pretend we have a bunch of golf balls, $N$ golf balls to be exact.  We are sorting them randomly amongst $M$ bins.  There are several different possible situations.

\subsubsection{Distinguishable objects}
In the first, and simplest case, all the golf balls are painted different colors so that we can tell them apart, and we can put as many golf balls as we like in each bin.  Then, each golf ball has a choice of any of the $M$ bins, and so the total number of available arrangements of golf balls is:
\begin{equation}
\Omega_{\mathrm{unlimited,\ distinct}} = M^N
\end{equation}

If instead we say that each bin may only hold one golf ball, then the first golf ball has $M$ possible choices, the second has $M-1$ choices, and so forth, so that:
\begin{equation}
\Omega_{\mathrm{single,\ distinct}} = \frac{M!}{(M-N)!}
\end{equation}
Note that in this case we must have at least as many bins as we do golf balls ($M \geq N$).

Finally, if we have many many more bins than golf balls ($M>>N$) then the we don't need to worry about whether or not golf balls can occupy the same bin or not, because the probability of us needing to worry about that is unbelievably small.  So we can just go back to the unlimited occupancy case:
\begin{equation}
\Omega_{\mathrm{dilute,\ distinct}} = M^N
\end{equation}

\subsubsection{Indistinguishable objects}
Technically, the indistinguishable object concept is only really valid for things like energy quanta and truly physically indistinguishable particles (electrons, protons, etc.)  But we can still play a bit of let's pretend with golf balls.  So, we now imagine that all of our golf balls are white and we can't tell which one is which.

For the unlimited occupancy case, we can compute the state counts by realizing that our $M$ bins are separated by $M-1$ walls.  So we can think of any particular arrangement of the $N$ golf balls amongst the bins as if it is an arrangement of the $N$ balls and the $M-1$ walls instead of trying to think about it just in terms of balls.  For example, if we have three bins and three balls two of which are in the first bin and one of which is in the second, then our arrangement can be represented as is (ball, ball, wall, ball, wall).  The total number of possible orderings of $M-1$ balls and $N$ walls is $(N+M-1)!$.  But we must also take into account the fact that all the balls are identical, so we divide this by $N!$, and all the walls are identical, so we divide also by $(M-1)!$ since these are the number of indistinguishable arrangements of balls and walls, respectively.  So the number of possible states for indistinguishable particles with unlimited occupancy is then:
\begin{equation}
\Omega_{\mathrm{unlimited,\ identical}} = \frac{(N+M-1)!}{(M-1)!N!}
\end{equation}

For the single occupancy case, the problem is a little bit easier to understand.  The number of possible ways to put the golf balls into their slots must be the same as when we can tell them apart, except that now the ordering of the golf balls is irrelevant, since we don't know which one is which.  Since there are $N!$ possible ways to order $N$ golf balls, we must divide the number of states for distinguishable golf balls by this count in order to avoid multiple counting of identical states.  So
\begin{equation}
\Omega_{\mathrm{single,\ identical}} = \frac{\Omega_{\mathrm{single,\ distinct}}}{N!} = \frac{M!}{(M-N)!N!}
\end{equation}
For the dilute case, the result is similar since the particles don't stack: just take the distinguishable particle result and divide by $N!$:
\begin{equation}
\Omega_{\mathrm{dilute,\ identical}} = \frac{\Omega_{\mathrm{dilute,\ distinct}}}{N!} = \frac{M^N}{N!}
\end{equation}
(You can't do this for the unlimited occupancy case because if the particles are stacked in some of the bins it is not easy to count their different orderings, and the result will not simply be $N!$.)

\subsection{Some rambling}
A useful approximation for understanding the relationship between the single occupancy and dilute cases is the fact that $\ln(n!)\approx n\ln(n)-n$ for very large values of $n$.  Then the entropy of the single-occupancy case for $M>>N$ is:
\begin{eqnarray*}
\sigma_{\mathrm{single,\ distinct}} &=& \ln(M!)-\ln((M-N)!)\\
 &\approx& (M\ln(M)-M) - ((M-N)\ln(M-N) - (M-N))\\
 &=& M\ln(M) - (M-N)\ln(M-N) - N\\
 &\approx& M\ln(M) - (M-N)\ln(M) = N\ln(M)
\end{eqnarray*}
and thus the number of states for $M>>N$ is:
\begin{equation}
\Omega_{\mathrm{single,\ distinct}} = e^{\sigma_{\mathrm{single,\ distinct}}} \approx M^N
\end{equation}
The results are similar for the identical particle case.

In many state-counting problems, you will have two separated subsystems which interact only through the exchange of a single parameter.  For example, they may be separated by a sliding divider, so that the total system volume is always $V$, and if subsystem 1 has volume $V_1$, then subsystem 2 has volume $V_2 = V-V_1$.  The particles in each subsystem are restricted to remain in that subsystem ($N_1$ and $N_2$ are constant), and only the volume distribution between the two systems can change.  The particles in one subsystem may distinguishable while the others are identical, or may have unlimited occupancy while the other is single-occupancy, and so forth.  The systems may be treated separately for particular values of the exchanged parameter ($V1$, $V2$), and then joint system probabilities and state counts computed as a product of those in the individual subsystems.  Their joint entropy is, of course, a \emph{sum} and not a product of their individual entropies.

\section{Units}
Just a usage note on units.  They're one of the easiest things in the world to screw up.  The SI system of units is basically an expanded metric system.  So any unit which can be constructed from a few basic metric units (meters, kilograms, seconds, Coulombs, Kelvins) is going to be part of the SI system.  The relevant SI units for this course are:

\begin{tabular}{|l||l|c|c|p{6.6cm}|}\hline
Type & Name & Abbrev. & SI base & Non-SI Alternate Units\\ \hline\hline
length & meters & m & m & --- \\ \hline
time & seconds & s & s & ---\\ \hline
mass & kilograms & kg & kg & \parbox{6.6cm}{proton masses = $m_p$\\ = atomic mass units = AMU\\ = $1.673\cdot10^{-27}$ kg}\\ \hline
temperature & Kelvins & K & K & \parbox{6.6cm}{degrees Celsius, degrees Fahrenheit:\\ $-273.15\,^\circ$C = $-459.67\,^\circ$F = 0 K}\\ \hline
volume & --- & m${}^3$ & m${}^3$ & liters = L = $10^{-3}$ m${}^3$\\ \hline
pressure & Pascals & Pa = N/m${}^2$ & kg/m-s${}^2$ & \parbox{6.6cm}{atmospheres = atm = $1.013\cdot10^5$ Pa}\\ \hline
energy & Joules & J = N-m & kg-m${}^2$/s${}^2$ & \parbox{6.6cm}{electron-Volts = eV = $1.602\cdot10^{-19}$ J,\\ liter-atmospheres = L-atm = $101.3$ J}\\ \hline
energy flow & Watts & W = J/s & kg-m${}^2$/s${}^3$ & ---\\ \hline
number density & --- & --- & m${}^{-3}$ & ---\\ \hline
\parbox{2.6cm}{entropy,\\ heat capacity} & --- & --- & J/K & ---\\ \hline
\end{tabular}

If you are given a problem containing non-SI units, then you need to very carefully check \emph{all} the units of \emph{all} the numbers you use to solve it (including constants off the equation sheet), and also the units of your answer, to make sure they are correct.  One possible way to do this is to convert all of your given numbers and constants to SI, compute the answer in SI units, and then convert it back to whatever units the problem requests.  The other possible solution is to include the units in your computation, and make sure that they cancel or insert the appropriate conversion factors to cause them to cancel.

Also, don't forget that you may need to convert between units of ``moles'' and units of ``particles''.  The conversion there is:
\begin{equation}
1\ \mathrm{mole} = 6.022\cdot10^{23}\ \mathrm{particles}
\end{equation}

And that's that.
\end{document}
