Solving the diophantine equation ax2 + bxy + cy2 + dx + ey +f = 0, where a ≠ 0, b2 - 4ac > 0 is not a perfect square.


Our algorithm is based on a method of John Robertson, communicated to the author on March 29, 2015. Let D = b2 - 4ac. We make a transformation

Dx = X + r, Dy = Y + s, ... (1)

where (r/D, s/D) = (2cd - be, 2ae - bd) is the centre of the hyperbola. This converts ax2 + bxy + cy2 + dx + ey +f = 0 to AX2 + BXY + CY2 = k. After dealing with the case k = 0 (intersection of two lines) we check that t = gcd(A,B,C) divides k and if so, divide through by t. We then investigate solubility of the binary form equation. In the case of solubility, we get g families with representatives (Xh,Yh), with the general solution having the form

X = (γF + δG)/2, Y = (εF + ζG)/2,

where γ = Xh, ε = Yh, δ = -(2Cε+Bγ) and F2 - DG2 = 4, where D = B2 - 4AC. Then F + G√D = ±(Φ/2 + Ψ/2√D)n, n an integer, where (Φ, Ψ) is the least positive solution of Φ2 - DΨ2 = 4. John Robertson has pointed out that it is enough to test the four solutions (Xh,Yh) corresponding to n = 0 and 1, to see if they give integer x and y in equation (1).

The output should be equivalent to that of the Sawilla, Silvester, Williams program This is a BCMath version of BC function ssw3(a,b,c,d,e,f) contained in patz.

Enter a (nonzero):
Enter b:
Enter c:
Enter d:
Enter e:
Enter f:

Last modified 7th April 2015
Return to main page