Suppose that x is smaller than its equilibrium value. The upward force of the gas is greater than the downward force of the weight, and if allowed to freely move, the gas in the cylinder would push the weight upward rapidly, and there would be frictional forces that would convert the energy to heat. If we specify that an external agent presses down on the weight so as to very slowly (reversibly) allow the weight to move upward to its equilibrium position, then there will be no heat generated and the entropy of the system will remain constant while energy is transferred as work to the external agent. The total energy of the system at any value of x is given by the internal energy of the gas plus the potential energy of the weight: