A 10 MeV/c positive muon beam was stopped in helium gas of a few mbar in a magnetic field of 5T. The muon 'swarm' has been efficiently compressed from a length of 16cm down to a few mm along the magnetic field axis (longitudinal compression) using electrostatic fields. The simulation reproduces the low energy interactions of slow muons in helium gas. Phase space compression occurs on the order of microseconds, compatible with the muon lifetime of 2μs. This paves the way for the preparation of a high- quality low-energy muon beam, with an increase in phase space density relative to a standard surface muon beam of 10
7. The achievable phase space compression by using only the longitudinal stage presented here is of the order of 10
4.