In engines, a gas is often employed to perform work through gas expansion or pressure-volume work.

Infinitesimal work output by the gas for an infinitesimal piston displacement dy is given by:

$$\begin{aligned} dW_{\text{out}} &= F \, dy \\ &= PA \, dy \\ &= P \, dV \end{aligned}$$

, where

F is the force exerted by the gas on the piston

y is the outward piston displacement

P is gas pressure

A is piston area

V is gas volume

Conversely, infinitesimal work input to the gas is given by: dW_{in} = -dW_{out}

The work output for a finite volume change from V_{i} V_{f} is:

$$\begin{aligned} W_{\text{out}} &= \int\limits_{1}^{2} dW_{out} \\ &= \int\limits_{V_{1}}^{V_{2}} P \, dV \end{aligned}$$

Geometrically, this is simply the area under the PV curve that represents the piston process, integrated from start volume V_{1} to end volume V_{2}

If piston opens, i.e., V_{2} > V_{1}, W_{out} > 0.

If piston closes, i.e., V_{2} < V_{1}, W_{out} < 0.