如何在有限域F(p)上找到橢圓曲線y^2 = x^3 + ax + b的最小y座標?在SAGE中,a和b大約10^15的數量級,整數p非常大,大約爲10^45的數量級。 我需要在SAGE中找到它,並且我一直在嘗試很多方法。我發佈了一些我的代碼:如何找到橢圓曲線的最小y座標y^2 = x^3 +
maxtime=120960000
p = 976324781263478623476912346213469128736427364
a = 783468734639429
b = 98347874287423
E = EllipticCurve(GF(p),[a,b])
length =50
for i in range(1,maxtime):
e = ZZ.random_element(999999999999)
if E.is_x_coord(I) == true:
temp = E.lift_x(I)
break
i=0
print 'P1:'
print temp
length=0
t=50
count=2
p2=temp+temp
while count < 10000000000:
count=count+1
p2=p2+temp
if (p2[1]>0):
if (ZZ(p2[1]) < ZZ(p-1)):
if (p2[0] > 0):
if(ZZ(p2[0]) < ZZ(p-1)):
if E.is_x_coord(p2[0]) == true:
y2 = E.lift_x(p2[0])
length=len(str(y2[1]))
if length <=11:
print 'p2:'
print y2
print 'count:'
print count
break
if t > length:
t= length
print 'length:'
print t
print 'count:'
print count
print 'p2:'
print y2
print 'failed:'
以上只是帶有隨機數的示例代碼。任何建議或完全不同的想法也會非常有幫助。
非常感謝 JS
這只是一個側面觀察:這種深刻的縮進使我非常懷疑 - 一種經典的「代碼味道」。在你的情況下,如果p2 [1]> 0和ZZ(p2 [1]) 0並且ZZ(p2 [0])
如果x> = 0 y的最小值是sqrt(b)... –
您可以嘗試Shanks-Tonelli算法(http://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm),但問題是找到最小的y。你可以嘗試所有的x值,這似乎是低效的。 –