Part a) The work done by the gas on the bullet is the integral of the force in dx, where x is the distance covered by the bullet inside the barrel with respect to the origin: By substituting the length of the barrel, L=0.540 m, we find the total work done by the gas on the bullet:
part b) The resolution of the problem is the same, we just have to use the new length of the barrel (L=0.95 m) inside the final formula, and we find the new value of the work: