Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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?

Here is the data: without fast_callable, these functions take exactly the same amount of time, for example on 4 + 2i they take about 1 second (!!!). With fast_callable, f takes 2.99 µs, and g takes 6.23µs

click to hide/show revision 3
corrected "second" mistake but the question remains

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?

Here is the data: 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 without fast_callable, these functions take exactly the same amount sage: timeit('g(4+2I)') 625 loops, best of time, for example on 4 + 2i they take about 1 second (!!!). 3: 5.87 µs per loop With fast_callable, f takes 2.99 µs, and g takes 6.23µs sage: timeit('fs(4+2I)') 625 loops, best of 3: 1.02 ms per loop sage: timeit('gs(4+2*I)') 625 loops, best of 3: 988 µs per loop

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

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

sage: timeit('g(4+2*I)')

625 loops, best of 3: 5.87 µs per loop

sage: timeit('fs(4+2*I)')

Incidentally, here are the non-fast_callable times: 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

sage: timeit('gs(4+2*I)')

625 loops, best of 3: 988 µs per loop

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

Incidentally, here


Non-fast_callable times, in case you are the non-fast_callable times: interested:

z = var('z')
 fs(z) = exp(z).abs()
 gs(z) = exp(z.real())
    timeit('fs(4+2*I)')

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