Bhaskara's lemma

Bhaskara's Lemma is an identity used as a lemma during the chakravala method. It states that:
 * $$\, Nx^2 + k = y^2\implies \,N\left(\frac{mx + y}{k}\right)^2 + \frac{m^2 - N}{k} = \left(\frac{my + Nx}{k}\right)^2$$

for integers $$m,\, x,\, y,\, N,$$ and non-zero integer $$k$$.

Proof
The proof follows from simple algebraic manipulations as follows: multiply both sides of the equation by $$m^2-N$$, add $$N^2x^2+2Nmxy+Ny^2$$, factor, and divide by $$k^2$$.


 * $$\, Nx^2 + k = y^2\implies Nm^2x^2-N^2x^2+k(m^2-N) = m^2y^2-Ny^2$$
 * $$\implies Nm^2x^2+2Nmxy+Ny^2+k(m^2-N) = m^2y^2+2Nmxy+N^2x^2$$
 * $$\implies N(mx+y)^2+k(m^2-N) = (my+Nx)^2$$
 * $$\implies \,N\left(\frac{mx + y}{k}\right)^2 + \frac{m^2 - N}{k} = \left(\frac{my + Nx}{k}\right)^2.$$

So long as neither $$k$$ nor $$m^2-N$$ are zero, the implication goes in both directions. (The lemma holds for real or complex numbers as well as integers.)