How many integer pairs satisfy the ellipse $x^2+ay^2=r?$
What I have discovered thus far:
This post is largely to document the thinking that I have already done... I know that this can be frowned upon in this community. BUT! This is not just a journal entry. I am asking about what happens for the $a>4$ case which I suspect is an open question.
Relevant OEIS: $a=1$,$a=2$, $a=3$,$a=4$. These links reference a text by Fine which I haven't yet seen. (But if someone who owns it wanted to confirm the formulae below... I wouldn't complain. I am confident about them but these are verified empirically and I haven't proven this explicitly but I hope that my formulas match up with: Page 78 of Basic Hypergeometric Series and Applications, Amer. Math. Soc., 1988;).
Let $\phi_a(r)$ be the number of solutions of $x^2+ay^2=r$.
Then for $a\in 1,2,3,4$ $$\phi_a(r)=2\sum_{d|r}\chi_a(d)$$
Where $\chi_{1}(x) = \cases{ \hspace{.14 in} 2 \hspace{1.86 in} \text{ when } x \cong 1 \text{ mod }4 \\ -2 \hspace{1.86 in} \text{ when }x\cong 3 \text{ mod }4 \\ \hspace{.14 in} 0 \hspace{1.86 in} \text{ when } 2|x }$
Where $\chi_{2}(x) = \cases{ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 1 \text{ mod }8 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x\cong 3 \text{ mod }8 \\ -1 \hspace{1.86 in} \text{ when } x \cong 5 \text{ mod }8 \\ -1 \hspace{1.86 in} \text{ when } x\cong 7 \text{ mod }8 \\ \hspace{.14 in} 0 \hspace{1.86 in} \text{ when } 2|x }$
Where $\chi_{3}(x) = \cases{ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 1 \text{ mod }12 \\ -1 \hspace{1.86 in} \text{ when } x\cong 2 \text{ mod }12 \\ \hspace{.14 in} 3 \hspace{1.86 in} \text{ when } x \cong 4 \text{ mod }12 \\ -1 \hspace{1.86 in} \text{ when } x\cong 5 \text{ mod }12 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 7 \text{ mod }12 \\ -3 \hspace{1.86 in} \text{ when } x\cong 8 \text{ mod }12 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 10 \text{ mod }12 \\ -1 \hspace{1.86 in} \text{ when } x\cong 11 \text{ mod }12 \\ \hspace{.14 in} 0 \hspace{1.86 in} \text{ when } 3|x }$
UPDATE: I also have found $\chi_4$ which is of a similar pattern.
Where $\chi_{4}(x)= \cases{ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 1 \text{ mod }16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 2 \text{ mod } 16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 3 \text{ mod } 16 \\ \hspace{.14 in} 2 \hspace{1.86 in} \text{ when } x \cong 4 \text{ mod } 16 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 5 \text{ mod }16 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 6 \text{ mod }16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 7 \text{ mod }16 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 9 \text{ mod }16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 10 \text{ mod }16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 11 \text{ mod }16 \\ -2 \hspace{1.86 in} \text{ when } x \cong 12 \text{ mod }16 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 13 \text{ mod }16 \\ \hspace{.14 in} 1 \hspace{1.86 in} \text{ when } x \cong 14 \text{ mod }16 \\ -1 \hspace{1.86 in} \text{ when } x \cong 15 \text{ mod }16 \\ \hspace{.14 in} 0 \hspace{1.86 in} \text{ when } 8|x }$
Note that these functions have some odd symmetry to them in addition to being periodic:
$\chi_a(x)=\chi_a(x+4at)$
$\chi_a(2a+k)= -\chi_a(2a-k)$
Why I think this is cool!
It gets us explicit series of rationals for transcendental numbers like:
$\pi\sqrt{2}=4(1+\frac{1}{3}-\frac{1}{5}-\frac{1}{7}+\frac{1}{9}+\frac{1}{11}+\dots$.
I know this because $\sum_{r=1}^{R^2} {\phi_2(r)}$ should approximate the area inside $x^2+2y^2=R^2$.
Update 9/10/18:
Let's write $\psi(\vec{v},n)=\sum_{d|n}{\vec{v}(n)}$ where for a finite vector $\vec{v}$ we interpret $\vec{v}(n)$ as the $n$th position of $\vec{v}$ mod the length of $\vec{v}$. That is, if $\vec{v}=(v_1, v_2 \dots v_p)$ we define an infinite vector of period $p$. We let $\vec{v}(n)=v_n=v_{n+p}$ for all whole numbers $n$.
$$\begin{align} & \phi_{1}(n)= 2\psi\bigg((2,0,-2,0),n\bigg) \\ & \phi_{2}(n)= 2\psi\bigg((1,0,1,0,-1,0,-1,0),n\bigg)\\ &\phi_{3}(n)= 2\psi\bigg((1,-1,0,3,-1,0,1,-3,0,1,-1,0),n \bigg) \end{align} $$
I think this notation is superior to the many cases above. If we look at the OEIS links above we will find the length of vector seems to be communicated in a statement about how this relates to the Euler Transform. In the $a=3$ case, Michael Somos writes of an "Euler transform of period 12 sequence $[ 2, -3, 4, -1, 2, -6, 2, -1, 4, -3, 2, -2, ...]$" I suppose I will need to look into what this Euler Transform means... For now I will comment that the period of this sequence commented on matches the length of this vector for $a=1,2,3,4,7,$ and I would assume for $a=5$. I haven't worked out the details for $a=5$ but this is a sequence of period $60$.
Just as a note: This seems to be a property that may happen only when $x^2$ is accompanied with the coefficient $1$. I will let $\phi_{(2,3)}(n)$ denote the number of integer solutions to $2x^2+3y^2=n$ which can be found here. In this link we can find the same type of comment: "Euler transform of period 24 sequence $[0, 2, 2, -3, 0, -1, 0, -1, 2, 2, 0, -4, 0, 2, 2, -1, 0, -1, 0, -3, 2, 2, 0, -2, ...]$." However, there doesn't seem to exist any vector $\vec{w}$ of length $24$ such that $\phi_{(2,3)}(n)=\psi({\vec{w},n)$.