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 (email@example.com) answers: This difference is a result of a change in the way that handles overflow and underflow. In Version 3.0, 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 . Compiled evaluation is faster for this example than uncompiled evaluation. Many of the terms in 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 with .