# Find the maximum of a function involved with Floor function

My function is

$$f(H,p) = \left\lfloor \dfrac{\lfloor H/p\rfloor + 3 - \sqrt{(\lfloor H/p\rfloor + 1)^2 - 4H}}{2} \right\rfloor$$

The constraints are $$H \geq p(4p-1)$$, $$p$$ is prime although not necessary for this problem. From numerical tests I see the maximum to be $$2p$$ at $$H = 4p^2$$. I need to prove this. The derivative of the Floor function is zero-so the usual method of finding the max/min does not apply here.

• Is p fixed? I mean, do you want to maximize with respect to {H,p} or only with respect to H? – Henrik Schumacher Dec 10 '18 at 20:55
• yes p will be fixed. – Lorenz H Menke Dec 10 '18 at 20:57
• Call your function f(H, p). Then f(4*3^2, 3) = 5 != 2*3. – Robert Jacobson Dec 11 '18 at 5:13
• I think you can do something like the following (I don't have time for a full answer, so this is just a rough sketch): Call your function $f_1$. Remove the outer Floor to get $f_2$. Maximizing this will give the same $H$ as $f_1$. Notice that $f_2'>0$ for $k\leq H/p<k+1,k\in\mathbb{N}$. So you only care about the values at $H=(k+1)p$. Rewrite as $f_3(k,p)$ (dropping the inner Floors), then $\partial_kf_3(k,p)<0,\forall k>4p-1$ (i.e. $H>p(4p-1)$). So $f_3$ (and thus $f_2,f_1$) has its maximum for the smallest $H>p(4p-1)$. (You might need to tweak a bit, but I think it should do the trick) – Lukas Lang Dec 11 '18 at 9:20
• After taking the derivative and solving for $k$ when less than zero I get $k \ge 2p-1 + 2 \sqrt{(p-1)p}$. Then show that $$p-1\le\left\lfloor\sqrt{(p-1)p}\right\rfloor\le\left\lceil\sqrt{(p-1)p}\right\rceil\le p.$$ From this we get $k \ge (4p-1)$ or $H \ge p(4p-1)$, hence solve the problem. – Lorenz H Menke Dec 12 '18 at 20:34