speed and order of operations with CDF
Why is the absolute value of the exponential of z:
f = fast_callable(exp(z).abs(),domain=CDF,vars='z')
about twice as fast as the exponential of the real part of z:
g = fast_callable(exp(z.real()), domain=CDF, vars='z')
Should I ignore this kind of thing in sage, or is there a good reason in this particular case?
Data:
z = var('z')
f = fast_callable(exp(z).abs(),domain=CDF,vars='z')
g = fast_callable(exp(z.real()), domain=CDF, vars='z')
fs(z) = exp(z).abs()
gs(z) = exp(z.real())
sage: timeit('f(4+2*I)')
625 loops, best of 3: 2.94 µs per loop
loop
sage: timeit('g(4+2I)')
timeit('g(4+2*I)')
625 loops, best of 3: 5.87 µs per loop
loop
sage: timeit('fs(4+2I)')
timeit('fs(4+2*I)')
625 loops, best of 3: 1.02 ms per loop
loop
sage: timeit('gs(4+2*I)')
625 loops, best of 3: 988 µs per loop