Orbital dynamics wizardry helped save NASA’s next Mars mission