The mechanical work, W, performed upon a gas is given by
where and are points in state space, p is the pressure and V is the volume. The mechanical work done by the gas has the opposite sign (a common source of mistakes).
For reversible changes,
and for irreversible changes