Let $\lambda = (1024 + \sqrt{101})/7$.
Let also $J(x, y) = |(x \lambda + y)^2 - $ round$(x \lambda + y)^2|$.
We want to deduce that $\inf J = 0$ for $(x, y) = (7, -1024) \in \mathbb{Z}^2$.
I know something with real numbers, but I want integers.
I tried periodic continued fractions (Python), but the periods are too large.
How wolfram alpha knows by the digits what is $\lambda$?
After that I tried the simplex algorithm, and the output was: $14772141080301727003860275213039\,x^2 - 2182261520963378741374304192941500\,x + 14772141080301727003860275213039 = 0$
$\Delta = 4761392481269013762405900791716544060291640138310882045235079787916$
Probably, that's because I searched for rational numbers $a = 1, b \le -1, c \ge 1$.
The ideal output would be $(7x - 1024)^2 - 101 = 0$
$\Rightarrow 49x^2 - 14336x + 1048475 = 0$. How to simplify?
The truth is that I can't detect $\cfrac{123456}{654321}$ by the digits.
def detect_sqrt(original, repetition = 1e-6, remainder = 1e-9):
vec = mp.zeros(10240, 1)
restos = mp.zeros(10240, 1)
s = original
fixed = 0
flag = False
for counter in range(0, 10240):
f = mp.floor(s)
vec[counter] = f
s = mp.fsub(s, f)
restos[counter] = s
if mp.fabs(s) < remainder:
s = 0
flag = True
if (vec[0] == vec[counter]) and (counter > 0):
counter = counter - 1
break
for i in range(0, counter):
dif = mp.fabs(restos[i] - s)
if dif < repetition:
flag = True
if (i == 0) and (vec[0] == vec[counter]):
fixed = 0
counter = counter - 1
else:
fixed = i + 1
#print("dif =", dif)
break
if flag:
break
s = mp.fdiv(1, s)
i = counter
w = mp.zeros(i + 1, 1)
for j in range(0, i + 1):
w[j] = vec[j]
mid = counter - fixed + 1
if mid > 1:
if s == 0:
#if vec[i - 1] != 0:
#if counter == 1:
#print("x =", my_int(vec[i-1]), "+ 1/", my_int(vec[i]))
#else:
#print("a_1 =", my_int(vec[i-1]), "+ 1/", my_int(vec[i]))
mid = mid - 1
i = i - 1
#else:
#print("a_1 =", my_int(vec[i]), "+ 1/x")
for j in range(2, mid):
i = i - 1
#print("a_", j, "=", my_int(vec[i]), "+ 1/a_", j - 1)
#if mid > 1:
#print("x =", my_int(vec[fixed]), "+ 1/a_", mid - 1)
#elif s != 0:
#print("x =", my_int(vec[fixed]), "+ 1/x")
j = mid
i = fixed - 1
#if i == 0:
#print("y =", my_int(vec[i]), "+ 1/x")
#elif i != -1:
#print("a_", j, "=", my_int(vec[i]), "+ 1/x")
#while (i > 1):
#i = i - 1
#j = j + 1
#print("a_", j, "=", my_int(vec[i]), "+ 1/a_", j - 1)
#print("y =", my_int(vec[0]), "+ 1/a_", j)
if s == 0:
i = counter
a = vec[i]
b = 1 # a over 1
while i > 0:
i = i - 1
a, b = b, a
a = a + b * vec[i]
#print("x =", my_int(a), "/", my_int(b))
else:
i = counter
a = vec[i]
b = 1 # ax + 1
c = 1 # over
d = 0 # 1x + 0
# print(a, "x +", b, "//", c, "x +", d)
while i > fixed:
i = i - 1
a, b, c, d = c, d, a, b
a = mp.fadd(a, mp.fmul(c, vec[i]))
b = mp.fadd(b, mp.fmul(d, vec[i]))
# print(a, "x +", b, "//", c, "x +", d)
#print(my_int(c), "x^2 +", my_int(d - a), "x +", my_int(-b), "= 0") # x (cx + d) = ax + b
j, a, b, c, d = mp.fadd(power(d - a, 2), mp.fmul(4, mp.fmul(c, b))), a - d, 1, 2*c, 0
#print("x_1 = (", my_int(a), "+", my_int(b), "sqrt(", my_int(j), "))/(", my_int(c), "+", my_int(d), "sqrt(", my_int(j), "))")
#print("x_2 = (", my_int(a), "-", my_int(b), "sqrt(", my_int(j), "))/(", my_int(c), "+", my_int(d), "sqrt(", my_int(j), "))")
while i > 0:
i = i - 1
a, b, c, d = c, d, a, b
a = mp.fadd(a, mp.fmul(c, vec[i]))
b = mp.fadd(b, mp.fmul(d, vec[i]))
#if fixed != 0:
#print("y_1 = (", my_int(a), "+", my_int(b), "sqrt(", my_int(j), "))/(", my_int(c), "+", my_int(d), "sqrt(", my_int(j), "))")
#print("y_2 = (", my_int(a), "-", my_int(b), "sqrt(", my_int(j), "))/(", my_int(c), "-", my_int(d), "sqrt(", my_int(j), "))")
if (fixed > 100) or (counter > 100):
flag = False
return flag, 1, 1, 1, 1 # a/b + c sqrt(j)