The work done by a gas when it undergoes a state change from 1 → 2 isothermally is
nRTln(V2V1)
For an isothermal process T is constant.
Therefore from ideal gas equation we get -
pV = nRT
⇒ p=nRTV ...(1)
We know that the work done in any process can be calculated using -
W=∫pdV ...(2)
From (1) and (2) -
W=∫v2v1nRTVdV
=nRT∫v2v1dVV
W=nRTln(V2V1).