Where $[x]$ in the summation limits is the floor function. In the summation body this is the Iverson bracket
Find the sum and asymptotic expansion of $\sum_{u=1}^{\lfloor{N/2}\rfloor} \sum_{v=1}^{\lfloor{\sqrt{N}}\rfloor} \left[|u^2-2v| \le N\right] \left[|-2uv| \le N\right]$.
I suspect that there may be a closed form solution. I have not made any progress to the analytic form of this sum.
I have some table values
| N | Sum |
|---|---|
| 1 | 0 |
| 10 | 10 |
| 10^2 | 100 |
| 10^3 | 981 |
| 10^4 | 10000 |
| 10^5 | 99928 |
This indicates that the sum approach $N$ as $N \rightarrow \infty$.
The second part is to find this asymptotic expansion.
Lets look at a table between perfect squares. Say from N = 16 to 24. Then
This pattern repeats for each perfect square sequence.
So with ${S}_{1} \left({N}\right) = \sum_{u=1}^{\lfloor{N/2}\rfloor} \sum_{v=1}^{\lfloor{\sqrt{N}}\rfloor} \left[{|u^2-2v| \le N}\right] \left[{|-2u| v \le N}\right]$.
Then consider two consecutive perfect squares $\sqrt{N} \in \mathbb{Z}$ or $N = {n}^{2}$ to $N = \left({n + 1}\right)^{2}$. Then from $N = {n}^{2}$ to $\left({n +1}\right)^{2} - 1$ there are $2\, n$ values. Let $k \in \left\{{0, 1, \cdots, 2\, n}\right\}$. Then for the values ${S}_{1} \left({{n}^{2}}\right.$, ${n}^{2} + 1$, $\cdots$, $\left.{\left({n +1}\right)^{2} - 1}\right) = N - \lfloor{k/2}\rfloor$. The sequence of $k = 0$ to $2\, n$ is $\lfloor{k/2}\rfloor = \lfloor{(N-\lfloor{\sqrt{N}}\rfloor^{2})/2}\rfloor$. Thus, applying induction, we can write for any perfect square interval $N \ge 9$
$${S}_{1} \left({N}\right) = N - \lfloor{\frac{N-\lfloor{\sqrt{N}}\rfloor^{2}}{2}}\rfloor$$
We add the final corrections for the values of $N \in \left\{{1, 2, 3, 5}\right\}$ resulting in
$${S}_{1} \left({N}\right) = N - \lfloor{\frac{N-\lfloor{\sqrt{N}}\rfloor^{2}}{2}}\rfloor - {\delta}_{N \in \left\{{1, 2, 3}\right\}} - {\delta}_{N=5}$$
For the asymptotic values as $N \rightarrow \infty$ we write the average value between two perfect squares of
$$\left<{\lfloor{\frac{N-\lfloor{\sqrt{N}}\rfloor^{2}}{2}}\rfloor}\right> = \frac{\text{sum of interval}}{2 \times \text{ length of the interval}}= \frac{\lfloor{\sqrt{N}}\rfloor^{2}-1}{2(\lfloor{\sqrt{N}}\rfloor+2)}\sim\frac{N-1}{2(\sqrt{N}+2)}\sim\frac{1}{2} \sqrt{N}-1+O(\frac{1}{N})$$
with the final answer
$${S}_{1}\left({N}\right) \sim N - \frac{1}{2} \sqrt{N}+1+O(\frac{1}{N})$$