Reversible and irreversible processes of thermodynamics My text book states the following:


(Edit:It should be p1/p2, sorry.)

My understanding of a reversible process is that it us a process that is executed so slowly that no energy would be dissipated at all and it is possible to bring it back to the original state again due to this.
(The classic jar and piston example)
An irreversible process is every other process.

I understood the derivation for work for reversible processes but for the irreversible process I am unable to relate to the formula.
Take the example of the jar again.
If we suddenly compress the gas, we are changing the external pressure, right? What would we substitute for p ext ? 
Also, how did this formula come and how does it accommodate the extra work we had to do that gets dissipated to get to the same state?

Please correct my understating if it
Is wrong.
For both reversible and irreversible processes, the pressure of the gas at the interface with the surroundings exactly matches the external pressure imposed by the surroundings $P_{ext}$, and the work done on the surroundings is always equal to $\int{P_{ext}}dV$.  (The equation you wrote for an irreversible process applies only if $P_{ext}$ is held constant).  However, for an irreversible process, the pressure of the gas at the interface is not given by the ideal gas law, because (a) there are viscous (dissipative) stresses that contribute to the pressure at the interface and (b) the pressure and temperature of the gas is not uniform within the cylinder.  So we need to specify how $P_{ext}$ varies during the process (say, as a function of the volume V) manually in order to analyze an irreversible process.  

For more details on this, see the following link:  Calculate Work Done for Reversible and Irreversible Adiabatic process