Query on Brahmagupta-Fibonacci Identity

According to Brahmagupta-Fibonacci Identity, for $p=q\cdot r$ we can prove if any two of the integers $p,q,r$ are of the form $a^2+n\cdot b^2,$ the third must of the same form

This is probably a generalization of this problem or this

Now, I want to determine the $n$ such that if $M=r\cdot s=a^2+n\cdot b^2$ where $(r,s)=1, r$ and $s$ must be of the same form for any integer pair $a,b$

Using Program, it seems that $n=1,2,3,7$ satisfy this

I think the proof for $2$ will be required here

We can safely assume $n$ to be square-free, as its square part(if any) can easily be merged with $b$

Now, if $(a,b)=d$ and $\frac aA=\frac bB=d\implies (A,B)=1$ and $a^2+n\cdot b^2=d^2(A^2+n\cdot B^2)$

As $n$ is square-free, $(A^2,n)=(A,n)=D$(say) and $\frac A{A_1}=\frac nN=D\implies (A_1,N)=1$

Subsequently, $A^2+n\cdot B^2$ becomes $D^2\cdot A_1^2+N\cdot D\cdot B^2=D(D\cdot A^2_1+N\cdot B^2)$ which is not of the form $a^2+n\cdot b^2$ unless $D$ or $N=1$

So, we can focus on $a^2+n\cdot b^2,$ where $(a,n\cdot b)=1$

Some observations can be made:

$(1):$ If $p^c$ divides $M=a^2+n\cdot b^2,$ where integer $c\ge1$ and $p$ is prime,

$a^2\equiv-n\cdot b^2\pmod {p^c}\iff (a\cdot b^{-1})^2\equiv-n\pmod {p^c}$ $\implies -n$ must be a Quadratic residue of $p^c$

This is a necessary condition for $p^c$ to be of the form $a^2+n\cdot b^2$

So, if $2^c$ (where $c\ge3,$) divides $M,n\equiv-1\pmod 8$ as $x^2\equiv e\pmod {2^c}$ is solvable with exactly $4$ solutions $\iff e\equiv1\pmod 8$

$(2):$ Generalizing the solution of this problem,

Let's consider $2^x=a^2+n\cdot b^2$

As $n$ is odd and $(a,b)=1, a\cdot b$ must be odd

One value of $x$ is $y,$ i..e, $2^y=a_1^2+nb_1^2$

and if the smallest value of $x$ is $x_\text{min},$ i.e., $2^{x_\text{min}}=a_2^2+n\cdot b_2^2$

$2^{x_\text{min}+y}=(a_1^2+n\cdot b_1^2)(a_2^2+n\cdot b_2^2)=(a_1a_2\pm n\cdot b_1b_2)^2+n(a_1b_2\mp a_2b_1)^2$

Observe that $a_1a_2\pm n\cdot b_1b_2,a_1b_2\mp a_2b_1$ are even and the highest powers of $2$ that divides each will be same $=2^k$(say).

So, $2^{x_\text{min}+y-2k}=\left(\frac{a_1a_2\pm n\cdot b_1b_2}{2^k}\right)^2+n\left(\frac{a_1b_2\mp a_2b_1}{2^k}\right)^2$

Following this line, we can be prove

$4^k,k\ge 2$ can be represented as $a^2+15b^2$

$2^{3k+2},k\ge 1$ can be represented as $a^2+31b^2$

• Please explain how $p, q, r, a, n, b$ are related. – Hans Engler Jun 8 '13 at 15:28
• @HansEngler, thanks for your observation.Incorporated the missed point. – lab bhattacharjee Jun 8 '13 at 15:33
• Can the answer employ number theory of quadratic number rings, such as results about Euclidean or unique factorization properties, or do you seek a more elementary answer? – Key Ideas Jun 8 '13 at 16:15
• @KeyIdeas, I want to know the pattern of $n$ (if any) via any valid method. – lab bhattacharjee Jun 10 '13 at 15:57