︠f72b49be-2436-4b73-9895-2d5b383ca373i︠ %html

You can use Sage to teach Calculus

︡cc394ba6-3d55-4779-9284-dd85ad97de5a︡{"html": "

You can use Sage to teach Calculus

"}︡ ︠3ba46d7b-ab02-4b14-92fb-3c0643162178︠ 2 + 3 ︡590e432f-cc32-4307-a6c5-56015a7344b4︡{"stdout": "5"}︡ ︠787c84d2-38a9-4761-a2af-80ef2e64e776︠ x = var('x') show(plot(sin(x^2), 0, pi)) ︡23ef6817-3374-4f6a-ab8c-cd656d235cf4︡︡ ︠9ed273c6-9743-458d-b367-ce5eebd4129b︠ a = integrate(sin(x^2),x); a ︡1faf6278-e25a-4d91-a774-0536b73fb931︡{"stdout": "sqrt(pi)*((sqrt(2)*I + sqrt(2))*erf((sqrt(2)*I + sqrt(2))*x/2) + (sqrt(2)*I - sqrt(2))*erf((sqrt(2)*I - sqrt(2))*x/2))/8"}︡ ︠c45c2eb5-ce77-4bde-95ea-13f6ce135195︠ show(a) ︡c0832485-2ca9-4dae-b7cf-b3fec370641d︡{"html": "
\\frac{{\\sqrt{ \\pi } \\left( {\\left( {\\sqrt{ 2 } i} + \\sqrt{ 2 } \\right) \\text{erf} \\left( \\frac{{\\left( {\\sqrt{ 2 } i} + \\sqrt{ 2 } \\right) x}}{2} \\right)} + {\\left( {\\sqrt{ 2 } i} - \\sqrt{ 2 } \\right) \\text{erf} \\left( \\frac{{\\left( {\\sqrt{ 2 } i} - \\sqrt{ 2 } \\right) x}}{2} \\right)} \\right)}}{8}
"}︡ ︠cfc92ba7-5cfd-431d-a2a1-720a91528e0e︠ search_src("integrate") ︡61fd88c9-21b0-4d79-8917-4610b03df74f︡{"html": "

Search Source Code: integrate

  1. calculus/all.py\n
  2. calculus/calculus.py\n
  3. calculus/functional.py\n
  4. calculus/tests.py\n
  5. calculus/wester.py\n
  6. functions/elementary.py\n
  7. functions/functions.py\n
  8. functions/piecewise.py\n
  9. functions/special.py\n
  10. gsl/gsl_monte.pxi\n
  11. gsl/integration.pyx\n
  12. interfaces/kash.py\n
  13. interfaces/maxima.py\n
  14. misc/functional.py\n
  15. misc/latex.py\n
  16. numerical/test.py\n
  17. schemes/elliptic_curves/monsky_washnitzer.py\n
  18. schemes/elliptic_curves/padics.py\n
  19. schemes/hyperelliptic_curves/hyperelliptic_padic_field.py\n
  20. server/notebook/tutorial.py\n
  21. structure/coerce_maps.pyx\n
"}︡ ︠04cc05f8-68db-41b5-8a72-edffb6d6e37e︠ var('a,b,c,X') s = solve(a*X^2 + b*X + c == 0, X) show(s[0]) ︡b2f141aa-b1d8-48ec-bde9-20e11d8413f2︡{"html": "
X = \\frac{-\\left( \\sqrt{ {b}^{2} - {{4 a} c} } \\right) - b}{{2 a}}
"}︡ ︠cc29a825-2c24-4859-8e5f-60335f90642di︠ %html

Finite Field Arithmetic

︡c2696a77-b15d-45dc-8622-03726df6b94c︡{"html": "

Finite Field Arithmetic

"}︡ ︠e252673d-8a65-41ac-8906-908eaeb6c0a0︠ k. = GF(2^8) k ︡ba815053-7b82-4972-8f2e-23a42c43485c︡{"stdout": "Finite Field in a of size 2^8"}︡ ︠e3c89123-d190-49f1-8e3e-072d81b48d70︠ latex(k) ︡6f6b0853-8241-4df2-a40a-5a859074cd3d︡{"stdout": "\\mathbf{F}_{2^{8}}"}︡ ︠bfacc3a3-6e43-4674-a597-302958321cfe︠ show(k) ︡3522919d-4892-474a-8c40-f5a4ba66328c︡{"html": "
\\mathbf{F}_{2^{8}}
"}︡ ︠7a037d00-b597-4c37-ab92-1bbc30abf884︠ P. = GF(3)['x'] while True: p = P.random_element(degree=5) if p.is_irreducible() and p.degree() == 5: break p ︡a5092559-69bb-47ea-b221-ba71f4793750︡{"stdout": "x^5 + 2*x^4 + 2*x^3 + 2*x^2 + x + 2"}︡ ︠5e9fe523-b140-427e-9b31-95cfc8fdc310︠ p = p/p.leading_coefficient() p ︡dc9a878d-cbe3-4f5d-9abc-7b5c0b6d19d3︡{"stdout": "x^5 + 2*x^4 + 2*x^3 + 2*x^2 + x + 2"}︡ ︠9f3a40f1-d988-4a94-a225-da1b02db06da︠ k.
= GF(3^5, modulus=p) k.modulus() ︡75928b36-ded2-408e-ac0d-860efa8012bb︡{"stdout": "x^5 + 2*x^4 + 2*x^3 + 2*x^2 + x + 2"}︡ ︠a1c48172-2374-4881-b2e2-9744cc24aa7fi︠ %html

Dense Linear Algebra over the Rationals and Integers

The NTRUEncrypt Public Key Cryptosystem is based on the hard mathematical problem of finding very short vectors in lattices of very high dimension. Generate a ntru-like lattice of dimension ($400 \times 400$), with the coefficients $h_i$ chosen as random $130$ bits integers and parameter $q=35$: $$ \left( \begin{array}{cccccccc} 1 & 0 & \dots & 0 & h_0 & h_1 & \dots & h_{d-1}\\ 0 & 1 & \dots & 0 & h_1 & h_2 & \dots & h_0 \\ \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\ 0 & 0 & \dots & 1 & h_{d-1} & h_0 & \dots & h_{d-1}\\ 0 & 0 & \dots & 0 & q & 0 & \dots & 0 \\ 0 & 0 & \dots & 0 & 0 & q & \dots & 0 \\ \dots & \dots & \dots & \dots & \dots & \dots & \dots & \dots \\ 0 & 0 & \dots & 0 & 0 & 0 & \dots & q \\ \end{array} \right) $$ ︡d76d534d-ce03-418b-bd9b-8fa9ca3a9f39︡{"html": "

Dense Linear Algebra over the Rationals and Integers

\r\n\r\nThe NTRUEncrypt Public Key Cryptosystem is based on the hard mathematical problem of finding very short vectors in\r\nlattices of very high dimension.\r\n\r\nGenerate a ntru-like lattice of dimension ($400 \\times 400$), with the\r\ncoefficients $h_i$ chosen as random $130$ bits integers and parameter $q=35$:\r\n\r\n$$\r\n\\left( \\begin{array}{cccccccc}\r\n 1 & 0 & \\dots & 0 & h_0 & h_1 & \\dots & h_{d-1}\\\\\r\n 0 & 1 & \\dots & 0 & h_1 & h_2 & \\dots & h_0 \\\\\r\n \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots \\\\\r\n 0 & 0 & \\dots & 1 & h_{d-1} & h_0 & \\dots & h_{d-1}\\\\\r\n 0 & 0 & \\dots & 0 & q & 0 & \\dots & 0 \\\\\r\n 0 & 0 & \\dots & 0 & 0 & q & \\dots & 0 \\\\\r\n \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots & \\dots \\\\\r\n 0 & 0 & \\dots & 0 & 0 & 0 & \\dots & q \\\\\r\n\\end{array} \\right)\r\n$$"}︡ ︠d99ba249-c7df-4ca9-85a7-b2db1e6d996c︠ from sage.libs.fplll.fplll import gen_ntrulike A = gen_ntrulike(200,130,35) time B = A.LLL(algorithm='fpLLL:fast') ︡ae610beb-a774-477e-9baa-bd33e1e0c674︡{"stdout": "Time: CPU 0.14 s, Wall: 0.24 s"}︡ ︠7d480b42-774a-4675-ab48-1b091ee0ae84︠ n = 100 a = random_matrix(QQ,n, n+1, num_bound=2^64, den_bound=1) time a.echelonize() ︡be877959-9555-4881-be6a-c8a98838517d︡{"stdout": "Time: CPU 0.14 s, Wall: 0.14 s"}︡ ︠f05e0552-3518-4e45-b480-20862838c9e8︠ %magma n := 100; a := RMatrixSpace(RationalField(), n,n+1)![Random(1,2^64): i in [1..n*(n+1)]]; time e := EchelonForm(a); ︡58e2fb93-a143-4df6-9e9c-44310f2e1543︡{"stdout": "Time: 2.100"}︡ ︠e083bebb-7ac8-4914-8d9a-f51a8401343ai︠ %html

Dense Linear Algebra over Finite Fields

︡ac5ab044-23f9-4b73-8811-2fbcc48c6501︡{"html": "

Dense Linear Algebra over Finite Fields

"}︡ ︠df9a561a-0768-44f3-94c7-1f0465f6e154︠ A = random_matrix(GF(127),2000,2000) B = random_matrix(GF(127),2000,2000) time C = A._multiply_linbox(B) ︡4f348042-6493-4b8a-9f44-1714069974c8︡{"stdout": "Time: CPU 2.60 s, Wall: 3.13 s"}︡ ︠28a581ab-305f-46eb-a46e-a78ca75574f2︠ time A.echelonize() ︡0d5b5696-c22a-49fc-9240-c2a6276cb587︡{"stdout": "CPU time: 1.50 s, Wall time: 1.54 s"}︡ ︠e519f9bc-2c5c-4e0c-9201-1e9f3a0005d3︠ n = 5000 A = random_matrix(GF(2),n,n) time E = A.echelon_form() ︡e798f908-30de-4ff3-92b5-d5724f52add5︡{"stdout": "Time: CPU 0.20 s, Wall: 0.21 s"}︡ ︠e1cf8906-b1a6-40ad-bf18-e4d29963be97︠ %magma n := 5000; k := GF(2); A := Random(RMatrixSpace(k, n,n)); time E := EchelonForm(A); ︡5a7e5913-88ab-4d14-98da-521f96479f00︡{"stdout": "Time: 0.700"}︡ ︠9bbcab8f-5aa9-4106-bee0-0fc469921383︠ n = 20000 A = random_matrix(GF(2),n,n) time E = A.echelon_form() ︡bc663604-74dd-4229-9a54-1726cb11ef66︡{"stdout": "Time: CPU 12.70 s, Wall: 13.25 s"}︡ ︠8923d5a9-cead-43ed-a4d8-cc3833f61412︠ %magma n := 20000; k := GF(2); A := Random(RMatrixSpace(k, n,n)); time E := EchelonForm(A); ︡2a9171fc-7d21-4e71-a47b-c60d65c63535︡{"stdout": "Time: 14.510"}︡ ︠b81c5890-cfa1-419e-a322-fa2dd7aa1394i︠ %html

Sparse Linear Algebra over Finite Fields

︡c0ba92c2-8b45-4805-bd80-c59b32785e74︡{"html": "

Sparse Linear Algebra over Finite Fields

"}︡ ︠0bec1120-e4ef-4b5b-8c31-b7738c82310e︠ A = random_matrix(GF(127),3000,3000,density=1.0/3000, sparse=True) time A.echelonize() A.rank() ︡f944101c-2ce1-44df-978e-5c4732305bb3︡{"stdout": "Time: CPU 0.11 s, Wall: 0.16 s\n1635"}︡ ︠5079b33f-6fe2-4831-bc1b-262cafb1e5b6︠ A = random_matrix(GF(127),1500,1500,density=10/1500, sparse=True) b = random_matrix(GF(127),1500,1) time c = A\b (A*c) == b ︡bbb5e125-ff26-4c42-a8a4-fb5d45efffd8︡{"stdout": "Time: CPU 3.27 s, Wall: 3.72 s\nTrue"}︡ ︠34b75521-4f88-4b4c-9418-023115889031︠ n = 300 A = random_matrix(GF(127),n,n+100,sparse=True,density=2/n) A.echelonize() A.visualize_structure() ︡d8792486-9979-4010-981b-518cce31f4f1︡︡ ︠0b49420c-307a-48ac-a978-533a8ea58279︠ sr = mq.SR(4,2,2,4,gf2=True, allow_zero_inversions=True) F,s = sr.polynomial_system() A,v = F.coefficient_matrix() A.visualize_structure(maxsize=600) ︡62fc023e-dd8f-466a-9d3a-d9f2856b7d2c︡︡ ︠c934a520-74fe-401c-b881-3d45497368bai︠ %html

Factoring

︡3ea6498e-27f2-41dd-9c05-7d7dceded090︡{"html": "

Factoring

"}︡ ︠3cced520-9457-462f-aa1b-f3652ee0b8d2︠ time factor(next_prime(2^40) * next_prime(2^300),verbose=0) ︡ff310c2f-83cd-4a2a-9e05-44cc8e46b3fc︡{"stdout": "1099511627791 * 2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397533\nCPU time: 3.99 s, Wall time: 4.82 s"}︡ ︠e41c9667-9f26-4ed0-bf10-0a1391d48ec1︠ time ecm.factor(next_prime(2^40) * next_prime(2^300)) ︡f590cf65-741f-4a9a-9df7-73a75ee1c70d︡{"stdout": "[1099511627791, 2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397533]\nCPU time: 0.18 s, Wall time: 1.40 s"}︡ ︠b7db81d6-8815-457f-8bc3-28df69b7cbce︠ v,t = qsieve(next_prime(2^90)*next_prime(2^91),time=True) print v, t[:4] ︡7038208c-5e50-4bce-a097-2bb51ef02d5d︡{"stdout": "[1237940039285380274899124357, 2475880078570760549798248507] 3.99"}︡ ︠77d107ed-33e3-45a9-bba4-ed21e2aecdedi︠ %html

Elliptic Curves

︡24c13007-15f6-4fb6-86e4-33e08e4c5992︡{"html": "

Elliptic Curves

"}︡ ︠909f044c-18e4-4fa2-afe6-25a4613ac675︠ e = EllipticCurve("37a") # Cremona Label show(e) ︡73483383-f1b6-47dd-8d6a-75252666ce70︡{"html": "
y^2 + y = x^3 - x
"}︡ ︠388b5168-960e-436d-b15f-8bb5a338efae︠ show(plot(e)) ︡a18461c3-877f-4dda-a00a-20084d41165d︡︡ ︠ad3deeb4-d65a-4b80-930e-9faa1eb7e0a9︠ #e.aplist e.a_invariants() ︡3a1bacbf-57ed-48a9-86c1-85671e3d8ff5︡{"stdout": "[0, 0, 1, -1, 0]"}︡ ︠e0cc54d3-1540-4176-b0fa-433ea2119218︠ print e.aplist(20) time n = e.aplist(10^6) ︡7acfa5f5-5e65-4da2-a336-38914c074b61︡{"stdout": "[-2, -3, -2, -1, -5, -2, 0, 0]\nTime: CPU 5.22 s, Wall: 6.00 s"}︡ ︠e485fd86-bcec-4a87-854e-33f066cb817b︠ %magma print GetVersion(); E := EllipticCurve([0,0,1,-1,0]); print TracesOfFrobenius(E, 20); time n := TracesOfFrobenius(E,10^6); ︡5fd870c7-dc63-4b43-b2d4-83dd8064e45d︡{"stdout": "2 14 14\n\n[ -2, -3, -2, -1, -5, -2, 0, 0 ]\nTime: 5.980"}︡ ︠793e3fde-41f3-4fd7-aeb1-91ca534d6e2a︠ E = e.change_ring(GF(997)) show(E.plot()) ︡9e32398e-9e38-449d-88f9-2cd03c0e0a20︡︡ ︠bb3431e7-5221-4628-8f4e-460a67bd5149︠ k = GF(next_prime(10^7)) E = EllipticCurve(k, [k.random_element(),k.random_element()]) E ︡11dc0171-c3d8-49c8-8e18-c0d0fae64e97︡{"stdout": "Elliptic Curve defined by y^2 = x^3 + 3004046*x + 7315639 over Finite Field of size 10000019"}︡ ︠1db7ead5-31ad-47f3-afe4-3759ca34604a︠ P = E.random_element() P.order() ︡db58ba69-2d19-43fc-8b5b-b486b3969711︡{"stdout": "9997377"}︡ ︠d8768adb-5510-4bb4-afb1-c3004983b05a︠ E.cardinality() ︡dac41c25-f1c1-4000-bde4-1485632a7f9c︡{"stdout": "9997377"}︡ ︠a92b9145-a157-4297-8db5-f714b952a654︠ 2*P + P ︡68590259-f0d3-4b92-a319-3f2399ee948d︡{"stdout": "(6921336 : 2053572 : 1)"}︡ ︠96152ad3-1bf9-483e-b1e2-cafd9007d445i︠ %html

p-Adic Numbers

︡ee8d649f-17c8-448e-9137-ffb7875ef058︡{"html": "

p-Adic Numbers

"}︡ ︠ecbf770e-cd52-4df4-a459-181eeb49f07b︠ R = Zp(5) e = R(3125346) f = R(5*34234234) t = cputime() for i in xrange(10^6): z = e*f cputime(t) ︡21ef20e0-cb03-4678-97a2-49bdbcc8d72f︡{"stdout": "0.45693099999999731"}︡ ︠aeaee59c-0bd3-4f99-970c-57a347be5d6a︠ %magma R := pAdicRing(5); e := R!3125346; f := R!5*34234234; time for i in [1..10^6] do z := e*f; end for ︡216c378d-4f89-43eb-877c-cc7955abbd2e︡{"stdout": "Time: 0.750"}︡ ︠4d4b2a96-8786-47e6-b5b0-bf824fdc4904︠ gp.eval("e = %s"%(e._gp_().name())) gp.eval("f = %s"%(f._gp_().name())) ︡68468859-c4c8-4139-a286-0778a5756c28︡{"stdout": "'4*5 + 5^2 + 4*5^3 + 3*5^4 + 4*5^5 + 4*5^6 + 3*5^8 + 2*5^9 + 2*5^10 + 3*5^11 + O(5^21)'"}︡ ︠5e72eacf-b573-462a-9019-576365de449a︠ %gp gettime; for(i=1,10^6,z=e*f); gettime/1000.0 ︡8b7f24a4-c847-4a02-aadf-2bbee8d2ebb9︡{"stdout": "0.76500000000000000000000000000000000000"}︡ ︠b9395bb3-deb8-4a8d-87a0-32588248eb86i︠ %html

Graph Theory

︡0bc6d725-5d3c-4f6c-b885-a605950ff447︡{"html": "

Graph Theory

"}︡ ︠3e841376-12d4-433f-8549-9364ebf61745︠ D = graphs.DodecahedralGraph() D.show() ︡366027df-5fd6-4492-848d-28195b141203︡︡ ︠5d514e03-f39c-4bd0-8a70-541d81228fdd︠ D.show3d() ︡0deadeb4-40eb-4469-baad-6b05bb2e9e55︡︡ ︠674cafaf-30e4-4c7a-b53b-6dad2d1ec151︠ gamma = SymmetricGroup(20).random_element() E = D.copy() E.relabel(gamma) D.is_isomorphic(E) ︡2855a179-a0fc-4dfe-b3d1-24823e39100f︡{"stdout": "True"}︡ ︠ee422dc9-0019-454e-ac6f-b4cfc9c3cda4︠ D.radius() ︡0c6f3b0f-8080-45ae-8dba-1ac0f6705984︡{"stdout": "5"}︡ ︠4fa13cf6-988d-4841-a787-24bc46df1c83i︠ %html

Univariate Polynomials over $\mathbf{Z}$

︡d9dd4b86-449f-46ae-bdf1-3d6a2e6bbde4︡{"html": "

Univariate Polynomials over $\\mathbf{Z}$

"}︡ ︠bee63997-4dec-4fc0-9eba-b480a4467bdc︠ P. = ZZ[] deg = 32; coeff=64 f = P.random_element(degree=deg,x=0,y=2^coeff) g = P.random_element(degree=deg,x=0,y=2^coeff) ︡6463fe69-d6aa-4249-8ba6-18fc6fd8752c︡︡ ︠a225c092-bd7f-4edc-a220-eec3e5ffc7a3︠ type(f) ︡b3f55aa1-c6de-474a-88e8-60f60da756de︡{"stdout": ""}︡ ︠20d71aad-aea4-4adf-94a3-bd4995f6f7d8︠ %time for _ in xrange(10^5): w = f*g ︡87dd7ff6-3e1c-4629-8621-e78468237fc1︡{"stdout": "CPU time: 1.39 s, Wall time: 1.42 s"}︡ ︠d9fd7c3f-3da4-4b61-92cf-e944450e5967︠ gp.eval('f = Pol(%s)'%f.list()) _ = gp.eval('g = Pol(%s)'%g.list()) ︡74bbbf0c-ecb2-4f58-ba79-0e22b809e1d2︡︡ ︠499e363f-bf5f-440c-93f2-c4566cf251cb︠ %gp gettime; for(i=1,10^5,w=f*g); gettime/1000.0 ︡38a70bd9-b9bd-4607-b749-a35933bd0876︡{"stdout": "9.1200000000000000000000000000000000000"}︡ ︠8398cdd0-7a63-42e3-bb65-9a187858edaf︠ %magma R := PolynomialRing(IntegerRing()); ︡1efe719c-2e59-42dc-bc8d-f32e90e00f34︡︡ ︠dda124a2-e22f-4760-af4c-e4430e5e1b48︠ magma.eval('f := R!%s'%f.list()) _ = magma.eval('g := R!%s'%g.list()) ︡ae78a9dd-ad86-4705-9157-ca2f98864c84︡︡ ︠111ce0ac-3d2d-414e-a240-c40bf0d0afaa︠ %magma time for i in [1..10^5] do w := f*g; end for; ︡3f5bd422-24c8-4ad5-948e-185636354eb3︡{"stdout": "Time: 14.260"}︡ ︠bac52883-3597-4912-b7cc-a105230f7830︠ # NTL ff = ntl.ZZX(f.list()) gg = ntl.ZZX(g.list()) ︡c1462070-bf75-46eb-ab1e-50b076c7cd04︡︡ ︠112fadac-8ad5-4638-ac4b-4d25e354b7c8︠ time for i in xrange(10^5): w = ff*gg ︡46ba56fa-358d-4fa1-b31f-6d7e7045f25a︡{"stdout": "CPU time: 8.19 s, Wall time: 8.51 s"}︡ ︠870d9cbe-df74-4125-8436-2306f3baeb53i︠ %html

Multivariate Polynomial Rings over Finite Fields

︡908ee64b-37f8-4dde-b64a-ad1e872b04d4︡{"html": "

Multivariate Polynomial Rings over Finite Fields

"}︡ ︠564cc772-f90c-43eb-818d-401f2cadbbc6︠ #In SAGE P. = PolynomialRing(QQ,3) p = (x + y + z + 1)^20 # the Fateman fastmult benchmark q = p + 1 time r = p*q ︡afb9c266-f8b8-482d-8057-23d38878451d︡{"stdout": "Time: CPU 1.09 s, Wall: 1.11 s"}︡ ︠479e2d85-7bf4-409b-8723-b3e9ee5d598b︠ %magma P := PolynomialRing(RationalField(),3); p:= (x + y + z + 1)^20; q:= p + 1; time r:= p*q; ︡442cd181-7186-457a-aa54-28a862acad3b︡{"stdout": "Time: 0.450"}︡ ︠94a8c0c0-ab4a-4d48-9a7f-9452c8a16923︠ #In SAGE P. = PolynomialRing(GF(32003),3) p = (x + y + z + 1)^20 # the Fateman fastmult benchmark q = p + 1 time r = p*q ︡46016797-721a-42f1-b267-ba25cbcaf0f1︡{"stdout": "Time: CPU 0.12 s, Wall: 0.12 s"}︡ ︠a3c32918-d017-4953-bddb-5a61b4e5b8e0︠ %magma P := PolynomialRing(GF(32003),3); p := (x + y + z + 1)^20; q := p + 1; time r := p*q; ︡a0c6590b-5ec1-4cd0-ad58-10115dd0ae70︡{"stdout": "Time: 0.260"}︡ ︠3a0d0e3b-47c3-46bb-b726-933e069ad1ac︠ P = PolynomialRing(GF(32003),10,'x') I = sage.rings.ideal.Cyclic(P,7) t = cputime() gb = I.groebner_basis('libsingular:std') print 'Sage/Singular', cputime(t) I = sage.rings.ideal.Cyclic(P,7) t = magma.cputime() gb = I.groebner_basis('magma:GroebnerBasis') print 'MAGMA', magma.cputime(t) ︡a6cf4305-1e3a-4db8-b6c4-b15e08988678︡{"stdout": "Sage/Singular 2.254657\nMAGMA 0.38"}︡ ︠c697c457-4a7c-4f34-a0cd-e76f63e4e0c8i︠ %html

Algebraic Cryptanalysis

︡55232a10-945d-4033-9525-8c57e09759a6︡{"html": "

Algebraic Cryptanalysis

"}︡ ︠f9d9b7ae-6360-4dd1-b6cc-cc1b7a35e6ea︠ sr = mq.SR(2,1,1,4,gf2=True) sr ︡5dcd718e-971b-4690-afa0-4a154d717f25︡{"stdout": "SR(2,1,1,4)"}︡ ︠729add15-832f-4a51-b835-2fdba8cb128e︠ F,s = sr.polynomial_system() F ︡993ae341-685a-4928-8ad8-3197943a4c9d︡{"stdout": "Polynomial System with 104 Polynomials in 36 Variables"}︡ ︠d5a2c16f-b95a-45cd-989e-8cfef136e3cc︠ gb = F.groebner_basis() Ideal(gb).variety() ︡082080da-6471-4fbb-bbdc-ddbf31ce985e︡{"stdout": "[{s001: 1, s103: 1, s101: 1, x103: 0, s000: 1, x101: 1, k003: 0, k100: 1, k001: 0, k200: 1, x200: 1, k202: 1, x202: 0, w102: 1, w100: 0, w201: 0, s002: 1, w203: 0, k101: 0, s102: 1, s100: 1, x102: 1, x100: 0, k002: 0, k000: 1, x201: 0, k201: 0, x203: 1, k203: 1, k103: 0, w103: 1, k102: 0, w101: 1, w200: 0, s003: 1, w202: 1}, {s001: 1, s103: 0, s101: 1, x103: 1, s000: 1, x101: 1, k003: 0, k100: 0, k001: 1, k200: 0, x200: 1, k202: 1, x202: 0, w102: 1, w100: 1, w201: 1, s002: 0, w203: 1, k101: 0, s102: 1, s100: 1, x102: 0, x100: 0, k002: 0, k000: 0, x201: 0, k201: 1, x203: 0, k203: 0, k103: 1, w103: 1, k102: 1, w101: 0, w200: 1, s003: 1, w202: 1}, {s001: 0, s103: 1, s101: 1, x103: 0, s000: 1, x101: 1, k003: 0, k100: 0, k001: 0, k200: 0, x200: 1, k202: 0, x202: 1, w102: 0, w100: 1, w201: 1, s002: 0, w203: 1, k101: 1, s102: 0, s100: 1, x102: 0, x100: 0, k002: 1, k000: 0, x201: 0, k201: 0, x203: 1, k203: 0, k103: 0, w103: 1, k102: 0, w101: 1, w200: 0, s003: 1, w202: 0}]"}︡ ︠08c97ade-461c-42c6-8734-c1938b70078d︠ s ︡bb41ba6a-be0d-4b75-a9a3-06449721024e︡{"stdout": "{k000: 1, k001: 0, k002: 0, k003: 0}"}︡ ︠4ef97608-e065-4082-8e6f-fa66a9012bf8︠ A,v = F.coefficient_matrix() ︡f53e2869-6b98-4a2e-9847-1c8869985211︡︡ ︠ecd56fd2-8c46-4cbb-9c80-f7a47ef00a4b︠ A.visualize_structure() ︡73627188-d5a6-4cfa-b52c-b7be9a545fee︡︡ ︠b7453203-d6c8-4d51-a289-32cbb026ac31︠ F.round(2) ︡9c4e1d84-d1bd-432b-847b-81242131708b︡{"stdout": "[w200 + k100 + x100 + x102 + x103, w201 + k101 + x100 + x101 + x103 + 1, w202 + k102 + x100 + x101 + x102 + 1, w203 + k103 + x101 + x102 + x103, x100*w100 + x103*w100 + x102*w101 + x101*w102 + x100*w103, x100*w100 + x101*w100 + x100*w101 + x103*w101 + x102*w102 + x101*w103, x101*w100 + x102*w100 + x100*w101 + x101*w101 + x100*w102 + x103*w102 + x102*w103, x102*w100 + x101*w101 + x100*w102 + x103*w103 + 1, x100*w100 + x101*w100 + x103*w100 + x101*w101 + x100*w102 + x102*w102 + x100*w103 + x100, x102*w100 + x100*w101 + x101*w101 + x103*w101 + x101*w102 + x100*w103 + x102*w103 + x101, x100*w100 + x101*w100 + x102*w100 + x102*w101 + x100*w102 + x101*w102 + x103*w102 + x101*w103 + x102, x101*w100 + x100*w101 + x102*w101 + x100*w102 + x101*w103 + x103*w103 + x103, x100*w100 + x102*w100 + x103*w100 + x100*w101 + x101*w101 + x102*w102 + x100*w103 + w100, x101*w100 + x103*w100 + x101*w101 + x102*w101 + x100*w102 + x103*w102 + x101*w103 + w101, x100*w100 + x102*w100 + x100*w101 + x102*w101 + x103*w101 + x100*w102 + x101*w102 + x102*w103 + w102, x101*w100 + x102*w100 + x100*w101 + x103*w101 + x101*w102 + x103*w103 + w103, x100^2 + x100, x101^2 + x101, x102^2 + x102, x103^2 + x103, w100^2 + w100, w101^2 + w101, w102^2 + w102, w103^2 + w103]"}︡