# Entropy and Temperature

Eliezer Yudkowsky [previously wrote](/lw/o5/the_second_law_of_thermodynamics_and_engines_of/) (6 years ago!) about the second law of thermodynamics. Many commenters were skeptical about the statement, "if you know the positions and momenta of every particle in a glass of water, it is at absolute zero temperature," because they don't know what temperature is. This is a common confusion.

**Entropy**

To specify the precise state of a classical system, you need to know its location in phase space. For a bunch of helium atoms whizzing around in a box, phase space is the position and momentum of each helium atom. For _N_ atoms in the box, that means 6_N_ numbers to completely specify the system.

Lets say you know the total energy of the gas, but nothing else. It will be the case that a fantastically huge number of points in phase space will be consistent with that energy.* In the absence of any more information it is correct to assign a uniform distribution to this region of phase space. The entropy of a uniform distribution is the logarithm of the number of points, so that's [that](http://en.wikipedia.org/wiki/Boltzmann%27s_entropy_formula). If you also know the volume, then the number of points in phase space consistent with both the energy and volume is necessarily smaller, so the entropy is smaller.

This might be confusing to chemists, since they memorized a [formula](http://hyperphysics.phy-astr.gsu.edu/hbase/therm/entropgas.html) for the entropy of an ideal gas, and it's ostensibly objective. Someone with perfect knowledge of the system will calculate the same number on the right side of that equation, but to them, that number isn't the entropy. It's the entropy of the gas if you know nothing more than energy, volume, and number of particles.

**Temperature**

The existence of temperature follows from the zeroth and second laws of thermodynamics: thermal equilibrium is transitive, and entropy is maximum in equilibrium. Temperature is then defined as the thermodynamic quantity that is the shared by systems in equilibrium.

If two systems are in equilibrium then they cannot increase entropy by flowing energy from one to the other. That means that if we flow a tiny bit of energy from one to the other (_δU_~1~ = -_δU_~2~), the entropy change in the first must be the opposite of the entropy change of the second (_δS_~1~ = -_δS_~2~), so that the total entropy (_S_~1~ \+ _S_~2~) doesn't change. For systems in equilibrium, this leads to (_∂S_~1~/_∂U_~1~) = (_∂S_~2~/_∂U_~2~). Define 1/_T_ = (_∂S_/_∂U_), and we are done.

Temperature is sometimes taught as, "a measure of the average kinetic energy of the particles," because for an ideal gas _U_/_N _= (3/2) _k~B~T_. This is wrong as a definition, for the same reason that the ideal gas entropy isn't the definition of entropy.

Probability is in the mind. Entropy is a function of probabilities, so entropy is in the mind. Temperature is a derivative of entropy, so temperature is in the mind.

**Second Law Trickery**

With perfect knowledge of a system, it is possible to extract all of its energy as work. EY states it clearly:

> So (again ignoring quantum effects for the moment), if you _know_ the states of all the molecules in a glass of hot water, it is cold in a genuinely thermodynamic sense: you can take electricity out of it and leave behind an ice cube.

Someone who doesn't know the state of the water will observe a violation of the second law. This is allowed. Let that sink in for a minute. Jaynes calls it [second law trickery](http://bayes.wustl.edu/etj/articles/gibbs.paradox.pdf), and I can't explain it better than he does, so I won't try:

> A physical system always has more macroscopic degrees of freedom beyond what we control or observe, and by manipulating them a trickster can always make us see an apparent violation of the second law.
> 
> Therefore the correct statement of the second law is not that an entropy decrease is impossible in principle, or even improbable; rather that it _cannot be achieved reproducibly by manipulating the macrovariables {X~1~, ..., X~n~} that we have chosen to define our macrostate._ Any attempt to write a stronger law than this will put one at the mercy of a trickster, who can produce a violation of it.
> 
> But recognizing this should increase rather than decrease our confidence in the future of the second law, because it means that if an experimenter ever sees an apparent violation, then instead of issuing a sensational announcement, it will be more prudent to search for that unobserved degree of freedom. That is, the connection of entropy with information works both ways; seeing an apparent decrease of entropy signifies ignorance of what were the relevant macrovariables.

**Homework**

I've actually given you enough information on statistical mechanics to calculate an interesting system. Say you have _N_ particles, each fixed in place to a lattice. Each particle can be in one of two states, with energies 0 and ε. Calculate and plot the entropy if you know the total energy: _S_(_E_), and then the energy as a function of temperature: _E_(_T_). This is essentially a combinatorics problem, and you may assume that _N_ is large, so use Stirling's approximation. What you will discover should make sense using the correct definitions of entropy and temperature.

* * *

*: How many combinations of 10^23 ^numbers between 0 and 10 add up to 5×10^23^?