For what $a,b$ such that $ax^2+by^2 = z^2$? This post made me think about this question.  What is the criterion on positive integer $a,b$ such that,
$$ax^2+by^2 = z^2$$
can be solved in positive integers $x,y,z$?
(Three broad classes are: 1) $a =\square$; 2) $a+b = \square$; and 3) if the Pell-like eqn $z^2-by^2 = a$ is solvable, but I assume there must be a general approach. This is such a basic question that I'm sure this must have been completely answered already.) 

I'm probably the only proponent of this approach for solving Diophantine equations.
Prefer to understand why the solution is, instead of using modular arithmetic.  Especially for complex equations modular arithmetic to use makes no sense.  And this approach allows us immediately to find out whether there is a solution and write a direct formula for the solutions of the equation. The meaning is simple. Recorded equation:
$$aX^2+bXY+cY^2=jZ^2$$          
Solutions can be written if even a single root.$\sqrt{j(a+b+c)}$ , $\sqrt{b^2 + 4a(j-c)}$ , $\sqrt{b^2+4c(j-a)}$    the solution is, if at least one root of a whole.   
Then the solution can be written. 
In the case when the root $\sqrt{j(a+b+c)}$ whole.         
$$X=(2j(b+2c)^2-(b^2+4c(j-a))(j\pm\sqrt{j(a+b+c)}))s^2+$$
$$+2(b+2c)(\sqrt{j(a+b+c)}\mp{j})sp+(j\mp \sqrt{j(a+b+c)})p^2$$         
$$Y=(2j(2j-b-2a)(b+2c)-(b^2+4c(j-a))(j\pm\sqrt{j(a+b+c)}))s^2+$$ 
$$+2((2j-2a-b)\sqrt{j(a+b+c)}\mp{j(b+2c)})sp+(j\mp\sqrt{j(a+b+c)})p^2$$       
$$Z=(2j(b+2c)^2-(b^2+4c(j-a))(a+b+c\pm\sqrt{j(a+b+c)}))s^2+$$ 
$$+2(b+2c) ( \sqrt{j(a+b+c)} \mp{j})sp + ( a + b + c \mp \sqrt{j(a+b+c)})p^2 $$        
In the case when the root $\sqrt{b^2+4c(j-a)}$ whole.       
Solutions have the form.          
$$X=((2j-b-2c)(8ac+2b(2j-b))-(b^2+4a(j-c))(b+2c\mp\sqrt{b^2+4c(j-a)}))s^2+$$
$$+2(4ac+b(2j-b)\pm{(2j-b-2c)}\sqrt{b^2+4c(j-a)})sp+(b+2c\pm\sqrt{b^2+4c(j-a)})p^2$$
$$Y=((b+2a)(8ac+2b(2j-b))-(b^2+4a(j-c))(2j-b-2a\mp\sqrt{b^2+4c(j-a)}))s^2+$$
$$+2(4ac+b(2j-b)\pm{(b+2a)}\sqrt{b^2+4c(j-a)})sp+(2j-b-2a\pm\sqrt{b^2+4c(j-a)})p^2$$
$$Z=((b+2a)(8ac+2b(2j-b))-(b^2+4a(j-c))(b+2c\mp\sqrt{b^2+4c(j-a)}))s^2+$$
$$+2(4ac+b(2j-b)\pm {(b+2a)}\sqrt{b^2+4c(j-a)})sp+(b+2c\pm\sqrt{b^2+4c(j-a)})p^2$$
In the case when the root $\sqrt{b^2+4a(j-c)}$ whole.      
Solutions have the form.       
$$X=(2j^2(b+2a)-j(a+b+c)(2j-2c-b\pm\sqrt{b^2+4a(j-c)}))p^2+$$ 
$$+2j(\sqrt{b^2+4a(j-c)}\mp{(b+2a)})ps+(2j-2c-b\mp\sqrt{b^2+4a(j-c)})s^2$$        
$$Y=(2j^2(b+2a)-j(a+b+c)(b+2a\pm\sqrt{b^2+4a(j-c)}))p^2+$$ 
$$+2j(\sqrt{b^2+4a(j-c)}\mp{(b+2a)})ps+(b+2a\mp\sqrt{b^2+4a(j-c)})s^2$$
$$Z=j(a+b+c)(b+2a\mp\sqrt{b^2+4a(j-c)})p^2+$$ 
$$+2((a+b+c)\sqrt{b^2+4a(j-c)}\mp{j(b+2a)})ps+ (b+2a\mp\sqrt{b^2+4a(j-c)})s^2$$   
The specifics of these equations is that some quadratic form is equivalent to the other.  This means that if for example no root is not an integer.  You need to find the equivalent quadratic form in which the root is intact.  Usually it is enough to do the replacement  $X\longrightarrow(X+kY)$ or  $Y\longrightarrow(Y+kX)$ .
$p,s - $ any integers which specify.
To find the equivalent form must be substituted in the root and find out what $k$ the root is intact.  Usually boils down to the Pell equation or representation of a number as a sum of two squares. If the answer is no it can be seen immediately.
It would be interesting to find these formulas counterexample, but I have not found.  I think because it really is a formula in General.
