Wolfram Library Archive

All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

A Package For Code Optimization Using Mathematica

Mark Sofroniou
Organization: Wolfram Research, Inc.
Department: Kernel Technology
Old MathSource #

Revision date


The package Optimize.m provides an efficient (linear time) means of expression optimization for Mathematica. The term "optimization" is used in the sense of reducing the arithmetic operation count. For the most part only exact, or syntactic, sub-expressions are matched. For example: the x+y in (x+y)*f(x+y) is considered as common, but not in x+y+f(x+y). Code optimization has many applications including speeding up numerics and graphics, improving the performance of canonical simplification and reducing the memory required to represent/store an expression. Optimized procedures and compiled procedures are possible. The procedure Horner factors polynomials in Horner form, an efficient form for numerical evaluation. The procedure Cost gives a count of the operators present in an expression. Optimize.m can also be used in conjunction with the auxiliary package Format.m (item 60) to produce optimized C and FORTRAN statement sequences.

The package Optimize.m is now obsolete and has be replaced by the built-in function Experimental`OptimizeExpression since version 4.1 of Mathematica. The package Format.m no longer needs Optimize.m to create an optimized expression sequence.

*Mathematica Technology > Programming

Conversion, C, code optimization, fortran, sub-expressions
Related items

*C, FORTRAN77, Maple and TeX Code Generation Package   [in MathSource: Packages and Programs]

Downloads Download Wolfram CDF Player

Optimize.m (22.8 KB) - Mathematica Package

Translate this page: