I am looking to solve Diophantine equation $a^2+5ab+3b^2-c^2=0$.
a, b, c are all positive.
Since the number of solutions are infinite. Lets say we are only interested in solutions till a limit N ie $1 \le a, b, c \le N$. If you have a expression for solution, I would want it to be better than trying all values of a, b till the limit $N$. We need all solutions set (not the number of solutions).
I already have a solution which reads like this:
Consider rational solutions to:
$$x^2+5xy+3y^2=1.\tag1$$
We have $(-1,0)$ is a rational solution.
If $p,q$ are relatively prime integers, there are usually two values $t$ such that $(-1+pt,qt)=(-1,0)+t(p,q)$ is a solution, one with $t=0.$
$$\begin{align}0&=(-1+pt)^2+5(-1+pt)qt+3(qt)^2-1\\&=-2pt+p^2t^2-5qt+5pqt^2+3q^2t^2\\&=t(\left(p^2+5pq+3q^2)t-(2p+5q)\right) > \end{align}$$
So $t=0$ or $t=\frac{2p+5q}{p^2+5pq+3q^2}.$
The. $$(x,y)=\left(\frac{p^2-3q^2}{p^2+5pq+3q^2},\frac{2pq+5q^2}{p^2+5pq+3q^2}\right)$$
And you get $$(a,b,c)=(p^2-3q^2,2pq+5q^2,p^2+5pq+3q^2).\tag2$$
If $(p,q)=(2,1)$ you get your solution $(1,9,17).$
This won't give primitive solutions, in general. When $(p,q)=(5,-2)$ then $(a,b,c)=(-13,0,-13),$ for example.
If $\gcd(p,q)=1,$ we can show $\gcd(a,b)=1$ or $13.$ It can only be $13$ if $p\equiv 4q\pmod{13}.$
Here we have reduced the equation in $a,b,c$ to $p,q$. For any value of p,q we would get a solution. However it is still not very computationally efficient. Lets say we have to generate all such solutions till $N$ ie $a,b,c \le N$ . If I iterate over all values of $-N < p \le N$ and $-N < q \le N$ which makes it's net computational cost $O(N^2)$. It still doesnt guarantee to find all solutions within N. It may miss a few and also it may generate a few false positive (ie >N) . We don't really know which are those p,q which would yeild all solutions which would be $(a,b,c)<= N$. Can you suggest improvements to the solution. Ideally this should be computed in time proportional to the number of solutions and we need not do any checking.
PS: this is a followup question to Solve Diophantine equation $a^2+5ab+3b^2-c^2=0$ The approached for this versions of the questions where are interested in bounded solution are going to be different from the original one and hence should not be merged with the original question.
Assumption of $-N \le p,q \le N$ is over-simplification Obviously we are looking for more tighter bound of $p,q$ if we solve
$1 \le p^2-3q^2 \le N$
$1 \le 2pq+5q^2 \le N$
$1 \le p^2+5pq+3q^2 \le N$
Which is what this question is all about.
If you have any suggestion to take it to anything better than $O(N^2)$ you are welcome.
You can assume we have $O(N^2)$ memory and arithmetic operations +-*/%
as $O(1)$