I am interested in hashing recently, and encountered an interesting estimate that deals with birthday problem. The original context is not relevant to the estimate I want, so I omit it unless people are interested in. The estimate I like to get is:
Question
For the function $$P(N,d)=\frac{N!}{d!N^d},$$ what's the asymptotic behavior of the inverse function $d(P,N)$?
Attempt
Using Stirling's formula, I have $$\frac{N!}{P}\sim\sqrt{2\pi d}\frac{Nd}{e}^d,$$ but I have no idea how to proceed.
Example
More specifically, I would like to obtain for what $d$ is the probability $P$ less than $10^{-4}$, where $N$ is assumed to be, say, $2^{128}$. This relates to how safety the algorithm MD5 is.
From $P(N,d) =\frac{N!}{d!N^d}, $, $\ln(P) =\ln(N!)-\ln(d!)-d\ln(N) $.
Since $\ln(x!) =x\ln(x)-x+O(\ln(x)) $,
$\ln(P) =N\ln(N)-N+O(\ln(N))-(d\ln(d)-d+O(\ln(d))-d\ln(N) $.
Let $d = \dfrac{c}{\ln(c)} $ so $d\ln(d) = \dfrac{c}{\ln(c)}(\ln(c)-\ln\ln(c)) =c-\dfrac{c\ln\ln(c)}{\ln(c)} =c+o(c) $.
Then
$\begin{array}\\ \ln(P) &=N\ln(N)-N+O(\ln(N))-(d\ln(d)-d+O(\ln(d))-d\ln(N)\\ &=N\ln(N)-N+O(\ln(N))-(c+o(c))-\dfrac{c}{\ln(c)}\ln(N)\\ &=N\ln(N)+o(N)-c+o(c)-\dfrac{c}{\ln(c)}\ln(N)\\ \end{array} $
If $d = o(N)$, then $\ln(P) =N\ln(N)-c+o(N)+o(c)-o(N\ln(N)) $ so $c =N\ln(N)-\ln(P)+o(N\ln(N)) $ so $\ln(c) =\ln(N)+o(\ln(N)) $ so $d =\dfrac{c}{\ln(c)} =\dfrac{N\ln(N)-\ln(P)+o(N\ln(N))}{\ln(N)+o(\ln(N))} =N-\dfrac{\ln(P)}{\ln(N)}+o(N) $.
Anyway, the answer should be something like this.