[Math] How to find integer solutions for an ellipse equation

diophantine equationsnumber theory

How can I find the positive integer solutions to $x$ and $y$, given the integers $a$, $b$ and $c$ in the following ellipse equation in the form:

$\frac{x^2}{a^2} + \frac{y^2}{b^2}=c$

For example, when $a, b, c = 1,2,2$, one possible solution may be $x, y = 1,2$:

$\frac{1^2}{1^2} + \frac{2^2}{2^2}=2$

Best Answer

Gerry Myerson shows that this is a sum-of-two-squares problem.

This is related to: Efficiently finding two squares which sum to a prime

Given a^2 * b^2 * c, we can efficiently find m, n such that m^2 + n^2 = a^2 * b^2 * c. Then it's a simple matter of checking to see if a or b divides m, and if so, if the other value divides n.

I believe an outline of the proof process you want to go through, goes something like this:

Let X = a^2 * b^2 * c If X is divisible by a prime equal to 3 mod 4, then X is divisible by that prime raised to an even power, and both 'm' and 'n' will be divisible by that prime raised to that even power. So we can effectively factor out those primes.

We now have Y divides a^2 * b^2 * c and Y is a product of primes equal to 1 mod 3. And we can look for 'k' and 'l' such that k^2 + l^2 == Y.

If Y is prime, then there is a unique solution, and the above referenced stackexchange page discusses how to find 'k' and 'l'.

If Y is not prime, then we can find a solution for each factor, and combine the partial solutions to enumerate all solutions. Suppose for example that Y = WZ where W and Z are prime and i^2 + j^2 = W and q^2 + r^2 = Z. Then (iq + jr)^2 + (ir - jq)^2 = WZ. There are also solutions involving the conjugates i^2 + (-j)^2 and q^2 + (-r)^2. Equivalent solutions can be avoided by using only the positive form for one of the primes, but allowing either the positive form or the conjugate form for each of the other primes.

Related Question