Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

2D plot performance

I have this function

    sage: f=imag(I*(sqrt(-cos(l) + 1)*cosh(sin(1/2*l)) - 
+ 1)^(3/2)*e^(1/2*I*l)))

i.m.h.o. this not something terribly complicated. I wanted to plot it. So I do

sage: time plot(f,l,0,10)
..nice plot..
Time: CPU 9.28 s, Wall: 9.41 s

I.e. I was waiting almost 10s for this (on an intel core duo CPU P9500 @ 2.53GHz) laptop!? I thought that maybe fast_callable would help:

sage: ff=fast_callable(f,vars=[l],domain=CC)
sage: time plot(ff,0,10)
..same nice plot..
Time: CPU 13.24 s, Wall: 13.50 s

So that's even worse. Now I compare to Mathematica

In[8]:= Timing[Plot[Im[(Sin[l/2]^3*(I*Sqrt[1 - Cos[l]]*Cosh[Sin[l/2]] - 
        I*Sqrt[2]*Sinh[Sqrt[Sin[l/2]^2]]))/(E^((I/2)*l)*(1 - 
         Cos[l])^(3/2))], {l, 0, 10}]]

Out[8]= {0.019997, ..same plot again..}

~500 times faster ... what am I doing wrong?