Compilation of dynamical systems