Solving x^2-Dy^2=N, D > 0 and not a perfect square, N divisible by 4, |N| > 4

This finds the fundamental solutions, if any, of the diophantine equation x2-Dy2=N, when N is divisible by 4. These are the solutions (a,b) in each equivalence class as defined by Bengt Stolt with least b ≥ 0, where we have a ≥ 0 if the class is ambiguous. The solutions (x,y) in the class containing (a,b) are given by (x+y√D)/2=±{(a+b√D)/2}{(x1+y1√D)/2}n, n ℇ ℤ, where (x1,y1) is the least solution of x2-Dy2=4.
We use Stolt's bounds for the fundamental solutions, which are, with small changes, sufficient as well as being necessary conditions. (See On the Diophantine equation u2-Dv2=±4N, Archiv för Matematik (1952) 2, nr. 1, 1-23, 2, nr. 10, 251-268.

This is a BCMath version of the BC function stolt0.

Note that this method is only useful for small D and N.

Warning: The program may halt prematurely, without an error message, due to running time limits.

If the Stolt upper bound exceeds 106, the program terminates after calculation of the least solution of Pell's equation.

Taking D=9z2-4 and N=-4z2, the Markoff numbers conjecture is equivalent to the statement that for z ≥ 5, the equation x2 - (9z2-4)y2 = -4z2 has at most one positive solution (x,y) with y < z/√(3z-2). See note.


Enter D (< 1010):
Enter N (a multiple of 4, where 4 < |N| ≤ 1010):

Last modified 11th September 2015
Return to main page