New research explains how gold and other heavy elements are created in space when stars collapse or collide, solving a long-standing mystery.