0

I came across a sum where I have to find the smallest $n$ so that

$$\sum_{x = 0}^n \frac{250^x}{x!} \ge \frac{e^{250}}{2}$$

I wrote a Java code and the result was 55 but with Desmos it was over 129 (I don't know exactly how much because Desmos gives "undefined value" over 129). How would you proceed in such a case? I also took the natural log of both sides because it is monotony-preserving but we have the same problem.

Gary
  • 36,640

2 Answers2

1

In fact, your inequality can be given a probabilistic interpretation : written under the form

$$\sum_{x = 0}^n e^{-250} \frac{250^x}{x!} \ge \frac{1}{2},$$

the first $n$ for which this inequality is true has a name : it is the median of the Poisson distribution with parameter $\lambda=250$.

In this reference, we have a "bracketing result" saying that the median $\nu$ is such that :

$$\lambda - \ln(2) \le \nu \le \lambda+\tfrac13$$

giving here $\nu=\lambda=250.$

Confirmation by this SAGE program (SAGE language supports multiprecision), where $S$, once the for-loop has been completed, is the sum on the LHS of your initial inequality :

 S=0
 c=1 ; # increment
 n=250
 for k in range(n) :
    S=S+c
    c=250*c/(k+1)
 show(S.n(30))
 t=exp(250)/2
 show(t.n(30))

Taking $n=250$ is

$$S \approx 1.8417173 \times 10^{108} < t \approx 1.8732273 \times 10^{108}$$

whereas, for $n=251$, it is :

$$S \approx 1.9362138\times 10^{108} > t \approx 1.8732273 \times 10^{108}$$

Jean Marie
  • 88,997
  • okay that seems to be the correct answer as I have calculated it with the median of the poisson Distribution so we know that the median is the floor of lamda + 1/3 - 0.02/lamda and that the median is actually the smallest n such that Pr(X<= n) >= 1/2 and here my lamda is 250 so n = 250. can u tell me how can I program in SAGE and why is it better than Java or C++? Also why does Java Code gives me 55 ? Thanks in advance – Issaouik Aziz May 25 '24 at 23:14
  • I just wrote exactly the same thing !!! 2) Unfortunately, I am unable to say something about Java that I don't know. But, have a look at the way you have programmed the increment : you can see on my version that I don't use "factorials" (which can maybe explain the errors occuring in your calculations)
  • – Jean Marie May 25 '24 at 23:19
  • Executing a program in SAGE is easy : just call https://sagecell.sagemath.org/ ; an Edit window opens ; type or copy-paste your program in this window, then press the button "Evaluate". The default environment is SAGE but you can modify it (work in Python for example) by changing (right button) the language. Its syntax is close to the Python syntax. – Jean Marie May 25 '24 at 23:27
  • 1
    okay I didnt see that you have mentioned it so sorry for 1). For 2) I will try it thanks a bunch for the advice. SAGE seems to be really cool tbh. – Issaouik Aziz May 26 '24 at 00:07