The roaming mechanism in the reaction H + MgH → Mg + HH is investigated
by classical and quantum dynamics employing an accurate ab initio 3-dimensional ground electronic state potential energy surface. The reaction dynamics are explored by running trajectories initialized on a 4-dimensional dividing surface anchored on 3-dimensional normally hyperbolic invariant manifold associated with a family of unstable orbiting periodic orbits in the entrance channel of the reaction (H + MgH). By locating periodic orbits localized in the HMgH well or involving H orbiting around the MgH diatom, and following their continuation with the total energy, regions in phase space where reactive or non-reactive trajectories may be trapped are found. In this way roaming reaction pathways are deduced in phase space. Patterns similar to periodic orbits projected into conguration space are found for the quantum bound and resonance eigenstates. Roaming is attributed to the capture of the trajectories in the neighborhood of certain periodic orbits. The complex forming trajectories in the HMgH well can either return back to the radical channel or 'roam' to the MgHH minimum from where the molecule may react.