0

A recurrence relation defined as below where $c$ is a constant:

$$ f(n) = \begin{cases} c, & \text{if $n=1$}\\\\ f(n-1)\left(\frac{c}{n}\right), & \text{if $n>1$ and $n \in \mathbb{Z}^+$} \end{cases} $$

Further expanding the function we get: $$ f(n) = \frac{c^n}{n!}\\\\ \delta(n) = f(n)-f(n-1) = \frac{c^n}{n!}\left(1-\frac{n}{c}\right),~n>1 ~\text{and}~ n \in \mathbb{Z}^+ $$

Ideally $\delta(n)\rightarrow 0 \text{ when $n\rightarrow\infty$}$. However, for computational purpose I am trying to solve $n$ when $\delta(n) = \varepsilon$ where $\varepsilon$ is a very small number. Offcourse $n$ can be found by calculating $\delta(n)$ for $n=2, 3, 4, \cdots$ until the value of $\delta(n)$ reaches $\varepsilon$.
In order to avoid all that, I am looking for an analytical solution to to solve $\delta(n) = \varepsilon$.

tachyon
  • 121
  • 4
  • Consider $,c=1.$ If $,f(n)=\epsilon,$ then $,1/\epsilon=n!,$ so you are looking for the inverse of the factorial function. – Somos May 31 '21 at 12:17
  • I saw this post where they defined inverse factorial as: $n=\left\lceil e^{W\left(\frac{\log \left(\frac{n!}{\sqrt{2 \pi }}\right)}{e}\right)+1}-\frac{1}{2}\right\rceil$. What is $W$ here? Besides, it seems far more complicated to solve when $c\ne1$ – tachyon May 31 '21 at 12:26
  • 1
    The $,W,$ is Lambert $W$ function and the formula is only inverse of Stirling's approximation, and not the actual inverse of factorial. – Somos May 31 '21 at 12:32
  • As you wrote, the problem is difficult when $c\neq 1$. What I suppose is that, if you fix le value of $\epsilon$ to any value of you choice, using numerical analysis,we could find some approximation. – Claude Leibovici May 31 '21 at 13:24
  • 1
    It would be much easier to solve, for $n$, $f(n)\leq \epsilon$ for any $c$ and $ \epsilon$ – Claude Leibovici May 31 '21 at 13:57
  • @ClaudeLeibovici How can we solve $f(n) < \varepsilon$? Will it be correct to – tachyon May 31 '21 at 14:29
  • This would be very simple. If this is of interest for you, just tell and I shall show tomorrow (it is almost curfew time here). Cheers :-) – Claude Leibovici May 31 '21 at 14:34
  • I am not a mathematician, but never thought about inverse of factorial function so it is kind of new to me also what I have read so far inverse of factorial (also gamma function) is way more complicated compared to how simple gamma and factorial is. Offcourse I am interested @ClaudeLeibovici. – tachyon May 31 '21 at 14:43

1 Answers1

1

If we start looking at the problem of finding $n$ such that $f(n) \leq \epsilon$, it write $$\frac {c^n}{n!}=\epsilon \implies n!=\frac {c^n}\epsilon$$ This has been solved in a question of mine where @robjohn proposed a superb approximation. Using your notations $$\color{blue}{n\sim c \,e^{1+W(t)}-\frac 12}\qquad \text{where} \qquad \color{blue}{t=-\frac{\log \left(2 \pi c \epsilon ^2\right)}{2 e c}}\tag 1$$ $W(t)$ being Lambert function.

For a first test, using $c=5$ and $\epsilon=10^{-15}$, this would give $n\sim 34.3499$ ( the exact solution being $34.3505$) then $\lceil n \rceil=35$. Checking $$\frac {5^{34}}{34!}=1.97\times 10^{-15} >10^{-15}\qquad \text{while} \qquad\frac {5^{35}}{35!}=2.82\times 10^{-16} <10^{-15}$$

If you cannot access Lambert function, since $t$ is large, you can approximate it using the series expansion $$W(t)\sim L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\frac{L_2(2L_2^2-9L_2+6)}{6L_1^3}+\cdots$$ where $L_1=\log(t)$ and $L_2=\log(L_1)$.

For illustration, still for $c=5$ and $\epsilon=10^{-k}$, let us compute $\delta(n) = |f(n)-f(n-1)|$. $$\left( \begin{array}{cc} k & \log_{10}[\delta(n)] \\ 5 & -4.49533 \\ 6 & -5.45527 \\ 7 & -6.42008 \\ 8 & -7.38869 \\ 9 & -8.36033 \\ 10 & -9.33446 \\ 11 & -10.3107 \\ 12 & -11.2886 \\ 13 & -12.2681 \\ 14 & -13.2489 \\ 15 & -14.2308 \end{array} \right)$$

It is the same order of magnitude. So, keep $(1)$ for the estimation.

If you really want to polish the root, consider that you look for the zero of function $$g(n)=\log \left(\frac{c^n }{n!}\left(\frac{n}{c}-1\right)\right)-\log(\epsilon)$$ and perform some iterations of Newton method $$n_{p+1}=n_p-\frac{g(n_p)}{g'(n_p)}$$ using for $n_0$ the value given by $(1)$ and $$g'(n)=\frac{1}{n-c}+\log (c)-H_n+\gamma$$ For the first worked example, the iterates would be $$\left( \begin{array}{cc} 0 & 34.3499 \\ 1 & 35.2783 \\ 2 & 35.2718 \end{array} \right)$$