Deriving the Gibbs–Duhem equation from the fundamental thermodynamic equation is straightforward. The total differential of the extensive Gibbs free energy  in terms of its natural variables is
Since the Gibbs free energy is the Legendre transformation of the internal energy, the derivatives can be replaced by their definitions, transforming the above equation into:
The chemical potential is simply another name for the partial molar Gibbs free energy (or the partial Gibbs free energy, depending on whether N is in units of moles or particles). Thus the Gibbs free energy of a system can be calculated by collecting moles together carefully at a specified T, P and at a constant molar ratio composition (so that the chemical potential doesn't change as the moles are added together), i.e.
The total differential of this expression is
Combining the two expressions for the total differential of the Gibbs free energy gives
which simplifies to the Gibbs–Duhem relation: