text: If a container with an ideal gas is expanded instantaneously, the temperature of the gas doesn't change at all, because none of the molecules slow down. The molecules keep their kinetic energy, but now the gas occupies a bigger volume. If the container expands slowly, however, so that the ideal gas pressure law holds at any time, gas molecules lose energy at the rate that they do work on the expanding wall. The amount of work they do is the pressure times the area of the wall times the outward displacement, which is the pressure times the change in the volume of the gas:
  If no heat enters the gas, the energy in the gas molecules is decreasing by the same amount. By definition, a gas is ideal when its temperature is only a function of the internal energy per particle, not the volume. So
  where  is the specific heat at constant volume. When the change in energy is entirely due to work done on the wall, the change in temperature is given by
  This gives a differential relationship between the changes in temperature and volume, which can be integrated to find the invariant. The constant  is just a unit conversion factor, which can be set equal to one:
  So 
  is an adiabatic invariant, which is related to the entropy 
  Thus entropy is an adiabatic invariant. The N log(N) term makes the entropy additive, so the entropy of two volumes of gas is the sum of the entropies of each one.
  In a molecular interpretation, S is the logarithm of the phase-space volume of all gas states with energy E(T) and volume V.
  For a monatomic ideal gas, this can easily be seen by writing down the energy:
  The different internal motions of the gas with total energy E define a sphere, the surface of a 3N-dimensional ball with radius . The volume of the sphere is
  where  is the gamma function.
  Since each gas molecule can be anywhere within the volume V, the volume in phase space occupied by the gas states with energy E is  
  Since the N gas molecules are indistinguishable, the phase-space volume is divided by , the number of permutations of N molecules.
  Using Stirlings approximation for the gamma function, and ignoring factors that disappear in the logarithm after taking N' large, 
  Since the specific heat of a monatomic gas is 3/2, this is the same as the thermodynamic formula for the entropy.