# Why does this derivation of the dependence of free energy on pressure not work?

It is well known that the Gibbs Free Energy of a gas depends on the pressure via the following formula: $$G_m(p) = G^\circ_m + RT\ln{\frac{p}{p^{\circ}}}$$ Where $G_m$ is the molar gibbs free energy of a gas, $G^\circ_m$ is the molar free energy under standard conditions, $p$ is the pressure of the gas and $p^\circ$ is the pressure at standard conditions.

A heuristic qualitative argument for this formula goes as follows: Suppose that a fixed number of gas molecules expand isothermally. The gas increases in entropy since each molecule has more available positions. Since $\Delta G_m = \Delta H_m - T \Delta S$, an increase in entropy implies a decrease in free energy. Therefore isothermal expansion decreases the free energy of a gas. Furthermore since under constant temperature, pressure is inversely proportional to volume, an decrease in pressure also decreases the free energy, and the precise relationship is given by the above equation, which has a logarithm as entropy is logarithmic in the number of microstates.

Here is another argument which goes wrong since it gives the wrong answer but, I have no idea why it goes wrong. Suppose you increase the number of molecules of gas in a fixed volume, while keeping the temperature constant, then the pressure of the gas increases. The entropy increases because you have more molecules. The free energy decreases due to the increases in entropy. Therefore an increase in pressure decreases the free energy, a false conclusion.