text: NOTE: The equations provided below are only correct when rarefaction takes place on left side of domain and shock happens on right side of domain.
  The different states of the solution are separated by the time evolution of the
  three characteristics of the system, which is due to the finite speed
  of information propagation. Two of them are equal to the speed
  of sound of the left and right states
  where  is the adiabatic gamma.
  The first one is the position of the beginning of the rarefaction wave while
  the other is the velocity of the propagation of the shock.
  Defining:
  The states after the shock are connected by the Rankine Hugoniot
  shock jump conditions.
  But to calculate the density in Region 4 we need to know the pressure in that region.
  This is related by the contact discontinuity with the pressure in region 3 by
  Unfortunately the pressure in region 3 can only be calculated iteratively, the right
  solution is found when  equals 
  This function can be evaluated to an arbitrary precision thus giving the pressure in the
  region 3
  finally we can calculate
  and  follows from the adiabatic gas law