SymPy-to-Torch conversion and numerical integration helpers.
Note: this module was first developed for libphysics (and remains compatible): https://github.com/ferhatpy/libphysics under the name libtorch.py — then it was split out into a standalone library.
pip install -e .
pip install libsymtorchimport symtorch
import sympy as sp
x = sp.Symbol("x", real=True)
expr = sp.Integral(sp.exp(-x**2), (x, -sp.oo, sp.oo))
lt = symtorch.SymTorch()
texpr = lt.torchify(expr)
re, im = texpr.torchquad_integrate(N=121)
print(re, im)