How many numbers of the form $m^2 + \sqrt{2} n^2$ are between $1 \times 10^6$ and $2 \times 10^6$?

141 Views Asked by At

I have a purely computational question today. How many numbers of the form $m^2 + \sqrt{2} n^2$ with $m,n \in \mathbb{Z}$ are between $1 \times 10^6$ and $2 \times 10^6$ ?

$$ \# \big\{ (m,n): 1 \times 10^6 < m^2 + \sqrt{2} \, n^2 < 2 \times 10^6 \big\} =\; ? $$

The asymptotic answer for this sequence of numbers can be found using Weyl's law, for exmaple that:

$$ \# \big\{ (m,n) : 0 < m^2 + \sqrt{2} \, n^2 < X \big\} \sim \frac{\pi}{4 \sqrt{2}} \, X$$

This result is saing that numbers of the form $m^2 + \sqrt{2} \, n^2$ are roughtly linearly distributed on the real line $\mathbb{R}$.

The Weyl's law estimate gives $\frac{\pi}{4\sqrt{2}} \times 10^6 \approx 555,630 + 0.36726\dots$ Perhaps with a computer it's possible to obtain an exact answer? E.g. using Python or sage.

2

There are 2 best solutions below

3
On

First of all, I graphed your function in the terms of $x$ and $y$ instead of $m$ and $n$ and got this graph:
graph 1 graph 2
graphed using: Geogebra

The graph shows an elliptic Paraboloid which has a minimum value of zero, going up to $\infty$; However, the graph shows a function on $\mathbb R$ not $\mathbb Z$ (of course). so, we've to find the solution for $m$ and $n$ which are integers that have a result (after applying the formula) included between $1 \times 10^6$ and $2 \times 10^6$ only.

And to do this we have to find out the number of integers included in $[1 \times 10^6,2 \times 10^6]$ before doing anything, and they are simply $1 \times 10^6 +1$ (bec. million is included, we can't simply subtract). Then we must get the minimum and the maximum value that both $m$ and $n$ can have.

The minimum value for each of them must be zero; as if one of them reached its maximum value the other must be zero. but, getting the maximum value will be a bit more trickier; considering that each one of them is zero independently might help: $$m^2 + \sqrt{2} \, n^2=2 \times 10^6 \\ m^2=2 \times 10^6 \\ m = \sqrt{2 \times 10^6} = 1414.213562 \ \ \ \ \ (m \notin \mathbb Z) \\ \lfloor m \rfloor = 1414$$ Having $m^2$ as the maximum value ($2 \times 10^6$) didn't help in getting an integer so flooring the result can help; as flooring the result will give an integer which is not more than $2 \times 10^6$. Now the same to get the maximum value for $n$ ($m=0$): $$m^2 + \sqrt{2} \, n^2=2 \times 10^6 \\ \sqrt{2} \, n^2 = 2 \times 10^6 \\ n = \sqrt{\frac{2 \times 10^6}{\sqrt{2}}} = 1189.207115 \ \ \ \ \ (n \notin \mathbb Z) \\ \lfloor n \rfloor = 1189$$

Now we the minimum and the maximum values for each $m$ and $n$, and this can be summarized as follows:
$$0 \le m \le 1414 \\ 0 \le n \le 1189$$ Now we need the minimum value for each of them when the other is zero, and that's possible by considering $n=0$:
$$m^2 + \sqrt{2} \, n^2=1 \times 10^6 \\ m^2=1 \times 10^6 \\ m = \sqrt{1 \times 10^6} = 1000$$ and again by considering $m=0$:
$$m^2 + \sqrt{2} \, n^2=1 \times 10^6 \\ \sqrt{2} \, n^2 = 1 \times 10^6 \\ n = \sqrt{\frac{1 \times 10^6}{\sqrt{2}}} = 840.8964153 \ \ \ \ \ (n \notin \mathbb Z) \\ \lceil n \rceil = 841$$ However, $n$ can't be $1000$ (for example) when $m=800$. so, how can we solve this problem ?
It's easy we just have to find a relation between $m$ and $n$, but first we must find the number of possibilities we have (now) which is all possibile ordered pairs of $m$ and $n$ which is (by using Cartesian product):
$$\# \{ m: 0 \le m \le 1414 \} = 1414 + 1 \ \text{(bec. zero is included)} = 1415 \\ \# \{ n: 0 \le n \le 1189 \} = 1189 + 1 = 1190 \\ 1415 \times 1190 = 1683850$$ Now we know that the number of numbers of the form $m^2+\sqrt{2} \, n^2$ between $1 \times 10^6$ and $2 \times 10^6$ in the first quadrant is less than $1683850$, but what is the difference between the required number and this number ?

We can find out by using the graph, think of an area (on the plane $z=0$ in the 3d graph) that contains all the ordered pairs we need, it will be like an ellipse that we can graph as follows:$10^6<x^2+ \sqrt{2} \, y^2 < 2 \times 10^6$ (inequality graph).
I used $x$ instead of $m$ and $y$ instead of $n$ and got this:-
Graph 3
Two ellipses one inside other with bounds that we have calculated above, the colored area represents all ordered pairs that satisfy the formula, so we just have to calculate number of integer pairs in it.

0
On

COMMENT.- Without calculator the problem is tedious but not difficult.

The required points are enclosed between the ellipses of equations $m^2 + \sqrt{2} n^2=10^6$ and $m^2 + \sqrt{2} n^2=2\cdot10^6$. Define the following sets in the first quadrant: $$A=\{(0,y)\text { with } y\gt0 \}\\B=\{(x,0)\text { with } x\gt0 \}\\C=\{(x,y)\text { with } x\gt0,y\gt0 \}$$ By symmetry we have for the total number $N$ of points $$N=2A+2B+4C$$ $A$ has $573$ points and $B$ has $413$.

One has for the calculation of the set $C$ $$\frac{\sqrt{10^6-m^2}}{\sqrt[4]2}\lt y\lt\sqrt[4]2\sqrt{10^6-m^2}\text { where } 1\le m\le1000$$ Assuming that @rogerl's comment above is true, there are $4\cdot660074+1972=\color{red}{2\space642\space268}$ points in total.