Chaotic mixing in charged-particle beams and galaxies