how to avoid error " OverflowError: Python int too large to convert to C long
Here is the code:
import time
p=101135929216614342638630785939670479796699743028362954839791101900457831250749
#p=115792089210356248762697446949407573530086143415290314195533631308867097853951
A=-3#4451685225093714772084598273548424
B=1#2061118396808653202902996166388514
K.<a>=GF(p^2);K.modulus()
#R.<z>=PolynomialRing(K);
R.<z> = PolynomialRing( K, sparse=True )
x= (33711976405538114212876928646556826598899914342787651613263700633485943750250*a + 67423952811076228425753857293113653197799828685575303226527401266971887500500)*z^101135929216614342638630785939670479796699743028362954839791101900457831250749 + (67423952811076228425753857293113653197799828685575303226527401266971887500499*a + 33711976405538114212876928646556826598899914342787651613263700633485943750250)*z
y= (67423952811076228425753857293113653197799828685575303226527401266971887500500*a + 33711976405538114212876928646556826598899914342787651613263700633485943750250)*z^101135929216614342638630785939670479796699743028362954839791101900457831250749 + (33711976405538114212876928646556826598899914342787651613263700633485943750249*a + 67423952811076228425753857293113653197799828685575303226527401266971887500499)*z
f=(11237325468512704737625642882185608866299971447595883871087900211161981250083*a + 56186627342563523688128214410928044331499857237979419355439501055809906250416)*z^303407787649843027915892357819011439390099229085088864519373305701373493752247 + (67423952811076228425753857293113653197799828685575303226527401266971887500499*a + 33711976405538114212876928646556826598899914342787651613263700633485943750249)*z^202271858433228685277261571879340959593399486056725909679582203800915662501499 + 67423952811076228425753857293113653197799828685575303226527401266971887500499*z^202271858433228685277261571879340959593399486056725909679582203800915662501498 + (33711976405538114212876928646556826598899914342787651613263700633485943750250*a + 67423952811076228425753857293113653197799828685575303226527401266971887500499)*z^101135929216614342638630785939670479796699743028362954839791101900457831250751 + 67423952811076228425753857293113653197799828685575303226527401266971887500500*z^101135929216614342638630785939670479796699743028362954839791101900457831250750 + (a + 2)*z^101135929216614342638630785939670479796699743028362954839791101900457831250749 + (89898603748101637901005143057484870930399771580767070968703201689295850000666*a + 44949301874050818950502571528742435465199885790383535484351600844647925000333)*z^3 + 67423952811076228425753857293113653197799828685575303226527401266971887500499*z^2 + (101135929216614342638630785939670479796699743028362954839791101900457831250748*a + 1)*z + 101135929216614342638630785939670479796699743028362954839791101900457831250748
print"\n Elliptic Curve fE(z) = ",f
#fE11 = fE.coefficients();fE11
start = time.time()
E = EllipticCurve(GF(p),[0,0,0,A,B]);
#print"EC=",E
#print (E.points()[:4])
#print "\n Take Two point on Elliptic curve "
P = E.random_point()#[2];E(0,2)
print"\n point1=",P # select Random point P on elliptic Curve
Q =E.random_point()#[4]; E(4,2)
print"\n point2=",Q
# P= E(59708,90244);P
# Q= E(108685,5812);Q
R1=P+Q;
print"\n Addition of two points Existing Approach (P+Q) =",R1
if((P[0]!=Q[0]) and (P[1]!=Q[1]) or (P[0]!=Q[0]) and (P[1]==Q[1])):
R.<z> = PolynomialRing( K, sparse=True )
**g=(((Q[0]-P[0])*y)-((Q[1]-P[1])*x)-(P[1]*Q[0]-Q[1]*P[0])) ;g**#**error obtained at this point**
f1=( f % g ).monic()
print "\n gcd=",f1
#R2=fL.quo_rem(f1);R2
#R3=fE.quo_rem(f1);R3
f2= (z-P[0]-P[1]*a)*(z-Q[0]-Q[1]*a);
print "\n point equation=",f2
f3=f1//f2;
print "\n f3=",f3;
new4 = f3.coefficients();new4
Result=new4[0];Result
#R15=K(-Result);R15
F.<a>=GF(p)
R.<a>=PolynomialRing(F);
R1.<z>=PolynomialRing(R);
f=Result
M=R(f).coefficients();#M
M1= M[1];#M1
M4=M[0];#M4
M2=F(-M4);#M2
M3=F(-M4)
R=(M2*a+M[1]);#R
R1=(M2,M1);#R1
#load("example.sage")
G = E.point((R1));#G
print "\n Addition of two points New Approach(P+Q)=" ,G
end = time.time()
print("the time taken for the existing approach is given by ", end - start)
I can not reproduce your error on my machine. Could you please give us some informations so that someone can try to reproduce your problem:
I couldn't reproduce it, either, for what that's worth.
i am working on sagemath cloud os is MAC no all by sagemath cloud .sagews files the error is overflow error . when i run the code on sagemath cloud error is obtained
sage math version is 7.3 on my macbook pro