{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "1b6dc5b9-b9f9-4ed2-a8ed-38fc2b296e53", "metadata": {}, "outputs": [], "source": [ "using SymPy" ] }, { "cell_type": "code", "execution_count": 2, "id": "9a154fac-53c4-4feb-9509-3c6a56154a2e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "minpoly (generic function with 1 method)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function minpoly(x, y, f, g, h, N)\n", " m = sympy.Poly(f, x).degree()\n", " n = sympy.Poly(g, y).degree()\n", " K = sympy.Poly(h, x).degree()\n", " L = sympy.Poly(h, y).degree()\n", " λ = symbols(\"λ[0:$N]\")\n", " z = symbols(\"z\")\n", " P = sum(λ[begin+k]*z^k for k in 0:N-1) + z^N\n", " p = P(z => h).expand()\n", " @time for k in K*N:-1:m\n", " p = p(x^k => x^k - x^(k-m)*f).expand()\n", " end\n", " @time for l in L*N:-1:n\n", " p = p(y^l => y^l - y^(l-n)*g).expand()\n", " end\n", " Q = sympy.Poly(p, x, y)\n", " C = Q.coeffs()\n", " @time sol = solve(C, λ)\n", " P = sum(get(sol, λ[begin+k], λ[begin+k])*z^k for k in 0:N-1) + z^N\n", " [\n", " sympy.Poly(f, x)\n", " sympy.Poly(g, y)\n", " sympy.Poly(h, x, y)\n", " sympy.Poly(P, z)\n", " ]\n", "end" ] }, { "cell_type": "code", "execution_count": 3, "id": "269c1f6f-56fd-4317-945e-bff201e74c66", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.023271 seconds (297 allocations: 7.094 KiB)\n", " 0.019818 seconds (297 allocations: 7.094 KiB)\n", " 0.298115 seconds (820.74 k allocations: 49.065 MiB, 2.47% gc time, 1.46% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{2} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{4} + \\left(- 2 a - 2 p\\right) z^{2} + a^{2} - 2 a p + p^{2}, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**2 - p, y, domain='ZZ[p]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z**4 + (-2*a - 2*p)*z**2 + a**2 - 2*a*p + p**2, z, domain='ZZ[p,a]')" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^2 - a\n", "g = y^2 - p\n", "h = x + y\n", "minpoly(x, y, f, g, h, 4)" ] }, { "cell_type": "code", "execution_count": 4, "id": "9172fb07-c9d3-46bb-a30b-e338f7c52195", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.000627 seconds (83 allocations: 2.031 KiB)\n", " 0.000587 seconds (83 allocations: 2.031 KiB)\n", " 0.026929 seconds (61.50 k allocations: 3.820 MiB, 17.14% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{2} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{2} - a p, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**2 - p, y, domain='ZZ[p]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z**2 - a*p, z, domain='ZZ[p,a]')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^2 - a\n", "g = y^2 - p\n", "h = x * y\n", "minpoly(x, y, f, g, h, 2)" ] }, { "cell_type": "code", "execution_count": 5, "id": "45c646cf-20c7-4d8d-9a3f-e34031231b4a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.040974 seconds (589 allocations: 14.031 KiB)\n", " 0.032724 seconds (489 allocations: 11.656 KiB)\n", " 0.052577 seconds (62.55 k allocations: 3.895 MiB, 12.21% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{6} - 3 a z^{4} - 2 p z^{3} + 3 a^{2} z^{2} - 6 a p z - a^{3} + p^{2}, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**3 - p, y, domain='ZZ[p]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^6 - 3*a*z^4 - 2*p*z^3 + 3*a^2*z^2 - 6*a*p*z - a^3 + p^2, z, domain='ZZ[p,a]')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^2 - a\n", "g = y^3 - p\n", "h = x + y\n", "minpoly(x, y, f, g, h, 6)" ] }, { "cell_type": "code", "execution_count": 6, "id": "128fd6b2-e085-4945-b095-9374be744837", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.014113 seconds (589 allocations: 14.031 KiB)\n", " 0.007490 seconds (489 allocations: 11.656 KiB)\n", " 0.009286 seconds (248 allocations: 7.594 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{6} - a^{3} p^{2}, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**3 - p, y, domain='ZZ[p]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z**6 - a**3*p**2, z, domain='ZZ[p,a]')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^2 - a\n", "g = y^3 - p\n", "h = x * y\n", "minpoly(x, y, f, g, h, 6)" ] }, { "cell_type": "code", "execution_count": 7, "id": "f49b2099-95d8-4d3d-bb48-203861cce7db", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.000561 seconds (589 allocations: 14.031 KiB)\n", " 0.043253 seconds (489 allocations: 11.656 KiB)\n", " 0.060136 seconds (248 allocations: 7.594 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{6} + \\left(- 3 a + 2 p\\right) z^{4} + 2 q z^{3} + \\left(3 a^{2} + p^{2}\\right) z^{2} + \\left(6 a q + 2 p q\\right) z - a^{3} - 2 a^{2} p - a p^{2} + q^{2}, z, domain=\\mathbb{Z}\\left[p, q, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**3 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^6 + (-3*a + 2*p)*z^4 + 2*q*z^3 + (3*a^2 + p^2)*z^2 + (6*a*q + 2*p*q)*z - a^3 - 2*a^2*p - a*p^2 + q^2, z, domain='ZZ[p,q,a]')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q x y\n", "f = x^2 - a\n", "g = y^3 + p*y + q\n", "h = x + y\n", "minpoly(x, y, f, g, h, 6)" ] }, { "cell_type": "code", "execution_count": 8, "id": "929c84b1-b22b-48e1-8ebf-22fde80eeac6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.000542 seconds (589 allocations: 14.031 KiB)\n", " 0.018329 seconds (489 allocations: 11.656 KiB)\n", " 0.021076 seconds (248 allocations: 7.594 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{6} + 2 a p z^{4} + a^{2} p^{2} z^{2} - a^{3} q^{2}, z, domain=\\mathbb{Z}\\left[p, q, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**3 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z**6 + 2*a*p*z**4 + a**2*p**2*z**2 - a**3*q**2, z, domain='ZZ[p,q,a]')" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q x y\n", "f = x^2 - a\n", "g = y^3 + p*y + q\n", "h = x * y\n", "minpoly(x, y, f, g, h, 6)" ] }, { "cell_type": "code", "execution_count": 9, "id": "9a613359-c5aa-4f17-9bd9-8c7b9278d521", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.093855 seconds (925 allocations: 22.031 KiB)\n", " 0.100663 seconds (679 allocations: 16.188 KiB)\n", " 0.212156 seconds (62.62 k allocations: 3.897 MiB, 3.41% gc time, 2.58% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{4} + p y^{2} + q y + r, y, domain=\\mathbb{Z}\\left[p, q, r\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{8} + \\left(- 4 a + 2 p\\right) z^{6} + 2 q z^{5} + \\left(6 a^{2} - 2 a p + p^{2} + 2 r\\right) z^{4} + \\left(4 a q + 2 p q\\right) z^{3} + \\left(- 4 a^{3} - 2 a^{2} p - 2 a p^{2} + 12 a r + 2 p r + q^{2}\\right) z^{2} + \\left(- 6 a^{2} q - 2 a p q + 2 q r\\right) z + a^{4} + 2 a^{3} p + a^{2} p^{2} + 2 a^{2} r + 2 a p r - a q^{2} + r^{2}, z, domain=\\mathbb{Z}\\left[p, q, r, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**4 + p*y**2 + q*y + r, y, domain='ZZ[p,q,r]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^8 + (-4*a + 2*p)*z^6 + 2*q*z^5 + (6*a^2 - 2*a*p + p^2 + 2*r)*z^4 + (4*a*q + 2*p*q)*z^3 + (-4*a^3 - 2*a^2*p - 2*a*p^2 + 12*a*r + 2*p*r + q^2)*z^2 + (-6*a^2*q - 2*a*p*q + 2*q*r)*z + a^4 + 2*a^3*p + a^2*p^2 + 2*a^2*r + 2*a*p*r - a*q^2 + r^2, z, domain='ZZ[p,q,r,a]')" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q r x y\n", "f = x^2 - a\n", "g = y^4 + p*y^2 + q*y + r\n", "h = x + y\n", "minpoly(x, y, f, g, h, 8)" ] }, { "cell_type": "code", "execution_count": 10, "id": "26248e0f-0ac8-4e24-a375-8ed3123abe17", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.036351 seconds (925 allocations: 22.031 KiB)\n", " 0.042049 seconds (679 allocations: 16.188 KiB)\n", " 0.051188 seconds (314 allocations: 9.562 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{4} + p y^{2} + q y + r, y, domain=\\mathbb{Z}\\left[p, q, r\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{8} + 2 a p z^{6} + \\left(a^{2} p^{2} + 2 a^{2} r\\right) z^{4} + \\left(2 a^{3} p r - a^{3} q^{2}\\right) z^{2} + a^{4} r^{2}, z, domain=\\mathbb{Z}\\left[p, q, r, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**4 + p*y**2 + q*y + r, y, domain='ZZ[p,q,r]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z^8 + 2*a*p*z^6 + (a^2*p^2 + 2*a^2*r)*z^4 + (2*a^3*p*r - a^3*q^2)*z^2 + a^4*r^2, z, domain='ZZ[p,q,r,a]')" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q r x y\n", "f = x^2 - a\n", "g = y^4 + p*y^2 + q*y + r\n", "h = x * y\n", "minpoly(x, y, f, g, h, 8)" ] }, { "cell_type": "code", "execution_count": 11, "id": "3a2187b2-aff8-468a-9c39-b201067b7b0f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.198323 seconds (1.29 k allocations: 30.828 KiB)\n", " 0.200592 seconds (902 allocations: 21.516 KiB)\n", " 30.746824 seconds (62.68 k allocations: 3.899 MiB, 0.02% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{5} + p y^{3} + q y^{2} + r y + s, y, domain=\\mathbb{Z}\\left[p, q, r, s\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{10} + \\left(- 5 a + 2 p\\right) z^{8} + 2 q z^{7} + \\left(10 a^{2} - 4 a p + p^{2} + 2 r\\right) z^{6} + \\left(2 a q + 2 p q + 2 s\\right) z^{5} + \\left(- 10 a^{3} - 3 a p^{2} + 10 a r + 2 p r + q^{2}\\right) z^{4} + \\left(- 10 a^{2} q - 4 a p q + 20 a s + 2 p s + 2 q r\\right) z^{3} + \\left(5 a^{4} + 4 a^{3} p + 3 a^{2} p^{2} - 10 a^{2} r - 2 a q^{2} + 2 q s + r^{2}\\right) z^{2} + \\left(6 a^{3} q + 2 a^{2} p q + 10 a^{2} s + 6 a p s - 2 a q r + 2 r s\\right) z - a^{5} - 2 a^{4} p - a^{3} p^{2} - 2 a^{3} r - 2 a^{2} p r + a^{2} q^{2} + 2 a q s - a r^{2} + s^{2}, z, domain=\\mathbb{Z}\\left[p, q, r, s, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**5 + p*y**3 + q*y**2 + r*y + s, y, domain='ZZ[p,q,r,s]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^10 + (-5*a + 2*p)*z^8 + 2*q*z^7 + (10*a^2 - 4*a*p + p^2 + 2*r)*z^6 + (2*a*q + 2*p*q + 2*s)*z^5 + (-10*a^3 - 3*a*p^2 + 10*a*r + 2*p*r + q^2)*z^4 + (-10*a^2*q - 4*a*p*q + 20*a*s + 2*p*s + 2*q*r)*z^3 + (5*a^4 + 4*a^3*p + 3*a^2*p^2 - 10*a^2*r - 2*a*q^2 + 2*q*s + r^2)*z^2 + (6*a^3*q + 2*a^2*p*q + 10*a^2*s + 6*a*p*s - 2*a*q*r + 2*r*s)*z - a^5 - 2*a^4*p - a^3*p^2 - 2*a^3*r - 2*a^2*p*r + a^2*q^2 + 2*a*q*s - a*r^2 + s^2, z, domain='ZZ[p,q,r,s,a]')" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q r s x y\n", "f = x^2 - a\n", "g = y^5 + p*y^3 + q*y^2 + r*y + s\n", "h = x + y\n", "minpoly(x, y, f, g, h, 10)" ] }, { "cell_type": "code", "execution_count": 12, "id": "8f7f53db-be4b-40db-b65b-cb33e3c4cd73", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.031418 seconds (1.29 k allocations: 30.828 KiB)\n", " 0.048821 seconds (902 allocations: 21.516 KiB)\n", " 0.081856 seconds (62.52 k allocations: 3.894 MiB, 6.15% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{2} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{5} + p y^{3} + q y^{2} + r y + s, y, domain=\\mathbb{Z}\\left[p, q, r, s\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x^{2}y^{2}, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{5} + 2 a p z^{4} + \\left(a^{2} p^{2} + 2 a^{2} r\\right) z^{3} + \\left(2 a^{3} p r - a^{3} q^{2}\\right) z^{2} + \\left(- 2 a^{4} q s + a^{4} r^{2}\\right) z - a^{5} s^{2}, z, domain=\\mathbb{Z}\\left[p, q, r, s, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**2 - a, x, domain='ZZ[a]')\n", " Poly(y**5 + p*y**3 + q*y**2 + r*y + s, y, domain='ZZ[p,q,r,s]')\n", " Poly(x**2*y**2, x, y, domain='ZZ')\n", " Poly(z^5 + 2*a*p*z^4 + (a^2*p^2 + 2*a^2*r)*z^3 + (2*a^3*p*r - a^3*q^2)*z^2 + (-2*a^4*q*s + a^4*r^2)*z - a^5*s^2, z, domain='ZZ[p,q,r,s,a]')" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q r s x y\n", "f = x^2 - a\n", "g = y^5 + p*y^3 + q*y^2 + r*y + s\n", "h = (x * y)^2\n", "minpoly(x, y, f, g, h, 5)" ] }, { "cell_type": "code", "execution_count": 13, "id": "4104a4e4-de9b-451a-86b5-5800fb7f5aa0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.066229 seconds (993 allocations: 23.656 KiB)\n", " 0.065860 seconds (993 allocations: 23.656 KiB)\n", " 0.048861 seconds (61.95 k allocations: 3.855 MiB, 9.78% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x^{3} + 3 x^{2}y + 3 xy^{2} + y^{3}, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{3} + \\left(- 3 a - 3 p\\right) z^{2} + \\left(3 a^{2} - 21 a p + 3 p^{2}\\right) z - a^{3} - 3 a^{2} p - 3 a p^{2} - p^{3}, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 - a, x, domain='ZZ[a]')\n", " Poly(y**3 - p, y, domain='ZZ[p]')\n", " Poly(x**3 + 3*x**2*y + 3*x*y**2 + y**3, x, y, domain='ZZ')\n", " Poly(z^3 + (-3*a - 3*p)*z^2 + (3*a^2 - 21*a*p + 3*p^2)*z - a^3 - 3*a^2*p - 3*a*p^2 - p^3, z, domain='ZZ[p,a]')" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^3 - a\n", "g = y^3 - p\n", "h = (x + y)^3\n", "minpoly(x, y, f, g, h, 3)" ] }, { "cell_type": "code", "execution_count": 14, "id": "17eb0d54-d4aa-4483-8ff2-c0a19ad140fc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.000927 seconds (107 allocations: 2.594 KiB)\n", " 0.000832 seconds (107 allocations: 2.594 KiB)\n", " 0.003331 seconds (126 allocations: 4.172 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} - p, y, domain=\\mathbb{Z}\\left[p\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{3} - a p, z, domain=\\mathbb{Z}\\left[p, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 - a, x, domain='ZZ[a]')\n", " Poly(y**3 - p, y, domain='ZZ[p]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z**3 - a*p, z, domain='ZZ[p,a]')" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p x y\n", "f = x^3 - a\n", "g = y^3 - p\n", "h = x * y\n", "minpoly(x, y, f, g, h, 3)" ] }, { "cell_type": "code", "execution_count": 15, "id": "78823940-e677-46f5-a5d3-744a1fc0afaf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.185318 seconds (993 allocations: 23.656 KiB)\n", " 0.287258 seconds (993 allocations: 23.656 KiB)\n", " 3.330868 seconds (62.65 k allocations: 3.898 MiB, 0.18% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} + a x + b, x, domain=\\mathbb{Z}\\left[a, b\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{9} + \\left(3 a + 3 p\\right) z^{7} + \\left(3 b + 3 q\\right) z^{6} + \\left(3 a^{2} + 3 a p + 3 p^{2}\\right) z^{5} + \\left(6 a b - 3 a q - 3 b p + 6 p q\\right) z^{4} + \\left(a^{3} + a^{2} p + a p^{2} + 3 b^{2} - 21 b q + p^{3} + 3 q^{2}\\right) z^{3} + \\left(3 a^{2} b + 3 a^{2} q - 6 a b p - 6 a p q + 3 b p^{2} + 3 p^{2} q\\right) z^{2} + \\left(a^{3} p - 2 a^{2} p^{2} + 3 a b^{2} - 3 a b q + a p^{3} - 6 a q^{2} - 6 b^{2} p - 3 b p q + 3 p q^{2}\\right) z + a^{3} q + a^{2} b p - 2 a^{2} p q - 2 a b p^{2} + a p^{2} q + b^{3} + 3 b^{2} q + b p^{3} + 3 b q^{2} + q^{3}, z, domain=\\mathbb{Z}\\left[p, q, a, b\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 + a*x + b, x, domain='ZZ[a,b]')\n", " Poly(y**3 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^9 + (3*a + 3*p)*z^7 + (3*b + 3*q)*z^6 + (3*a^2 + 3*a*p + 3*p^2)*z^5 + (6*a*b - 3*a*q - 3*b*p + 6*p*q)*z^4 + (a^3 + a^2*p + a*p^2 + 3*b^2 - 21*b*q + p^3 + 3*q^2)*z^3 + (3*a^2*b + 3*a^2*q - 6*a*b*p - 6*a*p*q + 3*b*p^2 + 3*p^2*q)*z^2 + (a^3*p - 2*a^2*p^2 + 3*a*b^2 - 3*a*b*q + a*p^3 - 6*a*q^2 - 6*b^2*p - 3*b*p*q + 3*p*q^2)*z + a^3*q + a^2*b*p - 2*a^2*p*q - 2*a*b*p^2 + a*p^2*q + b^3 + 3*b^2*q + b*p^3 + 3*b*q^2 + q^3, z, domain='ZZ[p,q,a,b]')" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a b p q x y\n", "f = x^3 + a*x + b\n", "g = y^3 + p*y + q\n", "h = x + y\n", "minpoly(x, y, f, g, h, 9)" ] }, { "cell_type": "code", "execution_count": 16, "id": "7df06c6e-92c9-4e4c-a821-fb424c9ef0a7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.075285 seconds (993 allocations: 23.656 KiB)\n", " 0.238995 seconds (993 allocations: 23.656 KiB)\n", " 0.156825 seconds (347 allocations: 10.562 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} + a x + b, x, domain=\\mathbb{Z}\\left[a, b\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{3} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{9} - 2 a p z^{7} - 3 b q z^{6} + a^{2} p^{2} z^{5} + a b p q z^{4} + \\left(a^{3} q^{2} + b^{2} p^{3} + 3 b^{2} q^{2}\\right) z^{3} + a b^{2} p q^{2} z - b^{3} q^{3}, z, domain=\\mathbb{Z}\\left[p, q, a, b\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 + a*x + b, x, domain='ZZ[a,b]')\n", " Poly(y**3 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z^9 - 2*a*p*z^7 - 3*b*q*z^6 + a^2*p^2*z^5 + a*b*p*q*z^4 + (a^3*q^2 + b^2*p^3 + 3*b^2*q^2)*z^3 + a*b^2*p*q^2*z - b^3*q^3, z, domain='ZZ[p,q,a,b]')" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a b p q x y\n", "f = x^3 + a*x + b\n", "g = y^3 + p*y + q\n", "h = x * y\n", "minpoly(x, y, f, g, h, 9)" ] }, { "cell_type": "code", "execution_count": 17, "id": "5e214c14-d8ea-4931-a7f7-1b101ddb8220", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.292580 seconds (1.57 k allocations: 37.516 KiB)\n", " 0.380052 seconds (1.43 k allocations: 34.047 KiB)\n", " 3.643590 seconds (62.84 k allocations: 3.905 MiB, 0.16% compilation time)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{4} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( x + y, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{12} + \\left(- 4 a + 3 p\\right) z^{9} + 3 q z^{8} + \\left(6 a^{2} + 18 a p + 3 p^{2}\\right) z^{6} + \\left(48 a q + 6 p q\\right) z^{5} + 3 q^{2} z^{4} + \\left(- 4 a^{3} - 18 a^{2} p - 6 a p^{2} + p^{3}\\right) z^{3} + \\left(30 a^{2} q - 6 a p q + 3 p^{2} q\\right) z^{2} + \\left(- 12 a q^{2} + 3 p q^{2}\\right) z + a^{4} - 3 a^{3} p + 3 a^{2} p^{2} - a p^{3} + q^{3}, z, domain=\\mathbb{Z}\\left[p, q, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 - a, x, domain='ZZ[a]')\n", " Poly(y**4 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x + y, x, y, domain='ZZ')\n", " Poly(z^12 + (-4*a + 3*p)*z^9 + 3*q*z^8 + (6*a^2 + 18*a*p + 3*p^2)*z^6 + (48*a*q + 6*p*q)*z^5 + 3*q^2*z^4 + (-4*a^3 - 18*a^2*p - 6*a*p^2 + p^3)*z^3 + (30*a^2*q - 6*a*p*q + 3*p^2*q)*z^2 + (-12*a*q^2 + 3*p*q^2)*z + a^4 - 3*a^3*p + 3*a^2*p^2 - a*p^3 + q^3, z, domain='ZZ[p,q,a]')" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q x y\n", "f = x^3 - a\n", "g = y^4 + p*y + q\n", "h = x + y\n", "minpoly(x, y, f, g, h, 12)" ] }, { "cell_type": "code", "execution_count": 18, "id": "4351be1a-2813-4f4b-80e8-78adcaf6f8e7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0.076121 seconds (1.57 k allocations: 37.516 KiB)\n", " 0.101282 seconds (1.43 k allocations: 34.047 KiB)\n", " 0.051363 seconds (551 allocations: 16.844 KiB)\n" ] }, { "data": { "text/latex": [ "$\\left[ \\begin{array}{r}\\operatorname{Poly}{\\left( x^{3} - a, x, domain=\\mathbb{Z}\\left[a\\right] \\right)}\\\\\\operatorname{Poly}{\\left( y^{4} + p y + q, y, domain=\\mathbb{Z}\\left[p, q\\right] \\right)}\\\\\\operatorname{Poly}{\\left( xy, x, y, domain=\\mathbb{Z} \\right)}\\\\\\operatorname{Poly}{\\left( z^{12} + 3 a p z^{9} + 3 a^{2} p^{2} z^{6} + a^{3} p^{3} z^{3} + a^{4} q^{3}, z, domain=\\mathbb{Z}\\left[p, q, a\\right] \\right)}\\end{array} \\right]$\n" ], "text/plain": [ "4-element Vector{Sym}:\n", " Poly(x**3 - a, x, domain='ZZ[a]')\n", " Poly(y**4 + p*y + q, y, domain='ZZ[p,q]')\n", " Poly(x*y, x, y, domain='ZZ')\n", " Poly(z^12 + 3*a*p*z^9 + 3*a^2*p^2*z^6 + a^3*p^3*z^3 + a^4*q^3, z, domain='ZZ[p,q,a]')" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@vars a p q x y\n", "f = x^3 - a\n", "g = y^4 + p*y + q\n", "h = x * y\n", "minpoly(x, y, f, g, h, 12)" ] }, { "cell_type": "code", "execution_count": null, "id": "b285fa08-cbe5-4b23-a432-c8a5ab264332", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "jupytext": { "formats": "ipynb,jl:hydrogen" }, "kernelspec": { "display_name": "Julia 1.6.3", "language": "julia", "name": "julia-1.6" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.6.3" } }, "nbformat": 4, "nbformat_minor": 5 }