DeRhamComputation/superelliptic.ipynb

883 lines
31 KiB
Plaintext
Raw Normal View History

2021-08-19 22:35:11 +02:00
{
"cells": [
{
"cell_type": "code",
2021-08-22 21:48:21 +02:00
"execution_count": 115,
2021-08-19 22:35:11 +02:00
"metadata": {},
2021-08-21 18:40:44 +02:00
"outputs": [],
2021-08-19 22:35:11 +02:00
"source": [
"class superelliptic:\n",
" def __init__(self, f, m, p):\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" self.polynomial = Rx(f)\n",
2021-08-19 22:35:11 +02:00
" self.exponent = m\n",
" self.characteristic = p\n",
" \n",
" def __repr__(self):\n",
" f = self.polynomial\n",
" m = self.exponent\n",
" p = self.characteristic\n",
" return 'Superelliptic curve with the equation y^' + str(m) + ' = ' + str(f)+' over finite field with ' + str(p) + ' elements.'\n",
" \n",
" def genus(self):\n",
" r = self.polynomial.degree()\n",
" m = self.exponent\n",
" delta = GCD(r, m)\n",
" return 1/2*((r-1)*(m-1) - delta + 1)\n",
" \n",
" def basis_holomorphic_differentials(self, j = 'all'):\n",
" f = self.polynomial\n",
" m = self.exponent\n",
" p = self.characteristic\n",
" r = f.degree()\n",
" delta = GCD(r, m)\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
2021-08-19 22:35:11 +02:00
" \n",
" basis = {}\n",
2021-08-22 21:48:21 +02:00
" k = 0\n",
2021-08-19 22:35:11 +02:00
" if j == 'all':\n",
" for j in range(1, m):\n",
" for i in range(1, r):\n",
2021-08-19 22:35:11 +02:00
" if (r*j - m*i >= delta):\n",
2021-08-21 20:50:10 +02:00
" basis[k] = superelliptic_form(self, Fxy(x^(i-1)/y^j))\n",
2021-08-19 22:35:11 +02:00
" k = k+1\n",
" return basis\n",
" else:\n",
" for i in range(1, r):\n",
" if (r*j - m*i >= delta):\n",
2021-08-21 20:50:10 +02:00
" basis[k] = superelliptic_form(self, Fxy(x^(i-1)/y^j))\n",
2021-08-19 22:35:11 +02:00
" k = k+1\n",
" return basis\n",
" \n",
2021-08-22 21:48:21 +02:00
" def degree_and_basis_de_rham(self, j = 'all'):\n",
" f = self.polynomial\n",
" m = self.exponent\n",
" p = self.characteristic\n",
" r = f.degree()\n",
" delta = GCD(r, m)\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
" basis = {}\n",
2021-08-22 21:48:21 +02:00
" degrees0 = {}\n",
" degrees1 = {}\n",
" t = 0\n",
" if j == 'all':\n",
" for j in range(1, m):\n",
2021-08-21 18:40:44 +02:00
" holo = C.basis_holomorphic_differentials(j)\n",
" for k in range(0, len(holo)):\n",
2021-08-22 21:48:21 +02:00
" basis[t] = superelliptic_cech(self, holo[k], superelliptic_function(self, Rx(0))) \n",
" g = Rx(holo[k].jth_component(j))\n",
" degrees0[t] = (g.degree(), j)\n",
" t += 1\n",
2021-08-21 18:40:44 +02:00
" for i in range(1, r):\n",
" if (r*(m-j) - m*i >= delta):\n",
2021-08-21 20:50:10 +02:00
" s = Rx(m-j)*Rx(x)*Rx(f.derivative()) - Rx(m)*Rx(i)*f\n",
" psi = Rx(cut(s, i))\n",
2021-08-22 21:48:21 +02:00
" basis[t] = superelliptic_cech(self, superelliptic_form(self, Fxy(psi/y^j)), superelliptic_function(self, Fxy(m*y^j/x^i)))\n",
" degrees0[t] = (psi.degree(), j)\n",
" degrees1[t] = (-i, j)\n",
" t += 1\n",
" return basis, degrees0, degrees1\n",
" \n",
" def degree_de_rham(self, i, j='all'):\n",
" basis, degrees0, degrees1 = self.degree_and_basis_de_rham(j)\n",
" if i==0:\n",
" return degrees0\n",
" \n",
" if i==1:\n",
" return degrees1\n",
" \n",
" def basis_de_rham(self, j = 'all'): \n",
" basis, degrees0, degrees1 = self.degree_and_basis_de_rham(j)\n",
" return basis\n",
" \n",
2021-08-19 22:35:11 +02:00
"def reduction(C, g):\n",
" p = C.characteristic\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
2021-08-19 22:35:11 +02:00
" f = C.polynomial\n",
" r = f.degree()\n",
" m = C.exponent\n",
2021-08-21 20:50:10 +02:00
" g = Fxy(g)\n",
2021-08-19 22:35:11 +02:00
" g1 = g.numerator()\n",
" g2 = g.denominator()\n",
" \n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" FxRy.<y> = PolynomialRing(Fx) \n",
" (A, B, C) = xgcd(FxRy(g2), FxRy(y^m - f))\n",
" g = FxRy(g1*B/A)\n",
2021-08-19 22:35:11 +02:00
" \n",
2021-08-21 20:50:10 +02:00
" while(g.degree(Rxy(y)) >= m):\n",
" d = g.degree(Rxy(y))\n",
" G = coff(g, d)\n",
2021-08-19 22:35:11 +02:00
" i = floor(d/m)\n",
" g = g - G*y^d + f^i * y^(d%m) *G\n",
" \n",
2021-08-21 20:50:10 +02:00
" return(FxRy(g))\n",
2021-08-19 22:35:11 +02:00
"\n",
"def reduction_form(C, g):\n",
" p = C.characteristic\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
2021-08-19 22:35:11 +02:00
" f = C.polynomial\n",
" r = f.degree()\n",
" m = C.exponent\n",
" g = reduction(C, g)\n",
"\n",
2021-08-22 21:48:21 +02:00
" g1 = Rxy(0)\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" FxRy.<y> = PolynomialRing(Fx)\n",
2021-08-19 22:35:11 +02:00
" \n",
2021-08-21 20:50:10 +02:00
" g = FxRy(g)\n",
2021-08-19 22:35:11 +02:00
" for j in range(0, m):\n",
" if j==0:\n",
" G = coff(g, 0)\n",
2021-08-22 21:48:21 +02:00
" g1 += FxRy(G)\n",
" else:\n",
" G = coff(g, j)\n",
2021-08-21 20:50:10 +02:00
" g1 += Fxy(y^(j-m)*f*G)\n",
2021-08-19 22:35:11 +02:00
" return(g1)\n",
" \n",
"class superelliptic_function:\n",
" def __init__(self, C, g):\n",
2021-08-21 18:40:44 +02:00
" p = C.characteristic\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
2021-08-19 22:35:11 +02:00
" f = C.polynomial\n",
" r = f.degree()\n",
" m = C.exponent\n",
" \n",
" self.curve = C\n",
" g = reduction(C, g)\n",
" self.function = g\n",
" \n",
" def __repr__(self):\n",
" return str(self.function)\n",
" \n",
" def jth_component(self, j):\n",
" g = self.function\n",
2021-08-22 21:48:21 +02:00
" C = self.curve\n",
" p = C.characteristic\n",
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx.<x> = FractionField(Rx)\n",
" FxRy.<y> = PolynomialRing(Fx)\n",
" g = FxRy(g)\n",
" return coff(g, j)\n",
2021-08-19 22:35:11 +02:00
" \n",
" def __add__(self, other):\n",
" C = self.curve\n",
" g1 = self.function\n",
" g2 = other.function\n",
" g = reduction(C, g1 + g2)\n",
" return superelliptic_function(C, g)\n",
" \n",
" def __sub__(self, other):\n",
" C = self.curve\n",
" g1 = self.function\n",
" g2 = other.function\n",
" g = reduction(C, g1 - g2)\n",
" return superelliptic_function(C, g)\n",
" \n",
" def __mul__(self, other):\n",
" C = self.curve\n",
" g1 = self.function\n",
" g2 = other.function\n",
" g = reduction(C, g1 * g2)\n",
" return superelliptic_function(C, g)\n",
" \n",
" def __truediv__(self, other):\n",
" C = self.curve\n",
" g1 = self.function\n",
" g2 = other.function\n",
" g = reduction(C, g1 / g2)\n",
" return superelliptic_function(C, g)\n",
" \n",
"def diffn(self):\n",
" C = self.curve\n",
" f = C.polynomial\n",
" m = C.exponent\n",
2021-08-21 18:40:44 +02:00
" p = C.characteristic\n",
2021-08-19 22:35:11 +02:00
" g = self.function\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
" g = Fxy(g)\n",
2021-08-19 22:35:11 +02:00
" A = g.derivative(x)\n",
" B = g.derivative(y)*f.derivative(x)/(m*y^(m-1))\n",
" return superelliptic_form(C, A+B)\n",
" \n",
"class superelliptic_form:\n",
" def __init__(self, C, g):\n",
2021-08-21 18:40:44 +02:00
" p = C.characteristic\n",
2021-08-21 20:50:10 +02:00
" Rxy.<x, y> = PolynomialRing(GF(p), 2)\n",
" Fxy = FractionField(Rxy)\n",
" g = Fxy(reduction_form(C, g))\n",
2021-08-19 22:35:11 +02:00
" self.form = g\n",
" self.curve = C \n",
" \n",
" def __add__(self, other):\n",
" C = self.curve\n",
" g1 = self.form\n",
" g2 = other.form\n",
" g = reduction(C, g1 + g2)\n",
" return superelliptic_form(C, g)\n",
" \n",
" def __sub__(self, other):\n",
" C = self.curve\n",
" g1 = self.form\n",
" g2 = other.form\n",
" g = reduction(C, g1 - g2)\n",
" return superelliptic_form(C, g)\n",
" \n",
" def __repr__(self):\n",
" g = self.form\n",
" if len(str(g)) == 1:\n",
" return str(g) + ' dx'\n",
" return '('+str(g) + ') dx'\n",
" \n",
" def jth_component(self, j):\n",
" g = self.form\n",
2021-08-22 21:48:21 +02:00
" C = self.curve\n",
" p = C.characteristic\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" FxRy.<y> = PolynomialRing(Fx)\n",
" Fxy = FractionField(FxRy)\n",
2021-08-22 21:48:21 +02:00
" Ryinv.<y_inv> = PolynomialRing(Fx)\n",
2021-08-21 20:50:10 +02:00
" g = Fxy(g)\n",
" g = g(y = 1/y_inv)\n",
2021-08-21 20:50:10 +02:00
" g = Ryinv(g)\n",
" return coff(g, j)\n",
" \n",
" def is_regular_on_U0(self):\n",
" C = self.curve\n",
" p = C.characteristic\n",
" m = C.exponent\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" for j in range(1, m):\n",
2021-08-21 20:50:10 +02:00
" if self.jth_component(j) not in Rx:\n",
" return 0\n",
" return 1\n",
" \n",
" def is_regular_on_Uinfty(self):\n",
" C = self.curve\n",
" p = C.characteristic\n",
" m = C.exponent\n",
" f = C.polynomial\n",
" r = f.degree()\n",
" delta = GCD(m, r)\n",
" M = m/delta\n",
" R = r/delta\n",
" \n",
" for j in range(1, m):\n",
" A = self.jth_component(j)\n",
" d = degree_of_rational_fctn(A)\n",
" if(-d*M + j*R -(M+1)<0):\n",
" return 0\n",
" return 1\n",
" \n",
2021-08-21 19:52:03 +02:00
" \n",
"class superelliptic_cech:\n",
2021-08-21 18:40:44 +02:00
" def __init__(self, C, omega, fct):\n",
" self.omega0 = omega\n",
" self.omega8 = omega - diffn(fct)\n",
" self.f = fct\n",
2021-08-21 18:40:44 +02:00
" self.curve = C\n",
" \n",
2021-08-21 19:52:03 +02:00
" def __add__(self, other):\n",
" C = self.curve\n",
" return superelliptic_cech(C, self.omega0 + other.omega0, self.f + other.f)\n",
" \n",
" def __sub__(self, other):\n",
" C = self.curve\n",
" return superelliptic_cech(C, self.omega0 - other.omega0, self.f - other.f)\n",
" \n",
2021-08-22 21:48:21 +02:00
" def mult(self, constant):\n",
" C = self.curve\n",
" w1 = self.omega0.form\n",
" f1 = self.f.function\n",
" w2 = superelliptic_form(C, constant*w1)\n",
" f2 = superelliptic_function(C, constant*f1)\n",
" return superelliptic_cech(C, w2, f2)\n",
" \n",
2021-08-21 19:52:03 +02:00
" def __repr__(self):\n",
" return \"(\" + str(self.omega0) + \", \" + str(self.f) + \", \" + str(self.omega8) + \")\" \n",
2021-08-22 21:48:21 +02:00
" \n",
" def basis_coeffs(self):\n",
" C = self.curve\n",
" g = self.f\n",
" basis = C.basis_de_rham()\n",
"\n",
" def coordinates(self):\n",
" print(self)\n",
" C = self.curve\n",
" p = C.characteristic\n",
" m = C.exponent\n",
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" FxRy.<y> = PolynomialRing(Fx)\n",
" g = C.genus()\n",
" degrees0 = C.degree_de_rham(0)\n",
" degrees0_inv = {b:a for a, b in degrees0.items()} \n",
" degrees1 = C.degree_de_rham(1)\n",
" degrees1_inv = {b:a for a, b in degrees1.items()}\n",
" basis = C.basis_de_rham()\n",
" \n",
" omega = self.omega0\n",
" fct = self.f\n",
" \n",
" if fct.function == Rx(0) and omega.form == Rx(0):\n",
" for j in range(1, m):\n",
" omega_j = Fx(omega.jth_component(j))\n",
" if omega_j != Fx(0):\n",
" d = d = degree_of_rational_fctn(omega_j)\n",
" index = degrees0_inv[(d, j)]\n",
" a = coeff_of_rational_fctn(omega_j)\n",
" a1 = coeff_of_rational_fctn(basis[index].omega0.jth_component(j))\n",
" elt = self - basis[index].mult(a/a1)\n",
" return elt.coordinates() + a/a1*vector([GF(p)(i == index) for i in range(0, 2*g)])\n",
" \n",
" for j in range(1, m):\n",
" fct_j = Fx(fct.jth_component(j))\n",
" if (fct_j != Rx(0)):\n",
" d = degree_of_rational_fctn(fct_j)\n",
" \n",
" if (d, j) in degrees1.values():\n",
" index = degrees1_inv[(d, j)]\n",
" a = coeff_of_rational_fctn(fct_j)\n",
" a1 = coeff_of_rational_fctn(basis[index].f.jth_component(j))\n",
" elt = self - basis[index].mult(a/a1)\n",
" return elt.coordinates() + a/a1*vector([GF(p)(i == index) for i in range(0, 2*g)])\n",
" \n",
" if d<0:\n",
" a = coeff_of_rational_fctn(fct_j)\n",
" elt =- superelliptic_cech(C, elt.omega0, elt.f - FxRy(y^j*x^d)).mult(a)\n",
" return elt.coordinates()\n",
" \n",
" if (fct_j != Rx(0)):\n",
" G = superelliptic_function(C, y^j*x^d)\n",
" a = coeff_of_rational_fctn(fct_j)\n",
" elt =-superelliptic_cech(diffn(G), G).mult(a)\n",
" return elt.coordinates()\n",
"\n",
" return vector(2*g*[0])\n",
2021-08-21 19:52:03 +02:00
" \n",
"def degree_of_rational_fctn(f):\n",
2021-08-21 20:50:10 +02:00
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" f = Fx(f)\n",
" f1 = f.numerator()\n",
" f2 = f.denominator()\n",
" d1 = f1.degree()\n",
" d2 = f2.degree()\n",
" return(d1 - d2)\n",
"\n",
2021-08-22 21:48:21 +02:00
"def coeff_of_rational_fctn(f):\n",
" Rx.<x> = PolynomialRing(GF(p))\n",
" Fx = FractionField(Rx)\n",
" f = Fx(f)\n",
" f1 = f.numerator()\n",
" f2 = f.denominator()\n",
" d1 = f1.degree()\n",
" d2 = f2.degree()\n",
" a1 = f1.coefficients(sparse = false)[d1]\n",
" a2 = f2.coefficients(sparse = false)[d2]\n",
" return(a1/a2)\n",
"\n",
"def coff(f, d):\n",
" lista = f.coefficients(sparse = false)\n",
" if len(lista) <= d:\n",
" return 0\n",
" return lista[d]\n",
"\n",
"def cut(f, i):\n",
2021-08-21 18:40:44 +02:00
" R = f.parent()\n",
" coeff = f.coefficients(sparse = false)\n",
2021-08-21 18:40:44 +02:00
" return sum(R(x^(j-i-1)) * coeff[j] for j in range(i+1, f.degree() + 1))"
2021-08-19 22:35:11 +02:00
]
},
{
"cell_type": "code",
2021-08-22 21:48:21 +02:00
"execution_count": 116,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [
{
2021-08-22 21:48:21 +02:00
"data": {
"text/plain": [
"{0: ((x/y) dx, 2/x*y, ((x^3*y^5 - x^3 + x - 1)/(x^2*y^6)) dx),\n",
" 1: (((-1)/y) dx, 2/x^2*y, ((-x^3*y^5 + x^3 - 2*x - 2)/(x^3*y^6)) dx),\n",
" 2: (((-2*x)/y^2) dx, 2/x*y^2, ((-2*x^3*y^3 + x^3 - 1)/(x^2*y^5)) dx),\n",
" 3: ((1/y^2) dx, 2/x^2*y^2, ((x^3*y^3 - 2*x^3 + 2*x - 2)/(x^3*y^5)) dx),\n",
" 4: ((1/y^3) dx, 0, (1/y^3) dx),\n",
" 5: (0 dx, 2/x*y^3, ((-2*x^3 - x - 1)/(x^2*y^4)) dx),\n",
" 6: ((1/y^4) dx, 0, (1/y^4) dx),\n",
" 7: ((2*x/y^4) dx, 2/x*y^4, ((2*x^3 - 2*x*y - y)/(x^2*y^4)) dx),\n",
" 8: ((1/y^5) dx, 0, (1/y^5) dx),\n",
" 9: ((x/y^5) dx, 0, (x/y^5) dx),\n",
" 10: ((1/y^6) dx, 0, (1/y^6) dx),\n",
" 11: ((x/y^6) dx, 0, (x/y^6) dx)}"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p = 5\n",
"C = superelliptic(x^3 + x + 2, 7, p)\n",
"C.basis_de_rham()\n",
"#C.basis_holomorphic_differentials()"
]
},
{
"cell_type": "code",
2021-08-22 23:42:55 +02:00
"execution_count": 117,
2021-08-22 21:48:21 +02:00
"metadata": {},
"outputs": [],
"source": [
"RxRy.<x, y> = PolynomialRing(GF(p), 2)\n",
"w1 = superelliptic_cech(C, superelliptic_form(C, (1/y^5)), superelliptic_function(C, 0))\n",
"w2 = superelliptic_cech(C, superelliptic_form(C,2*x/y^4), superelliptic_function(C, 2/x*y^4))\n",
"w = w1+w2+w2"
]
},
{
"cell_type": "code",
2021-08-22 23:42:55 +02:00
"execution_count": 118,
2021-08-22 21:48:21 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2021-08-22 23:42:55 +02:00
"(((-x*y + 1)/y^5) dx, 4/x*y^4, ((-x^3*y + x*y^2 + x^2 - 2*y^2)/(x^2*y^5)) dx)\n",
"((1/y^5) dx, 0, (1/y^5) dx)\n"
2021-08-22 21:48:21 +02:00
]
},
{
2021-08-22 23:42:55 +02:00
"data": {
"text/plain": [
"(0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0)"
]
},
"execution_count": 118,
"metadata": {},
"output_type": "execute_result"
2021-08-19 22:35:11 +02:00
}
],
"source": [
2021-08-22 21:48:21 +02:00
"w.coordinates()"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
"a, b, c = C.degree_and_basis_de_rham()"
2021-08-19 22:35:11 +02:00
]
},
{
"cell_type": "code",
2021-08-21 20:50:10 +02:00
"execution_count": 7,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [
{
2021-08-21 20:50:10 +02:00
"ename": "NameError",
"evalue": "name 'y' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-7-1009561bb01d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mInteger\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mm\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0momega\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msuperelliptic_form\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mC\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0momega\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_regular_on_U0\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0momega\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_regular_on_Uinfty\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0momega\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'y' is not defined"
]
2021-08-19 22:35:11 +02:00
}
],
"source": [
"licz = 0\n",
"m = 2\n",
"p = 5\n",
"R1.<x> = PolynomialRing(GF(p))\n",
"f = R1(x^3 + x + 4)\n",
"r = f.degree()\n",
"C = superelliptic(f, m, p)\n",
"for i in range(0, r):\n",
" for j in range(1, m):\n",
" omega = superelliptic_form(C, x^i/y^j)\n",
" if (omega.is_regular_on_U0() and omega.is_regular_on_Uinfty()):\n",
" print(omega)\n",
" licz += 1\n",
"print(licz, C.genus())\n",
"print(C.basis_holomorphic_differentials())"
2021-08-19 22:35:11 +02:00
]
},
{
"cell_type": "code",
2021-08-21 18:40:44 +02:00
"execution_count": null,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [],
"source": [
"p = 5\n",
"R.<x, y> = PolynomialRing(GF(p), 2)\n",
"g = x^6*y^2 + y^2"
]
},
{
"cell_type": "code",
"execution_count": 83,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [],
"source": [
"omega = diffn(superelliptic_function(C, y^2))"
]
},
{
"cell_type": "code",
"execution_count": 84,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3*x^2 + 1"
2021-08-19 22:35:11 +02:00
]
},
"execution_count": 84,
2021-08-19 22:35:11 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"omega.jth_component(0)"
]
},
{
"cell_type": "code",
"execution_count": 85,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"y"
]
},
"execution_count": 85,
2021-08-19 22:35:11 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"R.<x, y> = PolynomialRing(GF(p), 2)\n",
"g1 = x^3*y^7 + x^2*y^9\n",
"g2 = x^2*y + y^6\n",
"R1.<x> = PolynomialRing(GF(p))\n",
"R2 = FractionField(R1)\n",
"R3.<y> = PolynomialRing(R2)\n",
"\n",
"xgcd(R3(g1), R3(g2))[1]*R3(g1) + xgcd(R3(g1), R3(g2))[2]*R3(g2)"
]
},
{
"cell_type": "code",
"execution_count": 86,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [],
"source": [
"H = HyperellipticCurve(x^5 - x + 1)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Hyperelliptic Curve over Finite Field of size 5 defined by y^2 = x^5 + 4*x + 1"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
"f = x^3 + x + 2"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-2*x^2 + 1"
]
},
"execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f.derivative(x)"
]
},
{
"cell_type": "code",
"execution_count": 3,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [],
"source": [
"p = 5\n",
2021-08-19 22:35:11 +02:00
"R1.<x> = PolynomialRing(GF(p))\n",
"R2 = FractionField(R1)\n",
"R3.<y> = PolynomialRing(R2)\n",
"g = y^2/x + y/(x+1) \n",
"g = 1/y+x/y^2"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"x*z^2 + z"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"R3.<z> = PolynomialRing(R2)\n",
"g(y = 1/z)"
2021-08-19 22:35:11 +02:00
]
},
{
"cell_type": "code",
"execution_count": 57,
2021-08-19 22:35:11 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"x^3 + x + 4"
2021-08-19 22:35:11 +02:00
]
},
"execution_count": 57,
2021-08-19 22:35:11 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint' object has no attribute 'coefficient'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-62-e054c182ec1a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoefficient\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/structure/element.pyx\u001b[0m in \u001b[0;36msage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4614)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 485\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'LeftZeroSemigroup_with_category.element_class'\u001b[0m \u001b[0mobject\u001b[0m \u001b[0mhas\u001b[0m \u001b[0mno\u001b[0m \u001b[0mattribute\u001b[0m \u001b[0;34m'blah_blah'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 486\u001b[0m \"\"\"\n\u001b[0;32m--> 487\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetattr_from_category\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 488\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 489\u001b[0m \u001b[0mcdef\u001b[0m \u001b[0mgetattr_from_category\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/structure/element.pyx\u001b[0m in \u001b[0;36msage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4723)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 498\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 499\u001b[0m \u001b[0mcls\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mP\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_abstract_element_class\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 500\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mgetattr_from_other_class\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 501\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 502\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__dir__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx\u001b[0m in \u001b[0;36msage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2614)\u001b[0;34m()\u001b[0m\n\u001b[1;32m 392\u001b[0m \u001b[0mdummy_error_message\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcls\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 393\u001b[0m \u001b[0mdummy_error_message\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 394\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdummy_error_message\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 395\u001b[0m \u001b[0mattribute\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m<\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0mattr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 396\u001b[0m \u001b[0;31m# Check for a descriptor (__get__ in Python)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint' object has no attribute 'coefficient'"
]
}
],
"source": [
"f.coefficient()"
2021-08-19 22:35:11 +02:00
]
},
2021-08-21 18:40:44 +02:00
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"x^3 + x + 1"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x^3+x+1"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Symbolic Ring"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"parent(x)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"R.<x> = PolynomialRing(GF(5))"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"R = (x^3+x).parent()"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"R.<x, y> = PolynomialRing(GF(5))\n",
"RR = FractionField(R)\n",
"A = RR(1/(x*y))"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-1)/(x^2*y)"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A.derivative(x)"
]
},
2021-08-22 21:48:21 +02:00
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"dict1 = {}\n",
"dict1[3] = 5\n",
"dict1[6] = 121"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"degrees1_inv = {b:a for a, b in dict1.items()}"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{5: 3, 121: 6}"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"degrees1_inv"
]
},
2021-08-19 22:35:11 +02:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.1",
"language": "sage",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}