Maximum of the function $x\mapsto -N\log(x)+\sum\log(x-i)$ Fix $n\in\mathbb{N}$ and $N> n$.
I am trying to find the maximum of the following function:
$$
f:[n,\infty)\rightarrow\mathbb{R},\quad x\mapsto -N\log(x)+\sum_{i=0}^{n-1}\log\left(x-i\right)
$$
This function arose in a maximum-likelihood problem I am studying, which is why I expect that there should be a maximum.
Since $f$ is differentiable, we can find candidate solutions with the first-order-condition:
$$
\frac{N}{x}=\sum_{i=0}^{n-1}\frac{1}{x-i}
$$
The right-hand-side can be rewritten as:
$$
\sum_{i=0}^{n-1}\frac{1}{x-i}
=\sum_{j=x-n+1}^x\frac{1}{j}
=\sum_{j=0}^x\frac{1}{j}-\sum_{j=0}^{x-n}\frac{1}{j}
=H_{x}-H_{x-n}
$$
Above, $H_x$ denothes the $x$-th harmonic number.
Here I get stuck. Is there a way to find a closed-form solution for the maximum of $f$?
Alternative approaches are also welcome!
 A: I'm not sure if such a heuristic result will be helpful, but for large $n$, I believe the maximum of $f$ occurs fairly close to $\hat{x} = n\left(1+\frac{n}{N}\,W(-\frac{N}{n}\,e^{-\frac{N}{n}})\right)^{-1}$, where $W$ is the Lambert W-function. Here are a few values for comparison:
$$\left.\matrix{n & N & \hat{x} & {\rm Numerical}\cr
100 & 200 & 125.5 & 124.655 \cr
300 & 305 & 9200.55 & 9170.19 \cr
300 & 700 & 345.593 & 344.87 \cr
1000 & 3000 & 1063.29 & 1062.68 }\right.$$
The "Numerical" values are the outputs of Mathematica's NMaximize command applied to $f(x) = -N\log{x}+\sum_{i=0}^{n-1}{\log{(x-i)}}$. That is, ${\tt x /. NMaximize[\{f[x, n, bigN], x > n\}, x][[2, 1]]}$. Note that the NMaximize command takes a long time to execute on my laptop: about 2 minutes for the case $n=1000$, $N=3000$.
The expression for $\hat{x}$ results from crudely replacing the sum $\sum_{i=0}^{n-1}{\frac{1}{x-i}}$ with the integral $\int_0^{n}{\frac{di}{x-i}}$ in the condition for vanishing derivative. This results in the equation $\frac{N}{x} = \log{\frac{x}{x-n}}$. Defining $z = \frac{1}{x}$, we have $e^{Nz}(1-nz) = 1$ which shows that $z$ is close to $\frac{1}{n}$ (so that the product of a large and small factor is unity). In general, unraveling such transcendental equations leads to the Lambert W-function. (Mathematica calls it the ${\tt ProductLog}$ function.)
The expression for $\hat{x}$ is a little messy. When $\frac{N}{n}\gg 1$, an approximation is $\hat{x} \approx n(1+e^{-\frac{N}{n}})$. For example,
$$\left.\matrix{n & N & n(1+e^{-\frac{N}{n}}) & \hat{x} & {\rm Numerical}\cr
40 & 80 & 45.4 & 50.2 & 49.3512 \cr 
100 & 500 & 100.674 & 100.703 & 100.13}\right.$$
Update: For completeness, I'll show how to express the solution of $e^{Nz}(1-nz)=1$ in terms of the Lambert W-function. Define $u=1-nz$, then the equation says $u\,e^{\frac{N}{n}(1-u)}=1$. Multiplying both sides by $e^{-\frac{N}{n}}$, we have $u\,e^{-\frac{N}{n}u}=e^{-\frac{N}{n}}$. Multiplying both sides by $-\frac{N}{n}$, we have $(-\frac{N}{n}u)\,e^{(-\frac{N}{n}u)}=-\frac{N}{n}\,e^{-\frac{N}{n}}$. Now by definition, the Lambert W-function $W(y)$ has defining property $W\,e^W = y$. So from $(-\frac{N}{n}u)\,e^{(-\frac{N}{n}u)}=-\frac{N}{n}\,e^{-\frac{N}{n}}$, we have $-\frac{N}{n}u = W(-\frac{N}{n}\,e^{-\frac{N}{n}})$. Re-expressing this in terms of $z$, $-\frac{N}{n}(1-nz) = W(-\frac{N}{n}\,e^{-\frac{N}{n}})$. This equation is easily solved for $z$, and hence for $x$, leading to the expression for $\hat{x}$ given above.
