Question: Slow summation in a procedure

Hi, I am having problems with a slow procedure for doing a large number of recursive calculations. Here is the code: g_exp := proc(u,t,lambda,beta) global k, g, f, d, i, t1, sum2, j: g := array(0..u+t): f := array(0..u+t): g[0] := evalf(exp(-1*lambda)): f[0] := evalf(1-exp(-beta*(0.5))): for k from 1 to (u+t) do f[k] := evalf((1-exp(-beta*(k+0.5)))-(1-exp(-beta*(k-0.5)))): g[k] := evalf((lambda/k)*sum(i*f[i]*g[k-i],i=1..k)): end do: d := array(0..u+t-1,1..t); d[0,1] = evalf(g[0] + g[1]); for i from 1 to (u+t-1) do d[i,1] := evalf(d[i-1,1] + g[i+1]); end do: for t1 from 2 to 10 do for i from 0 to (u+t-t1) do d[i,t1] := evalf(sum(d[i+1-j,t1-1]*g[j],j=0..i+1)); end do: end do: end This is part of the code that is giving me problems: for t1 from 2 to 10 do for i from 0 to (u+t-t1) do d[i,t1] := evalf(sum(d[i+1-j,t1-1]*g[j],j=0..i+1)); end do: end do: I am using evalhf and this has speeded things up but it is still really slow. I have tried to find faster alternatives to storing the data in arrays. I suspect it is because I am accessing arrays. Thanks in advance, Matthew
Please Wait...