On Wed, Nov 25, 2009 at 6:47 PM, Joshua Friedman <crownea...@gmail.com> wrote: > The following program runs really, really slowly. Is there anyway to > speed this up. I tried it as a .spyx program, put it wouldn't compile: > It takes my machine around 10 seconds. I suppose it is the symbolic math? > > f(x,y) = y^2*abs(3*exp(2*pi*i*(x+i*y))*3*exp(4*2*pi*i*(x+i*y)) + > 8*exp(2*pi*i*(x+i*y))*10*exp(4*2*pi*i*(x+i*y))) > maxY = 5 > M=10 > d = 0.1 > supNorm = 0 > for N in range(0,M): > for K in range (0, M*(int(maxY-1/2)+1) ): > a = -0.5 + N*d > b = 0.5 + K*d > if f(a,b) > supNorm: > supNorm = f(a,b) > print N > print supNorm > >
By a simple application of Carl Witty's awesome "fast_callable", I got a speedup of a factor of over 260 for your code. See http://sagenb.org/home/pub/1152/ Here it is: f(x,y) = y^2*abs(3*exp(2*pi*i*(x+i*y))*3*exp(4*2*pi*i*(x+i*y)) + 8*exp(2*pi*i*(x+i*y))*10*exp(4*2*pi*i*(x+i*y))) # Optimized "compiled" version of f to double precision: f = fast_callable(f,CDF,[x,y]) maxY = 5 M=10 d = 0.1 supNorm = 0 for N in range(0,M): for K in range (0, M*(int(maxY-1/2)+1) ): a = -0.5 + N*d b = 0.5 + K*d if f(a,b) > supNorm: supNorm = f(a,b) print N print supNorm -- William -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org