Here's the textbook way of calculating the work done by an ideal gas in an isothermal case. PV=nRT P.dV=(nRT/V).dV ∴ ∫P.dV=nRT∫dV/V → W2-W1=nRT*ln(V2/V1) My question. Consider a cylindrical (or of any other shape) container of surface area A and a frictionless movable piston attached. Let the coordinate x run along the length of this container, with origin at the bottom of the container. Let the piston be at some x at some point of time. At this x, P.V= constant = nRT This holds for all x. Now since V(x)=A.x P(x)=constant/A.x=K/x .... for some contant k (=nRT/A) Now P and V are both functions of x. While calculating the infinitesimal work P.dV, how can we treat P(x) constant over the range dx? Instead, since P(x)V(x)=constant differentiating both sides, d[P(x)V(x)]=0 → V(x).dP + P(x).dV=0 ∴ P(x).dV= -V(x).dP Shouldn't this relation hold? I ask this because I was solving a similar problem, although which wasn't isothermal, involved P and V that depended on x and the approach used there was the second one.