Could anyone provide some hints for solving:


$\underset{n} {\mathrm{argmin}} \frac{a}{r + ns} + \sum\_{i=0}^{n-1}\frac{b}{r + is}$ for $n \in \{1,2,3,\ldots\}$


The problem is part of a coding exercise, but I was curious whether an analytic solution could be derived.



Analytic solution $\underset{n} {\mathrm{argmin}} \frac{a}{r + ns} + \sum_{i=0}^{n-1}\frac{b}{r + is}$
Let
$$ F(n) = \dfrac{a}{r+ns} + \sum\_{i=0}^{n-1} \dfrac{b}{r+is}$$
I'll assume $a,b,r,s > 0$. Note that
$$F(n+1) - F(n) = \dfrac{bs n + b r+ bs - as}{(ns + r + s)(ns + r)}$$
So you want the least positive integer $n$ (if any) such that
$b s n + br + bs - as \ge 0$, i.e. $n = \left\lceil \dfrac{a}{b} - \dfrac{r}{s} - 1\right\rceil$ if that is positive, otherwise $n=1$.


