Finding the minimum of a discrete function from a continuous version In another post is asked to minimize
$$n+\left\lceil\frac dn\right\rceil$$ where $n$ is a positive integer ($d$ is also an integer, but we can relax this condition).
We obviously have
$$n+\dfrac dn\le n+\left\lceil\frac dn\right\rceil< n+\dfrac dn+1$$ and there is some relation between the requested minimum and that of the function
$$x+\frac dx$$ over $\mathbb R$ (at $x=d$).
But I cannot pinpoint the exact relation and deduce a procedure to solve the initial problem from the solution of the latter.

Update:
I am looking for some generality in the approach. I am not really after the solution of this particular problem.
 A: Let $f(n,d)=n+\lceil\frac{d}{n}\rceil$.
Let $m(d)$ denote the minimum value of $f(n,d)$ for positive integers $n$. The function $x+\frac{k^2}{x}$ has minimum $2k$ over the reals and $x+\lceil\frac{k^2}{x}\rceil\ge x+\frac{k^2}{x}$, so $m(k^2)=2k$.
Note that $f(n,d+1)=f(n,d)$ or $f(n,d)+1$, so $m(d+1)=m(d)$ or $m(d)+1\quad(*)$.
We have $f(k,k^2+1)=k+\lceil k+\frac{1}{k}\rceil=2k+1$. Also $k^2+1>k^2-a^2$, so $\frac{k^2+1}{k\pm a}>k\mp a$ and hence $f(k\pm a,k^2+1)\ge 2k+1$. So $m(k^2+1)=2k+1$.
We have $f(k,k^2+k)=2k+1$, so by $(*)$ we have $m(k^2+a)=2k+1$ for $0\le a\le k$.
Similarly, $(k-a+1)(k+a)=k^2+k-a^2+a<k^2+k+1$, so $\frac{k^2+k+1}{k+a}>k-a+1$ and hence $f(k+a,k^2+k+1)\ge 2k+2$. But $f(k+1,k^2+k+1)=k+1+\lceil k+\frac{1}{k+1}\rceil=2k+2$. Hence $m(k^2+k+1)=2k+2$.
But $f(k^2+2k,k)=2k+2$, so by $(*)$ we have $m(k^2+k+i)=2k+2$ for $i=1,2,\dots,k$.
Summary: $m(d)=2k+1$ for $k^2<d\le k^2+k$ and $2k+2$ for $k^2+k+1\le d\le(k+1)^2$.
Let $M(d)=\lceil2\sqrt{d}\rceil$. Then $M(k^2)=m(k)$. Also $$k^2<k^2+1<k^2+k<(k+\frac{1}{2})^2$$ so $M(d)=m(d)$ for $k^2<d\le k^2+k$. And $$(k+\frac{1}{2})^2<k^2+k+1<(k+1)^2-1<(k+1)^2$$ so $M(d)=m(d)$ for $k^2+k<d\le(k+1)^2$. So we have $$m(d)=M(d)\quad\text{ for all }d$$ But $M(d)$ is just the minimum for the real valued function $x+\frac{d}{x}$ rounded up to the nearest integer. So there is apparently a close and suggestive relationship between the solutions in the discrete and continuous cases.
