0
$\begingroup$

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...

$\endgroup$
1
  • $\begingroup$ The target for defining a function is to give is a set, pair of values as the input. For me the copy'n'paste code works with 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$ Commented May 8, 2022 at 17:25

1 Answer 1

3
$\begingroup$

Maybe like this:

 ClearAll["`*"]; Remove["`*"];(* Clears All*)

 Pn[0, \[Lambda]_] := 1 - \[Lambda];
 Pn[1, \[Lambda]_] := (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}];

 f[\[Lambda]_, r_] := 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}]

  N[f[1/2, 101], 50]
  (* 1.0010532880860907539154104616060531372235322012173 *)

  f[1/2, 101] (*Large expression ! *)

For k->Infinity I doubt there's a closed form for the Sum.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.