# Entropy/entropy example 2

Consider a physical system consisting of an ideal gas enclosed in a cylindrical container of volume 1. The equilibrium state \(B\) is the state of maximal entropy. This is clearly the state where both pressure and temperature are constant (say, \(P_0\) and \(T_0\), respectively) throughout the container. Any other state can be achieved only with help from outside.

Suppose one places a piston at position \(p<\frac12\) in the cylinder
(see Figure <ref>F1</ref>; thermodynamically, this is still the state \(B\)) and then slowly moves
the piston to the center of the cylinder (position \(\frac12\)), allowing heat to flow between the cylinder and
its environment. Assume the temperature outside is held at \(T_0\), which stabilizes the temperature inside the cylinder at \(T_0\) during the entire time the piston is moving. Let \(A\) be the final state (see Figure <ref>F2</ref>). It is important that the states \(A\) and \(B\) have the same total energy inside the system; it is just distributed differently on the two sides of the piston. Indeed, if in the state \(A\), the piston is removed perpendicularly to the forces (upwards), which does not use nor return any work, then the system immediately returns to the state \(B\). Although it seems that work
has been delivered to the system, the equivalent amount of heat was emitted into the environment. The potential energy
of the piston is precisely the energy that was made *available to do work* by lowering the entropy, and not by adding
any energy.

To compute the jump of entropy one needs to examine what exactly happens during the passage. The force acting on the piston at position \(x\) is proportional to the difference between the pressures:

\[ F=c\left( P_0\frac{1-p}{1-x}-P_0\frac{p}{x} \right). \]

Thus, the work done while moving the piston equals:

\[ W =\int\limits_p^{\frac1{2}}F\,dx=c P_0 [(1-p)\log(1-p)+p\log p+\log 2]. \]

The function \(k(p) = (1-p)\log(1-p)+p\log p\) is negative and assumes its minimal value \(-\log 2\) at \(p=\frac 12\) (see Figure <ref>F3</ref>).

Thus the above work \(W\) is positive and represents the amount of energy delivered to the system from outside. During the process the compressed gas on the right emits heat, while the expanded gas on the left absorbs heat. By conservation of energy (applied to the enhanced system including the outside world), the gas in the two compartments will emit heat to the environment equivalent to the delivered work \(\Delta Q = -W\). Since the process is isothermal (the temperature is constant all the time), the change in entropy between states \(B\) and \(A\) of the gas is simply \(\frac 1{T_0}\) times \(\Delta Q\), i.e.,

- <math deltas>

\Delta S=\frac1{T_0} \cdot c P_0 [-(1-p)\log(1-p)-p\log p-\log 2]. </math>

Clearly \(\Delta S\) is negative. This confirms what was already expected, that the outside intervention has lowered the entropy of the gas.

This example illustrates very clearly Boltzmann's interpretation of entropy. Assume that there are \(N\) particles of the gas independently wandering inside the container. For each particle the probability of falling in the left or right half of the container is \(\frac 12\). The system can thus be modeled by a series of \(N\) independent coin tossings with a particle falling in the left or right half interpreted as heads and tails, respectively. The state \(A\) of the gas occurs spontaneously if there are \(pN\) heads and \((1-p)N\) tails. By elementary combinatorics formulas the probability of finding a system in state A equals

\[ {Prob}(A) = \frac{N!}{(pN)!((1-p)N)!} 2^{-N}. \]

By Stirling's formula (\(\log n!\approx n\log n-n\) for large \(n\)), the logarithm of \({Prob}(A)\) equals approximately

\[ N[-(1-p)\log(1-p)-p\log p - \log 2], \]

which is indeed proportional to the drop \(\Delta S\) of entropy between the states \(B\) and \(A\) (see (<ref>deltas</ref>) above).