enter image description here

The work done by a gas on a piston, by definition:

$$W_{gas} = \int \vec{F} \cdot \vec{dr}$$

Where $\vec{F}$ is the net force on the piston, $\vec{dr}$ is the infinitesimal displacement of this piston.

Since the force on the piston, is against the direction of displacement (for my coordinate system), F and dr are in opposite directions hence the work done on the gas

$$W_{gas} = \int -|F||dr|$$

Assuming that I move my piston in the purely x direction

$$W_{gas} = \int -|F|dx$$

I then move my piston from its initial position relative to my coordinates, to a distance x, thus the work done by the gas on the piston is

$$W_{gas} = \int_{0}^{x} -|F|dx$$

Therefore, the negative of this quantity is the work done by the piston on the gas (work done on the gas):

$$W = \int_{0}^{x} |F|dx$$

Let's forget about converting this into a pressure volume integral for simplicity

From here I am having trouble reconciling the standard formula for the work done on a gas.

$$W= -\int_{v_{i}}^{v_{f}} \rho dv$$

This converted into linear form is

$$W=-\int_{l_{1 I}}^{l_{f}} |F| dx$$

Let's take a look at the different formulas.

$$W = \int_{0}^{x} |F|dx$$

$$W=-\int_{l_{i}}^{l_{f}} |F| dx$$

One is integrating from the pistons initial position, to the pistons final position.

One is integrating from the remaining length when the piston is at its starting position, to the remaining length when the piston has extended.

(Much like the volume form is the remaining volume, and the remaining volume after the piston extends)

From first principles, the one that I derived, only matches the given formula given that $\rho$( and therefore F) is constant.

$$\int_{0}^{x} |F|dx = -\int_{l_{1 I}}^{l_{f}} |F| dx$$

$$|F|x - |F|0 = |F|(l_{i} -l_{f})$$

From the diagram $l_{i} -l_{f} = x$

$$|F|x = |F|x$$

The formulas differ when F is not constant.

Which formula is correct? Have i made any mistakes?

  • $\begingroup$ "Since the force on the piston, is against the direction of displacement (for my coordinate system)" The external force is in the same direction as the displacement making the work positive. $\endgroup$
    – Bob D
    Dec 18, 2022 at 16:27
  • $\begingroup$ The formulas don’t differ. You used F for the force in each, but they aren’t generally the same. When F is correctly written as a function of distance, the formulas are identical. $\endgroup$ Dec 18, 2022 at 17:08
  • $\begingroup$ Could you show me a derivation? $\endgroup$ Dec 18, 2022 at 18:17

3 Answers 3


The general expression for work:

$$W=\int_{xi}^{xf}\vec F\cdot \vec {dx}\tag{1}$$

Since the force $\vec F$ is in the same direction as $\vec {dx}$ (i.e., $\theta=0$), the work is simply $\int Fdx$. Then, for a piston of cross section area $A$ and the pressure $P=F/A$. A differential change in volume is $dV=Adx$, or $dx=dV/A$. Substituting these into equation (1)


Work done by the system (gas)is negative if the final volume is less than the initial (compression work) and positive if the final volume is greater than the initial (expansion work).

