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.) 
 A: Square factors do not matter, as they can be absorbed into the other two variables. So, $a,b$ are squarefree. At this point, any common factor would make it impossible, so we need $\gcd(a,b) = 1.$ Suppose that, for any odd prime $p|a,$ we have $(b|p) = 1;$ also, for any odd prime $q|b,$ we have $(a|q) = 1;$ then there is an integer solution to $a x^2 + b y^2 = z^2.$
It is not enough to just have Jacobi symbols $(a|b)= (b|a)=1$ when they are composite (and odd, I guess).
$$  5 x^2 + 21 y^2 = z^2  $$
has no integer solutions, because $(5|3)= -1$ and $(5|7)=-1.$ 
We are ignoring the prime $2.$ The ability to do this is a big theorem. Any indefinite ternary, such as $a x^2 + b y^2 - z^2,$ is anisotropic in $\mathbb Q_r$ for an even number of finite primes $r.$ This is the global relation for the Hilbert Norm Residue symbol, page 46 in Rational Quadratic Forms by Cassels. Lemma 3.4; we are using the fact that our ternary is isotropic in the real numbers. 
So, something with a $2$ in it, $$ 14 x^2 + 11 y^2 = z^2.  $$ There is a solution because $(14|11)= (3|11) = 1$ and $(11|7) = (4|7) = 1.$
Another with a $2$ in it, $$ 206 x^2 + 107 y^2 = z^2.  $$ There is a solution because  $(107|103) = (4|103) = 1$ and  $(206|107)=(103|107)(2|107)= -1 \cdot -1  = 1.$
Anyway, pages 80-82 in Cassels. 
The even/odd thing means that if there were a problem with the prime $2,$ there would also be a problem with an odd prime. 
On page 82 of Cassels he gives an explicit bound on a solution (if any) with very small values of $x,y,z,$ for your coefficients it is
$$ a x^2 + b y^2 + z^2 < 4ab, $$ which can be re-written as
$$ z^2 < 2 a b.$$ This is a really good bound, the absolute value of $z$ no larger than $\sqrt 2$ times the geometric mean of $a,b.$
 For $ 206 x^2 + 107 y^2 = z^2  $ there are infinitely many solutions, including infinitely many with $\gcd(x,y,z)=1,$ but the ones satisfying the bound are $(7,1,101),$ $(7,5,113),$ $(14,2,202).$
A: 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.
A: Here is an example with this equation.
$$206X^2+107Y^2=Z^2$$
Using the first formula when the root of a $\sqrt{j(a+b+c)}$ .
To do this replacement. $X=x+6Y$ $(1)$
We obtain the equation: $206x^2+2472xY+7523Y^2=Z^2$
This equation according to the first formula is solved and it turns out the formula. Then using $(1)$ and making cuts on multiple values.  we obtain the final formula.
$$X=38213s^2-208ps-7p^2$$
$$Y=15965s^2+1442ps-p^2$$
$$Z=572783s^2+1442ps+101p^2$$
$$***$$
$$X=38213s^2+6ps-7p^2$$
$$Y=4841s^2+1442ps+p^2$$
$$Z=550741s^2+1442ps+101p^2$$
$s,p - $ integers asked us.
This approach allows us to immediately write down the formula.  So. As we want.
