sympy2c: from symbolic expressions to fast C/C++ functions and ODE solvers in Python
Uwe Schmitt, Beatrice Moser, Christiane S. Lorenz, Alexandre Refregier

TL;DR
sympy2c is a Python package that converts symbolic equations from SymPy into optimized C/C++ code, enabling fast numerical solutions of complex systems like the Einstein-Boltzmann equations in cosmology.
Contribution
It introduces a novel method for generating optimized ODE solvers by exploiting Jacobian sparsity, bridging symbolic development and efficient numerical implementation.
Findings
Achieves significant performance improvements in solving Einstein-Boltzmann equations.
Demonstrates the effectiveness of symbolic transformations for code optimization.
Provides a widely applicable tool for computational physics applications.
Abstract
Computer algebra systems play an important role in science as they facilitate the development of new theoretical models. The resulting symbolic equations are often implemented in a compiled programming language in order to provide fast and portable codes for practical applications. We describe sympy2c, a new Python package designed to bridge the gap between the symbolic development and the numerical implementation of a theoretical model. sympy2c translates symbolic equations implemented in the SymPy Python package to C/C++ code that is optimized using symbolic transformations. The resulting functions can be conveniently used as an extension module in Python. sympy2c is used within the PyCosmo Python package to solve the Einstein-Boltzmann equations, a large system of ODEs describing the evolution of linear perturbations in the Universe. After reviewing the functionalities and usage of…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
