- #1
- 2,168
- 193
Consider quadratic Diophantine equations of the form:
x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the following:
32 – 2×22 = 1
22 – 3×12 = 1
92 – 5×42 = 1
52 – 6×22 = 1
82 – 7×32 = 1
Hence, by considering minimal solutions in x for D ≤ 7, the largest x is obtained when D=5.
Find the value of D ≤ 1000 in minimal solutions of x for which the largest value of x is obtained.
Any idea how to solve this ?
I made a code but its slow. I find some information about the general solution but I didnt understand it much.
http://mathworld.wolfram.com/PellEquation.html
I noticed that there's 427 -D- values which their minimal x values are larger then 10**5. So I don't think brute force can give the solution.
x2 – Dy2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×1802 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the following:
32 – 2×22 = 1
22 – 3×12 = 1
92 – 5×42 = 1
52 – 6×22 = 1
82 – 7×32 = 1
Hence, by considering minimal solutions in x for D ≤ 7, the largest x is obtained when D=5.
Find the value of D ≤ 1000 in minimal solutions of x for which the largest value of x is obtained.
Any idea how to solve this ?
I made a code but its slow. I find some information about the general solution but I didnt understand it much.
http://mathworld.wolfram.com/PellEquation.html
Python:
import time
start = time.perf_counter()
Number = [i for i in range(2,1001)]
Sq1 = [i**2 for i in range(2,int(1001**0.5))]
for i in Sq1:
Number.remove(i)
D_high_values =[]
x_initial = 3
for D in Number:
for x in range(2,10**5):
y = ((x**2-1)/D)
k = str(y**0.5)
if k[-1] == "0" and k[-2] ==".": #testing if the square root is integer
if x_initial < x:
x_initial = x
break
else:
D_high_values.append(D) #collecting values that have larger x value then 10**5
print(D_high_values)
print(x_initial) #highest minimal x up to 10**5
end = time.perf_counter()
print("Time to solve:",end-start)
I noticed that there's 427 -D- values which their minimal x values are larger then 10**5. So I don't think brute force can give the solution.