I am using the following recursion in Mathematica to compute W[n, 1, s] for given n and s:

W[1, j_, s_] := B[j, s]
W[n_, j_, s_] := W[n, j, s] = Sum[A[i, s] W[n-1,j+1-i], {i,0,j}]

with functions A and B given. I need the value of W[n, 1, s] for n equal to 2 to some k, and for different values of s. So as you can see I have written the recursion in a way so that it remembers the values it finds with the goal of reducing the time by keeping more memory. However, for higher values of k the computer runs out of memory. Is there a better way of doing this?

  • 1
    $\begingroup$ Seen this? $\endgroup$ Jun 10, 2013 at 17:43
  • $\begingroup$ Could you please define the functions A and B? $\endgroup$
    – partial81
    Jun 10, 2013 at 17:55
  • $\begingroup$ They are complicated Laplace transforms (s is the Laplace variable) defined in terms of other LTs (H and X) which are available in closed form. e.g., B[i_, s_] := If[i == 0, ((\[Mu]/(\[Mu] + \[Lambda] + s)) p H[s])/(1 \ - X[s]), ((\[Mu]/(\[Mu] + \[Lambda] + s)) p H[s] \ (X[s])^(i - 1))/((1 - X[s]))^(i + 1)] $\endgroup$ Jun 10, 2013 at 18:02
  • $\begingroup$ Thanks @J. M. I am reading it and I am getting some good ideas. $\endgroup$ Jun 10, 2013 at 18:13


Browse other questions tagged or ask your own question.