22.  Compilation:  Problems

Last revision:  April 15, 1998

Author: YourNameGoesHere

Compiling Arithmetic Expressions

Choose a sufficiently complicated arithmetic expression, using a combination of some of +, -, *, /, logarithms, exponentiation, trigonometric functions, and so on, and present timings showing that a compiled version of a function performs faster than a noncompiled, and therefore interpreted, version.

Speed Trade-offs

Discuss the tradeoffs from gaining speed by using (a) compiled code, (b) call-by-reference, and (c) inline functions instead of standard function calls.

Counting Machine Instructions

Define a function "machineCount[list,expr]" which counts the number of machine instructions the compiled version of "expr" with parameters "list" contains.  Hint:  in a Module, use "Compile[]" to compile the function into a local name, say "x"; then "Length[x[[3]]]" gives the number of instructions, since the third part of the compiled function is the list of the instructions.

Use your function to compare the lengths of the instructions needed in the compiled versions of several kinds of arithmetic expressions.