diff --git a/Apollonian Circle Packings.ipynb b/Apollonian Circle Packings.ipynb index 92c155f..7ee52b5 100644 --- a/Apollonian Circle Packings.ipynb +++ b/Apollonian Circle Packings.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -30,7 +30,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -42,7 +42,7 @@ "[ 0 0 0 1]" ] }, - "execution_count": 4, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -99,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": { "scrolled": true }, @@ -113,7 +113,7 @@ "[-2 -2 -2 -4]" ] }, - "execution_count": 6, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -140,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "scrolled": true }, @@ -154,7 +154,7 @@ "[-1/4 -1/4 -1/4 1/8]" ] }, - "execution_count": 7, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -165,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -197,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -206,7 +206,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -218,7 +218,7 @@ "[ 0 0 0 1]" ] }, - "execution_count": 10, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -229,7 +229,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -238,7 +238,7 @@ "b1^2 + b2^2 + b3^2 - b1*b_avg - b2*b_avg - b3*b_avg + 1/4*b_avg^2" ] }, - "execution_count": 11, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -269,7 +269,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -283,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -293,7 +293,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -305,7 +305,7 @@ "[ -1 -1 -1 1/2]" ] }, - "execution_count": 14, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -316,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -330,7 +330,7 @@ "]" ] }, - "execution_count": 15, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -342,7 +342,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -361,7 +361,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -370,7 +370,7 @@ "(7, 2, 4, 6)" ] }, - "execution_count": 17, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -382,7 +382,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -391,7 +391,7 @@ "(-1, 4, 4, 6)" ] }, - "execution_count": 18, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -402,7 +402,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -411,7 +411,7 @@ "(-1, 2, 2, 6)" ] }, - "execution_count": 19, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -422,7 +422,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -431,7 +431,7 @@ "(-1, 2, 4, 14)" ] }, - "execution_count": 20, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -451,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -475,7 +475,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -540,7 +540,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -557,7 +557,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -569,7 +569,7 @@ "[ 0 0 0 1 -1/2 1/2 1/2 1/2]" ] }, - "execution_count": 24, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -613,7 +613,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -627,7 +627,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -639,7 +639,7 @@ "[-3 -3 -3 1]" ] }, - "execution_count": 26, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -651,7 +651,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -663,7 +663,7 @@ "[-6/5 -6/5 -6/5 2]" ] }, - "execution_count": 27, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -674,7 +674,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -686,7 +686,7 @@ "[bt4 b4 h14 h24]" ] }, - "execution_count": 28, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -705,7 +705,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -714,7 +714,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -723,7 +723,7 @@ "5*b1^2 - 6*b1*b2 + 5*b2^2 - 6*b1*b3 - 6*b2*b3 + 5*b3^2 - 6*b1*b4 - 6*b2*b4 - 6*b3*b4 + 5*b4^2" ] }, - "execution_count": 30, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -750,7 +750,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 29, "metadata": { "scrolled": true }, @@ -771,7 +771,7 @@ "]" ] }, - "execution_count": 31, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -783,7 +783,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 30, "metadata": { "scrolled": true }, @@ -801,7 +801,7 @@ "[ 0 0 0 0 0 0 0 0]" ] }, - "execution_count": 32, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -820,11 +820,12 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "def quadform_from_root(root_matrix):\n", + " n = root_matrix.dimensions()[1]\n", " P = matrix([\n", " [0, -1/2, 0, 0],\n", " [-1/2, 0, 0, 0],\n", @@ -833,8 +834,11 @@ " ])\n", " \n", " # step 1: find linear relation between coords\n", - " relation = root_matrix.transpose().rref() * vector([ var('b' + str(i)) for i in range(1, root_matrix.dimensions()[0] + 1)])\n", - " \n", + " relations_temp = vector([ var('b' + str(i)) for i in range(1, n + 1)]) * root_matrix.transpose().rref()\n", + " relations = []\n", + " for i, expr in enumerate(relations_temp):\n", + " relations.append(var('b' + str(i + 1)) == expr)\n", + " \n", " # step 2: find matrix of quadratic form\n", " W = root_matrix[-4:]\n", " M = W * P * W.transpose()\n", @@ -850,28 +854,131 @@ " ])\n", " D = factor(simplify(expand(W2.transpose() * M.inverse() * W2)))\n", " \n", - " return relation, M.inverse(), D[1][1]" + " return relations[4:], M.inverse(), D[1][1]" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 32, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "(2*b1 + b5 + b6 + b7 - b8, 2*b2 + b5 + b6 - b7 + b8, 2*b3 + b5 - b6 + b7 + b8, 2*b4 - b5 + b6 + b7 + b8)\n", - "[ 5 -3 -3 -3]\n", - "[-3 5 -3 -3]\n", - "[-3 -3 5 -3]\n", - "[-3 -3 -3 5]\n", - "5*b1^2 - 6*b1*b2 + 5*b2^2 - 6*b1*b3 - 6*b2*b3 + 5*b3^2 - 6*b1*b4 - 6*b2*b4 - 6*b3*b4 + 5*b4^2\n" - ] + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[2 \\, b_{5} = b_{1} + b_{2} + b_{3} - b_{4}, 2 \\, b_{6} = b_{1} + b_{2} - b_{3} + b_{4}, 2 \\, b_{7} = b_{1} - b_{2} + b_{3} + b_{4}, 2 \\, b_{8} = -b_{1} + b_{2} + b_{3} + b_{4}\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[2*b5 == b1 + b2 + b3 - b4,\n", + " 2*b6 == b1 + b2 - b3 + b4,\n", + " 2*b7 == b1 - b2 + b3 + b4,\n", + " 2*b8 == -b1 + b2 + b3 + b4]" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n", + "5 & -3 & -3 & -3 \\\\\n", + "-3 & 5 & -3 & -3 \\\\\n", + "-3 & -3 & 5 & -3 \\\\\n", + "-3 & -3 & -3 & 5\n", + "\\end{array}\\right)\n", + "\\end{math}" + ], + "text/plain": [ + "[ 5 -3 -3 -3]\n", + "[-3 5 -3 -3]\n", + "[-3 -3 5 -3]\n", + "[-3 -3 -3 5]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}5 \\, b_{1}^{2} - 6 \\, b_{1} b_{2} + 5 \\, b_{2}^{2} - 6 \\, b_{1} b_{3} - 6 \\, b_{2} b_{3} + 5 \\, b_{3}^{2} - 6 \\, b_{1} b_{4} - 6 \\, b_{2} b_{4} - 6 \\, b_{3} b_{4} + 5 \\, b_{4}^{2}\n", + "\\end{math}" + ], + "text/plain": [ + "5*b1^2 - 6*b1*b2 + 5*b2^2 - 6*b1*b3 - 6*b2*b3 + 5*b3^2 - 6*b1*b4 - 6*b2*b4 - 6*b3*b4 + 5*b4^2" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\left(\\begin{array}{rrrr}\n", + "-1 & \\frac{6}{5} & \\frac{6}{5} & \\frac{6}{5} \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "\\frac{6}{5} & -1 & \\frac{6}{5} & \\frac{6}{5} \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "\\frac{6}{5} & \\frac{6}{5} & -1 & \\frac{6}{5} \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "\\frac{6}{5} & \\frac{6}{5} & \\frac{6}{5} & -1\n", + "\\end{array}\\right)\\right]\n", + "\\end{math}" + ], "text/plain": [ "[\n", "[ -1 6/5 6/5 6/5] [ 1 0 0 0] [ 1 0 0 0]\n", @@ -886,39 +993,138 @@ "]" ] }, - "execution_count": 34, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ "# cubical\n", "relation, mat, equation = quadform_from_root(Wc)\n", - "print(2 * relation)\n", - "print(32 * mat)\n", - "print(32 * equation)\n", - "weyl_generators(32 * mat, standard_basis(4))" + "show([2 * eq for eq in relation])\n", + "show(32 * mat)\n", + "show(32 * equation)\n", + "show(weyl_generators(32 * mat, standard_basis(4)))" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 33, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "(b1 + b5 + b6, b2 - b5, b3 - b6, b4 + b5 + b6)\n", - "[ 1 -2 -2 -1]\n", - "[-2 4 0 -2]\n", - "[-2 0 4 -2]\n", - "[-1 -2 -2 1]\n", - "b1^2 - 4*b1*b2 + 4*b2^2 - 4*b1*b3 + 4*b3^2 - 2*b1*b4 - 4*b2*b4 - 4*b3*b4 + b4^2\n" - ] + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[b_{5} = b_{1} - b_{2} + b_{4}, b_{6} = b_{1} - b_{3} + b_{4}\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[b5 == b1 - b2 + b4, b6 == b1 - b3 + b4]" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n", + "1 & -2 & -2 & -1 \\\\\n", + "-2 & 4 & 0 & -2 \\\\\n", + "-2 & 0 & 4 & -2 \\\\\n", + "-1 & -2 & -2 & 1\n", + "\\end{array}\\right)\n", + "\\end{math}" + ], + "text/plain": [ + "[ 1 -2 -2 -1]\n", + "[-2 4 0 -2]\n", + "[-2 0 4 -2]\n", + "[-1 -2 -2 1]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}b_{1}^{2} - 4 \\, b_{1} b_{2} + 4 \\, b_{2}^{2} - 4 \\, b_{1} b_{3} + 4 \\, b_{3}^{2} - 2 \\, b_{1} b_{4} - 4 \\, b_{2} b_{4} - 4 \\, b_{3} b_{4} + b_{4}^{2}\n", + "\\end{math}" + ], + "text/plain": [ + "b1^2 - 4*b1*b2 + 4*b2^2 - 4*b1*b3 + 4*b3^2 - 2*b1*b4 - 4*b2*b4 - 4*b3*b4 + b4^2" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\left(\\begin{array}{rrrr}\n", + "-1 & 4 & 4 & 2 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "1 & -1 & 0 & 1 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "1 & 0 & -1 & 1 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "2 & 4 & 4 & -1\n", + "\\end{array}\\right)\\right]\n", + "\\end{math}" + ], "text/plain": [ "[\n", "[-1 4 4 2] [ 1 0 0 0] [ 1 0 0 0] [ 1 0 0 0]\n", @@ -928,9 +1134,8 @@ "]" ] }, - "execution_count": 35, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ @@ -943,31 +1148,131 @@ " [4, 2, 2*sqrt(2), 1],\n", " [7, 1, 2*sqrt(2), 0],\n", "]))\n", - "print(relation)\n", - "print(8 * mat)\n", - "print(8 * equation)\n", - "weyl_generators(8 * mat, standard_basis(4))" + "show(relation)\n", + "show(8 * mat)\n", + "show(8 * equation)\n", + "show(weyl_generators(8 * mat, standard_basis(4)))" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 34, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "(b1, b2, b3, b4)\n", - "[ 1 -1 -1 -1]\n", - "[-1 1 -1 -1]\n", - "[-1 -1 1 -1]\n", - "[-1 -1 -1 1]\n", - "b1^2 - 2*b1*b2 + b2^2 - 2*b1*b3 - 2*b2*b3 + b3^2 - 2*b1*b4 - 2*b2*b4 - 2*b3*b4 + b4^2\n" - ] + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[]" + ] + }, + "metadata": {}, + "output_type": "display_data" }, { "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n", + "1 & -1 & -1 & -1 \\\\\n", + "-1 & 1 & -1 & -1 \\\\\n", + "-1 & -1 & 1 & -1 \\\\\n", + "-1 & -1 & -1 & 1\n", + "\\end{array}\\right)\n", + "\\end{math}" + ], + "text/plain": [ + "[ 1 -1 -1 -1]\n", + "[-1 1 -1 -1]\n", + "[-1 -1 1 -1]\n", + "[-1 -1 -1 1]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}b_{1}^{2} - 2 \\, b_{1} b_{2} + b_{2}^{2} - 2 \\, b_{1} b_{3} - 2 \\, b_{2} b_{3} + b_{3}^{2} - 2 \\, b_{1} b_{4} - 2 \\, b_{2} b_{4} - 2 \\, b_{3} b_{4} + b_{4}^{2}\n", + "\\end{math}" + ], + "text/plain": [ + "b1^2 - 2*b1*b2 + b2^2 - 2*b1*b3 - 2*b2*b3 + b3^2 - 2*b1*b4 - 2*b2*b4 - 2*b3*b4 + b4^2" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\left(\\begin{array}{rrrr}\n", + "-1 & 2 & 2 & 2 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "2 & -1 & 2 & 2 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "2 & 2 & -1 & 2 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "2 & 2 & 2 & -1\n", + "\\end{array}\\right)\\right]\n", + "\\end{math}" + ], "text/plain": [ "[\n", "[-1 2 2 2] [ 1 0 0 0] [ 1 0 0 0] [ 1 0 0 0]\n", @@ -977,9 +1282,8 @@ "]" ] }, - "execution_count": 36, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ @@ -990,17 +1294,382 @@ " [-1, 1, 0, 0],\n", " [3, 1, 2, 0]\n", "]))\n", - "print(relation)\n", - "print(4 * mat)\n", - "print(4 * equation)\n", - "weyl_generators(4 * mat, standard_basis(4))" + "show(relation)\n", + "show(4 * mat)\n", + "show(4 * equation)\n", + "show(weyl_generators(4 * mat, standard_basis(4)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "I suspect that it is highly dependent on the order of the circles in the root. Interestingly, it looks like the only relation it was able to deduce for the tetrahedral packing is $b_1, b_2, b_3, b_4 = 0$, meaning there is no null space, as we'd expect. The octahedral quadratic form we get is very different, which isn't surprising, I guess, since this is a very different coordinate system, but I'm not sure if it's right. It feels very strange, since it's only really two dimensional, rather than four, and it doesn't quite look like the equations hold up. But it does absolutely work for the tetrahedral packing, which is awesome." + "# $n$-Gon Base Pyramid\n", + "\n", + "The goal here is to find the quadratic form for an arbitrary $n$-gon base pyramid. The key to the whole process is a magic formula Dylan found for the bilinear form between two circles in an $n$-gon base pyramidal packing, namely $$\n", + " \\frac{1 - \\cos\\left(\\frac{2\\pi}{n}\\right) - 4\\sin^2\\left(\\frac{p\\pi}{n}\\right)}{1-\\cos\\left(\\frac{2\\pi}{n}\\right)}\n", + "$$\n", + "\n", + "where $p$ is how many circles are between the two circles in question. If we are finding the bilinear form between the central circle and any other circle it will always be $-1$ so we don't need to worry about that case." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [], + "source": [ + "# function to compute W^T*P*W for n-gon pyramidal packing\n", + "def wmatrix(n):\n", + " vals = []\n", + " for i in range(n+1):\n", + " row = []\n", + " for j in range(n+1):\n", + " if i == j: # same vertex bilinear form'd with itself, so 1\n", + " row.append(1)\n", + " elif i ==0 or j == 0: # vertex bilinear form'd with special point, so tangent and therefore -1\n", + " row.append(-1)\n", + " else:\n", + " p = abs(i - j) # otherwise Dylan's crazy formula\n", + " row.append(\n", + " (1 - cos(2 * pi / n) - 4 * sin(pi * p / n)^2) / (1 - cos(2 * pi / n))\n", + " )\n", + " vals.append(row)\n", + " return matrix(vals)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "# just convenience function for quadratic forms\n", + "def qform(matrix, vector):\n", + " return vector * matrix * vector" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [], + "source": [ + "# function to compute the linear relations and quadratic formula for an ngon base pyramid\n", + "# the circles will be numbered 1 in the center, then 2 through n winding around the circle by step, so\n", + "# for n = 4 with step = 1, we have\n", + "# b3\n", + "# b4 b1 b2\n", + "# b5\n", + "# and the quadratic form is in terms of b1, b2, b3, and b4\n", + "# and for n = 6 with step = 2, we have\n", + "# b4 b3\n", + "# b5 b1 b2\n", + "# b6 b7\n", + "# and the quadratic form is in terms of b1, b3, b5, and b7\n", + "def ngon_linear_relations_and_quadratic_form(n, step=1):\n", + " mat = wmatrix(n)\n", + " \n", + " # work out initial relations\n", + " relations_temp = vector([ var('b' + str(i)) for i in range(1, n + 2) ]) * mat.transpose().rref()\n", + " relations = []\n", + " for i in range(4, n + 1):\n", + " relations.append(var('b' + str(i + 1)) == relations_temp[i])\n", + " \n", + " # rewrite the relations in terms of the variables we care about, depends on the step\n", + " shuffled = (list(range(1, n + 2)) * step)[::step]\n", + " targets = [ var('b' + str(i)) for i in shuffled[4:] ]\n", + " relations = solve(relations, *targets)[0]\n", + " \n", + " # find the matrix corresponding to the quadratic form, picking the appropriate rows from the matrix\n", + " Q = mat[:4*step:step,:4*step:step].inverse()\n", + " \n", + " # find the quadratic form in variables; proper units will satisfy this being equal to zero\n", + " nqform = qform(Q, vector([ var('b' + str(i)) for i in range(1, 5) ]))\n", + " \n", + " return relations, Q, expand(nqform)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}b_{5} = b_{2} - b_{3} + b_{4}\n", + "\\end{math}" + ], + "text/plain": [ + "b5 == b2 - b3 + b4" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n", + "4 & -2 & 0 & -2 \\\\\n", + "-2 & 1 & -2 & -1 \\\\\n", + "0 & -2 & 4 & -2 \\\\\n", + "-2 & -1 & -2 & 1\n", + "\\end{array}\\right)\n", + "\\end{math}" + ], + "text/plain": [ + "[ 4 -2 0 -2]\n", + "[-2 1 -2 -1]\n", + "[ 0 -2 4 -2]\n", + "[-2 -1 -2 1]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}4 \\, b_{1}^{2} - 4 \\, b_{1} b_{2} + b_{2}^{2} - 4 \\, b_{2} b_{3} + 4 \\, b_{3}^{2} - 4 \\, b_{1} b_{4} - 2 \\, b_{2} b_{4} - 4 \\, b_{3} b_{4} + b_{4}^{2}\n", + "\\end{math}" + ], + "text/plain": [ + "4*b1^2 - 4*b1*b2 + b2^2 - 4*b2*b3 + 4*b3^2 - 4*b1*b4 - 2*b2*b4 - 4*b3*b4 + b4^2" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\left(\\begin{array}{rrrr}\n", + "-1 & 1 & 0 & 1 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "4 & -1 & 4 & 2 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 1 & -1 & 1 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "4 & 2 & 4 & -1\n", + "\\end{array}\\right)\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[\n", + "[-1 1 0 1] [ 1 0 0 0] [ 1 0 0 0] [ 1 0 0 0]\n", + "[ 0 1 0 0] [ 4 -1 4 2] [ 0 1 0 0] [ 0 1 0 0]\n", + "[ 0 0 1 0] [ 0 0 1 0] [ 0 1 -1 1] [ 0 0 1 0]\n", + "[ 0 0 0 1], [ 0 0 0 1], [ 0 0 0 1], [ 4 2 4 -1]\n", + "]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "relations, Q, nqform = ngon_linear_relations_and_quadratic_form(4)\n", + "\n", + "show(relations)\n", + "show(8 * Q)\n", + "show(8 * nqform)\n", + "show(weyl_generators(8 * Q, standard_basis(4)))" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[3 \\, b_{2} = 2 \\, b_{3} - b_{5} + 2 \\, b_{7}, 3 \\, b_{4} = 2 \\, b_{3} + 2 \\, b_{5} - b_{7}, 3 \\, b_{6} = -b_{3} + 2 \\, b_{5} + 2 \\, b_{7}\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[3*b2 == 2*b3 - b5 + 2*b7, 3*b4 == 2*b3 + 2*b5 - b7, 3*b6 == -b3 + 2*b5 + 2*b7]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n", + "9 & -1 & -1 & -1 \\\\\n", + "-1 & 1 & -1 & -1 \\\\\n", + "-1 & -1 & 1 & -1 \\\\\n", + "-1 & -1 & -1 & 1\n", + "\\end{array}\\right)\n", + "\\end{math}" + ], + "text/plain": [ + "[ 9 -1 -1 -1]\n", + "[-1 1 -1 -1]\n", + "[-1 -1 1 -1]\n", + "[-1 -1 -1 1]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}9 \\, b_{1}^{2} - 2 \\, b_{1} b_{2} + b_{2}^{2} - 2 \\, b_{1} b_{3} - 2 \\, b_{2} b_{3} + b_{3}^{2} - 2 \\, b_{1} b_{4} - 2 \\, b_{2} b_{4} - 2 \\, b_{3} b_{4} + b_{4}^{2}\n", + "\\end{math}" + ], + "text/plain": [ + "9*b1^2 - 2*b1*b2 + b2^2 - 2*b1*b3 - 2*b2*b3 + b3^2 - 2*b1*b4 - 2*b2*b4 - 2*b3*b4 + b4^2" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/latex": [ + "\\begin{math}\n", + "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[\\left(\\begin{array}{rrrr}\n", + "-1 & \\frac{2}{9} & \\frac{2}{9} & \\frac{2}{9} \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "2 & -1 & 2 & 2 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "2 & 2 & -1 & 2 \\\\\n", + "0 & 0 & 0 & 1\n", + "\\end{array}\\right), \\left(\\begin{array}{rrrr}\n", + "1 & 0 & 0 & 0 \\\\\n", + "0 & 1 & 0 & 0 \\\\\n", + "0 & 0 & 1 & 0 \\\\\n", + "2 & 2 & 2 & -1\n", + "\\end{array}\\right)\\right]\n", + "\\end{math}" + ], + "text/plain": [ + "[\n", + "[ -1 2/9 2/9 2/9] [ 1 0 0 0] [ 1 0 0 0] [ 1 0 0 0]\n", + "[ 0 1 0 0] [ 2 -1 2 2] [ 0 1 0 0] [ 0 1 0 0]\n", + "[ 0 0 1 0] [ 0 0 1 0] [ 2 2 -1 2] [ 0 0 1 0]\n", + "[ 0 0 0 1], [ 0 0 0 1], [ 0 0 0 1], [ 2 2 2 -1]\n", + "]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "relations, Q, nqform = ngon_linear_relations_and_quadratic_form(6, 2)\n", + "\n", + "show([3 * eq for eq in relations])\n", + "show(12 * Q)\n", + "show(12 * nqform)\n", + "show(weyl_generators(12 * Q, standard_basis(4)))" ] } ],