1

I am looking for a direct formula for this sum

$$\sum_{k=0}^n \lfloor{\sqrt{n+k}}\rfloor\lfloor{\sqrt{k}}\rfloor$$

Or a method to efficiently compute the sum for large n

Ruan
  • 11

2 Answers2

1

I do not think that a closed form could exist.

Generating value for $100\leq n\leq 10000$ by step of $100$ and plotting the results shows something very close to a power law. Using nonlinear regression, what I obtained is $$S_n=\sum_{k=0}^n \lfloor{\sqrt{n+k}}\rfloor\lfloor{\sqrt{k}}\rfloor\approx 0.781411\, n^{2.0067}$$ where both parameters are highly significant as show below $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & 0.781411 & 0.000529556 & \{0.78036,0.782462\} \\ b & 2.006700 & 0.000075149 & \{2.00655,2.006850\} \\ \end{array} $$ I suppose that we could keep the exponent equal to $2$ and get $$S_n \approx 0.830070\, n^2$$

You should notice that, as Yves Daoust commented, $$\int_0^1\sqrt{1+x}\sqrt x \,dx=\frac{1}{4} \left(3 \sqrt{2}-\sinh ^{-1}(1)\right)\approx 0.840317$$

  • Hmm. Are there certain types of $n$ for which a closed form could exist?(i.e, can a closed form exist for when $n$ is a square(or another special type)?) – S.C.B. Apr 04 '16 at 09:51
  • Sums involving integer square roots can be addressed by considering the "runs" of values where the square root remains constant. For instance the sum of $\sqrt k$ yields about $\sqrt n$ whole runs of value $k$ and length $2k+1$, hence the sum of $k(2k+1)$ up to $k=\sqrt n$, and a final incomplete run. –  Apr 04 '16 at 10:12
  • The case at hand is much harder as the runs for $\sqrt{n+k}$ and $\sqrt k$ do not overlap, but there is still some hope for a closed formula. –  Apr 04 '16 at 10:14
  • @YvesDaoust. I am not sure I understand your comment. Why don't you write an answer ? I should be very interested to learn. Thank you in advance. Cheers. – Claude Leibovici Apr 04 '16 at 10:15
  • @ClaudeLeibovici: I started to, but I can't complete it right now, too complicated. Have a look at this: http://math.stackexchange.com/a/1242332/65203 –  Apr 04 '16 at 10:17
  • @YvesDaoust. Very interesting link, indeed ! I am sure that you know that I am not a mathematician (only concerned by numerical stuff). Cheers. – Claude Leibovici Apr 04 '16 at 10:27
  • @ClaudeLeibovici: I known the author of that post personally. Just an algorithmician, nothing more. :) –  Apr 04 '16 at 10:31
  • Thanks guys. What about summing $$\lfloor{\sqrt{k(n+k)}}\rfloor$$ – Ruan Apr 08 '16 at 06:57
1

Here's an exact $O(\sqrt{n})$ formula:

$$\left\lfloor \sqrt{n}\right\rfloor \left((n+1) \left\lfloor \sqrt{n}\right\rfloor +\frac{1}{3} \left(-\left(\left\lfloor \sqrt{n}\right\rfloor +1\right)^3+\frac{3}{2} \left(\left\lfloor \sqrt{n}\right\rfloor +1\right)^2+\frac{1}{2} \left(-\left\lfloor \sqrt{n}\right\rfloor -1\right)\right)\right)+\frac{1}{6} \left\lfloor \sqrt{n}\right\rfloor \left(-\left\lfloor \sqrt{n}\right\rfloor \left(2 \left\lfloor \sqrt{n}\right\rfloor +3\right)+6 n+5\right) \left\lfloor \sqrt{2} \sqrt{n}-\left\lfloor \sqrt{n}\right\rfloor \right\rfloor +\sum _{j=\left\lfloor \sqrt{n}\right\rfloor +1}^{\left\lfloor \sqrt{2n} \right\rfloor } \left(\left\lfloor \sqrt{j^2-n}\right\rfloor ^3-\left(j^2-n\right) \left\lfloor \sqrt{j^2-n}\right\rfloor -\frac{1}{6} \left(\left\lfloor \sqrt{j^2-n}\right\rfloor -1\right) \left(4 \left\lfloor \sqrt{j^2-n}\right\rfloor +1\right) \left\lfloor \sqrt{j^2-n}\right\rfloor \right)$$ It can be derived via the following steps:

  1. the $\left\lfloor\sqrt{k+n}\right\rfloor$ factor can be ignored at first; substitute in $\sqrt{n}$ and use the known formula for summing $\left\lfloor\sqrt{k}\right\rfloor$
  2. now add in the deficit: each $k$ where $\left\lfloor\sqrt{k+n}\right\rfloor$ increases by $1$ (there are $O(\sqrt{n})$ such points), sum $\left\lfloor\sqrt{k}\right\rfloor$ from this $k$ to $n$ (use the known formula again, with suitable modifications).
  3. Clean up: shift the summation index to make the sum formula maybe nicer looking; pull factors which only depend on $n$ outside the sum, etc.
  • Apparently, something that looks highly similar was already found here: https://www.nctm.org/tmf/library/drmath/view/77981.html – Dan Hoying Jun 21 '20 at 18:45
  • Hi @DanHoying, please ignore my previous comment about the formula not working. It works perfectly, I missed a $\sqrt{}$. – Ruan Sunkel Aug 27 '21 at 13:18
  • How would the formula change if the $n$ within the square root changed to a positive integer constant $c$? – Ruan Sunkel Aug 27 '21 at 13:36