Find a way to statically link against llvm and compile to real machine code
A simpler solution might be to check if the formula is some regular pattern and convert it to a more specialized node. For example, we could create dedicated Horner-form polynomial evaluation nodes from formulas that are just multivariate polynomials. There is some literature on multivariate Horner forms e.g. https://arxiv.org/abs/1207.7079 and an existing python package: multivar_horner.
The current formula implementation walks an AST on evaluation. The AST is not optimized beforehand. We could improve this in a few ways:
A simpler solution might be to check if the formula is some regular pattern and convert it to a more specialized node. For example, we could create dedicated Horner-form polynomial evaluation nodes from formulas that are just multivariate polynomials. There is some literature on multivariate Horner forms e.g. https://arxiv.org/abs/1207.7079 and an existing python package: multivar_horner.