""" Calculates the Greenberg transform of x^3 + (a0,a1,a2)*x^2 + (b0,b1,b2)*x + (c0,c1,c2) in 3 different ways: * Precompute polynomials for Witt Sum and Prod. (in the most efficient way), then use them to perform sums and prod. * Perform sums and prods using recursion. * Use the formulas for the GT. Best to cut and paste.... We include the times obtained (in boole) as comments. *** TESTED!!! -- compared the results and they all match! *** """ #################################################################### # FIRST WAY: Precompute polynomials for Witt Sum and Prod. load 'memory.py' # to check memory usage load 'witt2_fun.sage' m0=memory() # ####################### # choose char. p=11 # ####################### vecS=WittSum2Pol(p) vecP=WittProd2Pol(p) PR.=PolynomialRing(GF(p)) a=[a0,a1,a2] b=[b0,b1,b2] c=[c0,c1,c2] x=[x0,x1,x2] GT=WittSum22(c,WittProd22(b,x, vecP=vecP), vecS=vecS) GT=WittSum22(GT,WittProd22(a, WittProd22(x,x, vecP=vecP), vecP=vecP), vecS=vecS) GT=WittSum22(GT,WittProd22(x,WittProd22(x,x, vecP=vecP), vecP=vecP), vecS=vecS) print "Total memory usage: " + str(memory(m0)/(1024)^2) + "MB" """ p=5 gives: Total memory usage: 5.8203125MB Exiting SAGE (CPU time 0m0.50s, Wall time 0m7.64s). p=7 gives: Total memory usage: 65.8203125MB Exiting SAGE (CPU time 0m27.48s, Wall time 0m48.18s). p=11 gives: Total memory usage: 3566.3203125MB Exiting SAGE (CPU time 171m5.87s, Wall time 1005m20.61s). """ #################################################################### # SECOND WAY: Perform sums and prods using recursion. load 'memory.py' # to check memory usage load 'witt2_fun.sage' m0=memory() ########################### # choose char. p=11 ########################### PR.=PolynomialRing(GF(p)) a=[a0,a1,a2] b=[b0,b1,b2] c=[c0,c1,c2] x=[x0,x1,x2] GT=WittSum2(c,WittProd2(b,x)) GT=WittSum2(GT,WittProd2(a, WittProd2(x,x))) GT=WittSum2(GT,WittProd2(x,WittProd2(x,x))) print "Total memory usage: " + str(memory(m0)/(1024)^2) + "MB" """ p=5 gives: Total memory usage: 6.8203125MB Exiting SAGE (CPU time 0m0.32s, Wall time 0m2.90s). p=7 gives: Total memory usage: 72.8203125MB Exiting SAGE (CPU time 0m6.69s, Wall time 0m12.51s). p=11 gives: Total memory usage: 4999.3203125MB Exiting SAGE (CPU time 36m51.73s, Wall time 37m53.53s). """ #################################################################### # THIRD WAY: Use the formulas for GT load 'memory.py' # to check memory usage load 'witt2_fun.sage' m0=memory() ######################## # choose char. p=13 ######################## PR.=PolynomialRing(GF(p)) f=c0+b0*x0+a0*x0^2+x0^3 cc2=pol_p_power(f.derivative(x0),p)*x1+ c1+b1*x0^p+a1*x0^(2*p)+SpcFct(f) cc3=pol_p_power(f.derivative(x0),p,2)*x2 + pol_p_power(-NextCoord(3,p)*x0^(2*p)+(2*a1-a0^p*NextCoord(2,p))*x0^p+b1,p)*x1^p + (3*x0^(p^2)+a0^(p^2))*x1^(2*p)+(c2+b2*x0^(p^2)+a2*x0^(2*p^2)) + SpcFct(pol_p_power(f.derivative(x0),p)*x1+ c1+b1*x0^p+a1*x0^(2*p)) + fSpcFct(pol_p_power(f.derivative(x0),p)*x1+ c1+b1*x0^p+a1*x0^(2*p),SpcFct(f)) + Spc4Fct(f) # GT3=[f,cc2,cc3] len(cc3.monomials()) print "Total memory usage: " + str(memory(m0)/(1024)^2) + "MB" """ p=5 gives: Total memory usage: 4.8203125MB Exiting SAGE (CPU time 0m0.29s, Wall time 0m2.12s). p=7 gives: Total memory usage: 33.8203125MB Exiting SAGE (CPU time 0m1.30s, Wall time 0m8.80s). p=11 gives: Total memory usage: 1721.8203125MB Exiting SAGE (CPU time 3m16.01s, Wall time 3m38.22s). p=13 gives: Total memory usage: 8416.57421875MB Exiting SAGE (CPU time 22m48.54s, Wall time 36m40.73s). sage: len(cc3.monomials()) _24 = 153065983 (same as MAGMA!) """