Is there a performance difference in using Piecewise vs other conditionals in a function definition.
i.e. I have a function whose limit as x-> 0 is finite, but evaluates to Indeterminate when 0 is entered explicitly,
myfunc[x_] := (1-Exp[-x^2])/x
and I call upon this function quite a bit within Integrate calls.
Is there a difference in computation speed if the function is defined as
If seems to be faster than Piecewise for this specific example, but defining a separate downvalue is even faster, especially when you might be able to use a literal zero rather than PossibleZeroQ. Here are some example evaluations and timings: