Automatic Program Generation from a Computer
Algebra System: Efficiency and Correctness
Gaston Gonnet
Computer Algebra systems have been used for quite some time to generate programs (or at least portions of programs) automatically. Early work was almost exclusively done in order to generate derivatives, a job which was seen as tedious and error prone. This job was so important that a new discipline grew out of it: Automatic Differentiation. In recent times researchers and programmers realized that there are several other advantages to automatic code generation. In this talk we would like to support our case by giving examples from a molecular dynamics protein structure solver. The main advantages of automatic code generation (typically from a computer algebra system) are: - Correctness, which has to be considered at various levels: - Routine manipulations, like differentiation - Derivation of formulas from a more fundamental statement of the problem - Errors in the automatic code generation tend to be catastrophic and hence much easier to detect. - Efficiency - Various mathematical transformations can be used to optimize code. - Usually the optimizations done are beyond the capabilities of even good compilers. - Code integration, macro expansion, in-lining. - Programming time saved - Numerical stability, detection and reporting of numerical problems. - Singularities, discontinuities, etc. - Increased reliability by being able to solve the same problem in two completely different environments.