""" Calculates the Greenberg transform of x^2 + (a0,a1,a2)*x + (b0,b1,b2) 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] x=[x0,x1,x2] GT=WittSum22(b,WittProd22(a,x, vecP=vecP), vecS=vecS) GT=WittSum22(GT,WittProd22(x,x, vecP=vecP), vecS=vecS) print "Total memory usage: " + str(memory(m0)/(1024)^2) + "MB" """ p=5 gives: Total memory usage: 2.3203125MB Exiting SAGE (CPU time 0m0.26s, Wall time 0m29.49s). p=7 gives: Total memory usage: 4.8203125MB Exiting SAGE (CPU time 0m0.89s, Wall time 0m22.13s). p=11 gives: Total memory usage: 50.3203125MB Exiting SAGE (CPU time 1m57.84s, Wall time 2m4.28s). ######## sage 4.3.1. ################ p=11 gives: Total memory usage: 50.3203125MB Exiting SAGE (CPU time 1m57.77s, Wall time 2m26.30s). ##################################### p=13 gives: Total memory usage: 153.3203125MB Exiting SAGE (CPU time 13m53.49s, Wall time 14m14.26s). p=17 gives: Total memory usage: 922.921875MB Exiting SAGE (CPU time 259m19.63s, Wall time 3834m3.13s). """ #################################################################### # 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] x=[x0,x1,x2] GT2=WittSum2(b,WittProd2(a,x)) GT2=WittSum2(GT2,WittProd2(x,x)) print "Total memory usage: " + str(memory(m0)/(1024)^2) + "MB" """ p=5 gives: Total memory usage: 2.3203125MB Exiting SAGE (CPU time 0m0.24s, Wall time 0m2.02s) p=7 gives: Total memory usage: 5.3203125MB Exiting SAGE (CPU time 0m0.31s, Wall time 0m1.97s). p=11 gives: Total memory usage: 70.8203125MB Exiting SAGE (CPU time 0m7.96s, Wall time 0m13.68s). ######## sage 4.3.1. ################ Total memory usage: 70.3203125MB Exiting SAGE (CPU time 0m6.14s, Wall time 0m15.37s). ##################################### p=13 gives: Total memory usage: 217.8203125MB Exiting SAGE (CPU time 0m40.47s, Wall time 1m7.91s). p=17 gives: Total memory usage: 1354.3203125MB Exiting SAGE (CPU time 11m8.95s, Wall time 12m27.87s). p=19 gives: Total memory usage: 2907.3203125MB Exiting SAGE (CPU time 34m52.06s, Wall time 407m24.24s). """ #################################################################### # THIRD WAY: Use the formulas for GT load 'memory.py' # to check memory usage load 'witt2_fun.sage' m0=memory() ######################## # choose char. p=11 ######################## PR.=PolynomialRing(GF(p),9) f=b0+a0*x0+x0^2 cc2=f.derivative(x0)^p*x1+ b1+a1*x0^p+SpcFct(f) cc3=f.derivative(x0)^(p^2)*x2 +(-NextCoord(2,p)*x0^p+a1)^p*x1^p +x1^(2*p)+(b2+a2*x0^(p^2)) + SpcFct(f.derivative(x0)^p*x1+ b1+a1*x0^p) + fSpcFct(f.derivative(x0)^p*x1+ b1+a1*x0^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: 2.3203125MB Exiting SAGE (CPU time 0m0.24s, Wall time 0m2.49s). p=7 gives: Total memory usage: 4.3203125MB Exiting SAGE (CPU time 0m0.29s, Wall time 0m3.10s). p=11 gives: Total memory usage: 27.3203125MB Exiting SAGE (CPU time 0m1.22s, Wall time 0m3.45s). ######## sage 4.3.1. ################ Total memory usage: 27.3203125MB Exiting SAGE (CPU time 0m1.21s, Wall time 0m5.20s). ##################################### p=13 gives: Total memory usage: 78.3203125MB Exiting SAGE (CPU time 0m3.64s, Wall time 0m5.50s). p=17 gives: Total memory usage: 458.8203125MB Exiting SAGE (CPU time 0m49.43s, Wall time 1m0.55s). p=19 gives: Total memory usage: 976.3203125MB Exiting SAGE (CPU time 2m22.43s, Wall time 4m53.32s). p=23 gives: Total memory usage: 3570.12109375MB Exiting SAGE (CPU time 10m33.81s, Wall time 11m27.72s). # number of monomials sage: len(cc3.monomials()) _43 = 65553940 """