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')
timeit('f(4+2*I)')
625 loops, best of 3: 2.94 µs per loop
timeit('g(4+2*I)')
625 loops, best of 3: 5.87 µs per loop
Non-fast_callable times, in case you are interested:
z = var('z')
fs(z) = exp(z).abs()
gs(z) = exp(z.real())
timeit('fs(4+2*I)')
625 loops, best of 3: 1.02 ms per loop
timeit('gs(4+2*I)')
625 loops, best of 3: 988 µs per loop