Code Optimization in FORM
J. Kuipers, T. Ueda, J. A. M. Vermaseren
TL;DR
The paper tackles the challenge of speeding up numerical evaluation of large symbolic expressions by optimizing output code in FORM. It introduces a generic optimization pipeline that combines Monte Carlo tree search for multivariate Horner schemes with classical techniques like common subexpression elimination, greedy optimizations, partial factorization, and recycling of temporaries. Empirical results on physics formulas and large resultants show substantial reductions in operation counts and improved compiled performance, with the caveat that tuning parameters such as $C_p$ and Horner direction is important and problem-dependent. The work demonstrates the viability of generic, domain-agnostic optimization in symbolic computation and outlines avenues for automatic parameter tuning and domain-specific pre-processing in future versions of FORM.
Abstract
We describe the implementation of output code optimization in the open source computer algebra system FORM. This implementation is based on recently discovered techniques of Monte Carlo tree search to find efficient multivariate Horner schemes, in combination with other optimization algorithms, such as common subexpression elimination. For systems for which no specific knowledge is provided it performs significantly better than other methods we could compare with. Because the method has a number of free parameters, we also show some methods by which to tune them to different types of problems.
