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?
A
andB
? $\endgroup$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$