Skip to main content
added 41 characters in body
Source Link
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola (when $r > 0$) or an ellipse (when $r < 0$).
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(1, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<6087 values of a, instead of original 66>]
6087
0.41802382469177246
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola.
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(1, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<6087 values of a, instead of original 66>]
6087
0.41802382469177246
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola (when $r > 0$) or an ellipse (when $r < 0$).
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(1, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<6087 values of a, instead of original 66>]
6087
0.41802382469177246
deleted 4 characters in body
Source Link
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola.
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(-top1, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<12174[<6087 values of a, instead of original 66>]
121746087
0.795045614242553741802382469177246
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola.
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(-top, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<12174 values of a, instead of original 66>]
12174
0.7950456142425537
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola.
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(1, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<6087 values of a, instead of original 66>]
6087
0.41802382469177246
added 5 characters in body
Source Link
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's conversionidea to convert to a hyperbola.
from time import time
t0 = time()
r = -2
listA = []
top = 100
for n in range(-top, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<12174 values of a, instead of original 66>]
12174
0.7950456142425537
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's conversion to a hyperbola.
from time import time
t0 = time()
r = -2
listA = []
top = 100
for n in range(-top, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<12174 values of a, instead of original 66>]
12174
0.7950456142425537
  1. The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola.
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(-top, top + 1):
    for d in range(1, top + 1):
        if gcd(n,d) == 1:
            t = QQ(n) / QQ(d)
            a = t^2 / (r - t^2)
            e = sqrt(a * (a + 1) / r)
            if (e in QQ) and a != -1 and a != 0:
                listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<12174 values of a, instead of original 66>]
12174
0.7950456142425537
Source Link
Loading