ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 18 Nov 2012 19:37:08 +0100speed and order of operations with CDFhttps://ask.sagemath.org/question/9545/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 loopmarcoSun, 18 Nov 2012 19:37:08 +0100https://ask.sagemath.org/question/9545/