Calculating work done on an ideal gas I am trying to calculate the work done on an ideal gas in a piston set up where temperature is kept constant.  I am given the volume, pressure and temperature.
I know from Boyle's law that volume is inversely proportional to pressure that is,
$$V \propto \frac{1}{p}$$
using this I can calculate the two volumes I need for this equation to calculate work done:
$$\Delta W = - \int^{V_2}_{V_1} p(V)dV$$
but what I do not understand is how to use this equation to help me calculate the work done, I think I am confused by the fact that I need to have $p(V)$ but I am not sure what this is.  If you could help me to understand this, that would be great
 A: Try the ideal gas law
$$ p V = N k_B T \Leftrightarrow p = N k_B \frac{T}{V} $$
since $N$, $k_B$ and $T$ are constant, we have
$$ \Delta W = - N k_B T \int_{V_1}^{V_2} \frac{\textrm{d}V}{V} = - N k_B T \left( \ln(V_2) - \ln(V_1)\right) $$
A: The answer by Claudius is correct with one assumption:  That is that the process is reversible.  In other words the process must take place so slowly that the system is always in equilibrium.
Why is this important?  Because the definition of work is really
$$W = -\int_{V_1}^{V_2} p_{ext} dV$$
Note the $p_{ext}$.  That's the external pressure because doing work is equivalent to raising a weight in the earth's gravitational field.
In a reversible process the external and internal pressures are always equal, so one can use $p = nRT/V$, where $p$ here is the internal pressure, in place of the external pressure.
In nonequilibrium situations one has to know how $p_{ext}$ varies with the volume of the system.  And usually we don't.  For instance, expansion against zero pressure does no work, while expansion against a constant external pressure does $$W = -p_{ext} (V_2 - V_1)$$ work.  Can you see why?