Hope this helps.

  • $\begingroup$ Your integral in your expression does not match your explanation of it. Your formula says that work is negative when there is a decrease in volume , via your own condition that the force is in the same direction as the displacement. The formula that is in my text book is $$-\int_{vi}^{vf} \rho dv$$. You also don't actually prove the 'general expression for work', the bounds of the integral should be the displacement of the piston which isn't vi to vf,but 0 to the final displacement, which is what my entire question focuses on $\endgroup$ Dec 18, 2022 at 17:53
  • $\begingroup$ You start with the assumption that $$\int_{v_{i}}^{v_{f}} \vec{F} \cdot \vec{dr} $$ is the correct formula for the work in this situation. If a piston moves through a displacement 0 to x, through a vector field, then the amount of work done BY that vector field on that piston is $$\int_{0}^{x} \vec{F} \cdot \vec{dr}$$ This vector field, ( the force created by the gas not an "external force") is against the direction of displacement. Thus the amount of work done BY THE GAS on the piston, is $$\int_{0}^{x} - |F| dx$$ --> $\endgroup$ Dec 18, 2022 at 18:08
  • $\begingroup$ Much like when dealing with potentials, the amount of work done against the gas ( energy imparted to the gas) is the negative of this quantity. Aka $$\int_{0}^{x} |F|dx $$ when there is a positive displacement of the piston ( aka remaining gas volume is smaller) then the work done against the gas is positive. $\endgroup$ Dec 18, 2022 at 18:11
  • $\begingroup$ This formulation, is different from the given formula integrated about the initial volume and final volume. Since the volume in consideration is the volume traversed by the piston, not the final and initial volume of gas. The minus sign is important as this makes the whole expression positive, which means that the work is positive when there is a decrease in remaining volume ( x being positive). $\endgroup$ Dec 18, 2022 at 18:15
  • $\begingroup$ Can you please show the derivation of the work done on a gas formula described in your first line, As starting with an integral of these bounds doesn't make much sense. With the equation in question,being the one in my text book, that $$W=- \int_{v_{i}}^{v_{f}} \rho dv$$ $\endgroup$ Dec 18, 2022 at 18:18

The formulas differ when F is not constant.

Specifically, they differ when $F$ is a function of $x$. Otherwise, as you note, $F$ can be brought outside the integral and the difference $l_{i}-l_{f}$ replaced with the identical difference $x-0$.

And of course we do expect the resistance $F$ to depend on the compression $x$ when we compress a material. The apparent paradox arises because you've used $F$ to refer to two different functions: $F(x,0)$ and $F(l_{i},l_{f})$. They aren't the same because you've measured $l$ increasing leftward from the right end of the container and $x$ moving rightward from the left end of the container. These inputs to $F$ differ by an offset and by a sign, which makes the integrals appear to differ as well.

If you formulate $F$ appropriately for one of these coordinate systems (say, $F(l)=\frac{nRT}{L-l_i+l_f}$, using the ideal gas law, where $L$ is the total container length), then you can always apply a coordinate transformation to $F$ and to the limits of integration to work in another coordinate system, obtaining identical results for the work done.


I think that your confusion is down to your choice of variables.

Let the system be the gas inside the cylinder/piston.

Rather than $L_{\rm f}$ I would like to introduce the variable $\ell$ such that $x=L_{\rm i} - \ell$.
If one differentiates this expression one gets $dx = -d\ell$.

The change of volume of the gas is $d\ell \,A = -dx\,A$ where $A$ is the area of the piston.
Note that $dx\,A$ is the change in volume outside the system.

Let $\hat \ell$ be the unit vector pointing to the left in your diagram and displacement $\vec \ell$ be measured from the right-hand end of the cylinder.

The work done by the gas undergoing a change from $\ell =L_{\rm i}$ to $\ell = L_{\rm f}$ is $\displaystyle \int^{L_{\rm f}}_{L_{\rm i}}\vec F_{\rm gas}\cdot d\vec \ell = \int^{L_{\rm f}}_{L_{\rm i}}F_{\rm gas}\,\hat \ell\cdot d\ell \,\hat\ell = \int^{L_{\rm f}}_{L_{\rm i}}F_{\rm gas}\,d\ell$.

With a change of variable, $x=L_{\rm i} - \ell$, work done by gas becomes $\displaystyle -\int^{x_{\rm f}}_0F_{\rm gas}\,dx$.

Another possible change of variable is $V= A\,\ell \Rightarrow dV = A\,d\ell$ and the work done by the gas becomes $\displaystyle \int^{V_{\rm f}}_{V_{\rm i}}P\,dV$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.