I have this summation, $S$,...
$$ \begin{alignat}{2}% & P(0) = (1 - A) \notag \\ & P(1) = (1 - A)(e^A - 1) \\ & P(i + 1) = \frac{1}{P(0,A)}\Bigl\{P(i) - [P(0) + P(1)] P(i,A) \\ & \quad \quad-\sum_{\nu=2}^{i} P(\nu) \cdot P(i - \nu + 1, A) \Bigr\}. \label{md1ssprob} \end{alignat} $$
$$ S = \sum _{k=0}^{\infty } \left(1-\sum _{i=r+1}^{2 r+1} \binom{2 r+1}{i} \left(1-\frac{P(k,\lambda )}{\sum _{j=0}^k P(j,\lambda )}\right)^i \left(1-\left(1-\frac{P(k,\lambda )}{\sum _{j=0}^k P(j,\lambda )}\right)\right)^{2r+1-i }\right) $$
and I want to be able to substitute for some arbitrary value $r$, but it doesn't seem to want to work. It only works when I manually enter the values for the summation.
Here is the code I have (that works if I manually put in the $r$ value).
Pn[0, \[Lambda]_] := 1 - \[Lambda];
Pn[1] = (1 - \[Lambda])*(E^\[Lambda] - 1);
Pn[n_, \[Lambda]_] := (1 - \[Lambda])*
Sum[E^(j*\[Lambda])*(-1)^(n -
j)*(((j*\[Lambda] + n - j)*(j*\[Lambda])^(n - j - 1))/(n -
j)!), {j, 0, n}];
Sum[1 - Sum[
Binomial[2*r + 1,
i]*(1 - Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}])^
i*(1 - (1 -
Pn[k, \[Lambda]]/Sum[Pn[j, \[Lambda]], {j, 0, k}]))^(2*r +
1 - i),
{i, r + 1, 2*r + 1}], {k, 0, 35}] /. {\[Lambda] ->
0.5, r -> 101}
Why does it do this? Why can't I just substitute some $r$ value using the $\longrightarrow$ rule?
Also, in the code I only sum to 35. The reason is that if I put the symbol $\infty$ in, it takes forever and never completes. Also, it overflows sometimes if the number is too high. If you have any thoughts on that as well, it would be appreciated.
Thanks in advance...
Pn[101, 0.5]
. Mathematica runs in this way used faster because the values are taken earlier before the symbolic sum has been created. In my machine You interchanged {r,[Lambda]} in the rules and did not work properly with the braces. Mathematica creates a signature for the functions to identify them in more detail in this. Think of using rules in this cases a working in three implicit step, two symbolic calc and the numerical instead one. $\endgroup$