CompiledFunction in 3.0

Q: Version 3.0 sometimes takes considerably longer to generate plots than Version 2.2. For example:




Evaluating the same expression in Version 2.2 is about eight times faster. Why is version 3.0 so much slower?

David Withoff ( answers: This difference is a result of a change in the way that [Graphics:inoutgr92.gif] handles overflow and underflow. In Version 3.0, [Graphics:inoutgr93.gif] switches to uncompiled evaluation in cases of machine overflow or underflow.


In Version 2.2, the same input would evaluate to zero.

The compiler is called automatically from [Graphics:inoutgr98.gif]. Compiled evaluation is faster for this example than uncompiled evaluation. Many of the terms in [Graphics:inoutgr99.gif] generate machine underflow within the range of the plot. Version 2.2 just replaces these terms with zero and continues with compiled evaluation, which is often wrong, but which is probably fine in this example. Version 3.0 is more careful; it switches to uncompiled evaluation when it detects underflow, but that extra care has the unfortunate side effect of making this calculation slower.

One workaround is to replace all of the expressions that might cause overflow or underflow with conditional expressions. For example, one could replace [Graphics:inoutgr100.gif] with [Graphics:inoutgr101.gif].