# Difference between Sum and NSum?

**URL:** <https://community.wolfram.com/t/difference-between-sum-and-nsum/21791>\
**Category:** Questions\
**Tags:** algebra, calculus\
**Created:** [March 22, 2023, 3:44pm UTC](https://community.wolfram.com/t/difference-between-sum-and-nsum/21791 "2023-03-22T15:44:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![indra](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@indra](https://community.wolfram.com/u/indra)\
**Post date:** [March 22, 2023, 3:44pm UTC](https://community.wolfram.com/t/difference-between-sum-and-nsum/21791/1 "2023-03-22T15:44:40Z")

</div>

I have to compute this,

 ![WhatsAppImage2023-03-22at16.24.07.jpg](https://global.discourse-cdn.com/wolfram/original/2X/6/65946263abfbfce5fcd032a3372b0d9198d5dd7a.jpeg)

I have written the Mathematica code, keeping Ta, and Tb as variables. Later we will compute prob[1,0,1,0,Ta,Tb]

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/9af5c537-ff00-4ece-8a42-74c04684548b)

```
In[75]:= prob[i_,j_,k_,l_,Ta_,Tb_]:= Sum[Binomial[ip,i]*Ta^i*(1-Ta)^(ip-i)*Binomial[jp,j]*Ta^j*(1-Ta)^(jp-j)*Binomial[kp,k]*Tb^k*(1-Tb)^(kp-k)*Binomial[lp,l]*Tb^l*(1-Tb)^(lp-l),{ip,1,Infinity},{jp,1,Infinity},{kp,1,Infinity},{lp,1,Infinity}];
In[80]:= prob[1,0,1,0,Ta,Tb]
Out[80]= ((-1+Ta) (-1+Tb))/(Ta^2 Tb^2)

```

My question is,

1. I have seen that if I use NSum in place of sum it takes too much to compute prob[1,0,1,0,Ta,Tb]  
what is the difference between sum and NSum here?
2. what will be a good idea to use here sum or NSum as I think Sum is not giving correct answer.(or maybe I am wrong that it is giving the correct answer)

---

<div class="post-metadata">

**Author:** ![jbaldwinpsw](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jbaldwinpsw](https://community.wolfram.com/u/jbaldwinpsw)\
**Post date:** [March 23, 2023, 3:19am UTC](https://community.wolfram.com/t/difference-between-sum-and-nsum/21791/2 "2023-03-23T03:19:26Z")

</div>

Why do you think using `Sum` gives the wrong answer? There’s no need to use `NSum`.

The way you’ve constructed the sum can be simplified and you have the product of 4 separate terms:

```
p[i_, t_] := Sum[Binomial[n, i]*t^i*(1 - t)^(n - i), {n, 1, \[Infinity]}]
prob[i_, j_, k_, l_, Ta_, Tb_] := p[i, Ta] p[j, Ta] p[k, Tb] p[l, Tb]
prob[1, 0, 1, 0, Ta, Tb]
(* ((1 - Ta) (1 - Tb))/(Ta^2 Tb^2) *)

```

**Addition:**

It appears that `p[i, t]` equals -1+1/t for i=0 and 1/t for i\>0 (with i being a non-negative integer). That simplifies things considerably.

---

<div class="post-metadata">

**Author:** ![indra](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@indra](https://community.wolfram.com/u/indra)\
**Post date:** [March 23, 2023, 12:57pm UTC](https://community.wolfram.com/t/difference-between-sum-and-nsum/21791/3 "2023-03-23T12:57:48Z")

</div>

Thanks for your response
