{ "cells": [ { "cell_type": "markdown", "id": "vocational-obligation", "metadata": {}, "source": [ "## Flow tree formulas\n", "Here we will test the attractor tree formula (see [arXiv:1910.03098](https://arxiv.org/abs/1910.03098) and [arXiv:2101.07636](https://arxiv.org/abs/2101.07636)) and the flow tree formula (see [arXiv:1804.06928](https://arxiv.org/abs/1804.06928) and [arXiv:2102.11200](https://arxiv.org/abs/2102.11200)). They allow us to find rational DT invariants for any stability parameter from rational attractor invariants.\n", "We will compare these computations to the algorithm from [arXiv:math/0204059](https://arxiv.org/abs/math/0204059) that allows us to find the same invariants from the total invariant (stacky invariant for the trivial stability). We will also compare implementation speeds of all algorithms." ] }, { "cell_type": "code", "execution_count": 1, "id": "involved-village", "metadata": {}, "outputs": [], "source": [ "import os, sys\n", "module_path = os.path.abspath(os.path.join('..'))\n", "if module_path not in sys.path:\n", " sys.path.append(module_path)\n", "from msinvar import *" ] }, { "cell_type": "code", "execution_count": 5, "id": "prescription-recipe", "metadata": {}, "outputs": [], "source": [ "Q=KroneckerQuiver(3, prec=[3,3])\n", "z=Stability([1,0])" ] }, { "cell_type": "code", "execution_count": 6, "id": "universal-reggae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 442 ms, sys: 2.62 ms, total: 444 ms\n", "Wall time: 443 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0): 1,\n", " (2, 0): 1/2*y/(y^2 + 1),\n", " (3, 0): 1/3*y^2/(y^4 + y^2 + 1),\n", " (0, 1): 1,\n", " (1, 1): (y^4 + y^2 + 1)/y^2,\n", " (2, 1): (y^4 + y^2 + 1)/y^2,\n", " (3, 1): 1,\n", " (0, 2): 1/2*y/(y^2 + 1),\n", " (1, 2): (y^4 + y^2 + 1)/y^2,\n", " (2,\n", " 2): (-y^12 - 3/2*y^10 - 2*y^8 - 3/2*y^6 - 2*y^4 - 3/2*y^2 - 1)/(y^7 + y^5),\n", " (3, 2): (y^12 + y^10 + 3*y^8 + 3*y^6 + 3*y^4 + y^2 + 1)/y^6,\n", " (0, 3): 1/3*y^2/(y^4 + y^2 + 1),\n", " (1, 3): 1,\n", " (2, 3): (y^12 + y^10 + 3*y^8 + 3*y^6 + 3*y^4 + y^2 + 1)/y^6,\n", " (3,\n", " 3): (y^24 + 2*y^22 + 4*y^20 + 16/3*y^18 + 6*y^16 + 6*y^14 + 19/3*y^12 + 6*y^10 + 6*y^8 + 16/3*y^6 + 4*y^4 + 2*y^2 + 1)/(y^14 + y^12 + y^10)}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb1=Q.attr_tree_formula(z,Q.ratAtt_default())\n", "%time Omb1.dict()" ] }, { "cell_type": "code", "execution_count": 7, "id": "promising-allergy", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 695 ms, sys: 5.35 ms, total: 700 ms\n", "Wall time: 704 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0): 1,\n", " (2, 0): 1/2*y/(y^2 + 1),\n", " (3, 0): 1/3*y^2/(y^4 + y^2 + 1),\n", " (0, 1): 1,\n", " (1, 1): (y^4 + y^2 + 1)/y^2,\n", " (2, 1): (y^4 + y^2 + 1)/y^2,\n", " (3, 1): 1,\n", " (0, 2): 1/2*y/(y^2 + 1),\n", " (1, 2): (y^4 + y^2 + 1)/y^2,\n", " (2,\n", " 2): (-y^12 - 3/2*y^10 - 2*y^8 - 3/2*y^6 - 2*y^4 - 3/2*y^2 - 1)/(y^7 + y^5),\n", " (3, 2): (y^12 + y^10 + 3*y^8 + 3*y^6 + 3*y^4 + y^2 + 1)/y^6,\n", " (0, 3): 1/3*y^2/(y^4 + y^2 + 1),\n", " (1, 3): 1,\n", " (2, 3): (y^12 + y^10 + 3*y^8 + 3*y^6 + 3*y^4 + y^2 + 1)/y^6,\n", " (3,\n", " 3): (y^24 + 2*y^22 + 4*y^20 + 16/3*y^18 + 6*y^16 + 6*y^14 + 19/3*y^12 + 6*y^10 + 6*y^8 + 16/3*y^6 + 4*y^4 + 2*y^2 + 1)/(y^14 + y^12 + y^10)}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb2=Q.flow_tree_formula(z,Q.ratAtt_default())\n", "%time Omb2.dict()" ] }, { "cell_type": "code", "execution_count": 8, "id": "integral-execution", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 47.4 ms, sys: 2.69 ms, total: 50.1 ms\n", "Wall time: 50.1 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0): 1,\n", " (2, 0): 1/2*y/(y^2 + 1),\n", " (3, 0): 1/3*y^2/(y^4 + y^2 + 1),\n", " (0, 1): 1,\n", " (1, 1): (-y^4 - y^2 - 1)/(-y^2),\n", " (2, 1): (-y^4 - y^2 - 1)/(-y^2),\n", " (3, 1): 1,\n", " (0, 2): 1/2*y/(y^2 + 1),\n", " (1, 2): (-y^4 - y^2 - 1)/(-y^2),\n", " (2,\n", " 2): (y^12 + 3/2*y^10 + 2*y^8 + 3/2*y^6 + 2*y^4 + 3/2*y^2 + 1)/(-y^7 - y^5),\n", " (3, 2): (y^12 + y^10 + 3*y^8 + 3*y^6 + 3*y^4 + y^2 + 1)/y^6,\n", " (0, 3): 1/3*y^2/(y^4 + y^2 + 1),\n", " (1, 3): 1,\n", " (2, 3): (-y^12 - y^10 - 3*y^8 - 3*y^6 - 3*y^4 - y^2 - 1)/(-y^6),\n", " (3,\n", " 3): (y^24 + 2*y^22 + 4*y^20 + 16/3*y^18 + 6*y^16 + 6*y^14 + 19/3*y^12 + 6*y^10 + 6*y^8 + 16/3*y^6 + 4*y^4 + 2*y^2 + 1)/(y^14 + y^12 + y^10)}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb3=Q.rat_from_total(z)\n", "%time Omb3.dict()" ] }, { "cell_type": "markdown", "id": "engaged-willow", "metadata": {}, "source": [ "### Another example" ] }, { "cell_type": "code", "execution_count": 9, "id": "leading-establishment", "metadata": {}, "outputs": [], "source": [ "r=6\n", "Q=ChainQuiver(r)\n", "Q.prec([1]*r)\n", "z=Stability([1]*r).randomize()" ] }, { "cell_type": "code", "execution_count": 11, "id": "human-machine", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 14.1 s, sys: 18.4 ms, total: 14.1 s\n", "Wall time: 14.1 s\n" ] }, { "data": { "text/plain": [ "{(1, 0, 0, 0, 0, 0): 1,\n", " (0, 1, 0, 0, 0, 0): 1,\n", " (0, 0, 1, 0, 0, 0): 1,\n", " (0, 0, 0, 1, 0, 0): 1,\n", " (0, 0, 1, 1, 0, 0): 1,\n", " (0, 1, 1, 1, 0, 0): 1,\n", " (0, 0, 0, 0, 1, 0): 1,\n", " (0, 0, 1, 1, 1, 0): 1,\n", " (0, 1, 1, 1, 1, 0): 1,\n", " (0, 0, 0, 0, 0, 1): 1,\n", " (0, 0, 0, 0, 1, 1): 1,\n", " (0, 0, 1, 1, 1, 1): 1,\n", " (0, 1, 1, 1, 1, 1): 1}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb1=Q.attr_tree_formula(z,Q.ratAtt_default())\n", "%time Omb1.dict()" ] }, { "cell_type": "code", "execution_count": 12, "id": "isolated-telling", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 500 ms, sys: 2.9 ms, total: 503 ms\n", "Wall time: 502 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0, 0, 0, 0, 0): 1,\n", " (0, 1, 0, 0, 0, 0): 1,\n", " (0, 0, 1, 0, 0, 0): 1,\n", " (0, 0, 0, 1, 0, 0): 1,\n", " (0, 0, 1, 1, 0, 0): 1,\n", " (0, 1, 1, 1, 0, 0): 1,\n", " (0, 0, 0, 0, 1, 0): 1,\n", " (0, 0, 1, 1, 1, 0): 1,\n", " (0, 1, 1, 1, 1, 0): 1,\n", " (0, 0, 0, 0, 0, 1): 1,\n", " (0, 0, 0, 0, 1, 1): 1,\n", " (0, 0, 1, 1, 1, 1): 1,\n", " (0, 1, 1, 1, 1, 1): 1}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb2=Q.flow_tree_formula(z,Q.ratAtt_default())\n", "%time Omb2.dict()" ] }, { "cell_type": "code", "execution_count": 13, "id": "starting-gender", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 143 ms, sys: 2.01 ms, total: 145 ms\n", "Wall time: 144 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0, 0, 0, 0, 0): 1,\n", " (0, 1, 0, 0, 0, 0): 1,\n", " (0, 0, 1, 0, 0, 0): 1,\n", " (0, 0, 0, 1, 0, 0): 1,\n", " (0, 0, 1, 1, 0, 0): 1,\n", " (0, 1, 1, 1, 0, 0): 1,\n", " (0, 0, 0, 0, 1, 0): 1,\n", " (0, 0, 1, 1, 1, 0): 1,\n", " (0, 1, 1, 1, 1, 0): 1,\n", " (0, 0, 0, 0, 0, 1): 1,\n", " (0, 0, 0, 0, 1, 1): 1,\n", " (0, 0, 1, 1, 1, 1): 1,\n", " (0, 1, 1, 1, 1, 1): 1}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb3=Q.rat_from_total(z)\n", "%time Omb3.dict()" ] }, { "cell_type": "code", "execution_count": 16, "id": "bulgarian-shoulder", "metadata": {}, "outputs": [], "source": [ "r=7\n", "Q=ChainQuiver(r)\n", "Q.prec([1]*r)\n", "z=Stability([1]*r).randomize()" ] }, { "cell_type": "code", "execution_count": 17, "id": "headed-force", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 8.19 s, sys: 11 ms, total: 8.2 s\n", "Wall time: 8.2 s\n" ] }, { "data": { "text/plain": [ "{(1, 0, 0, 0, 0, 0, 0): 1,\n", " (0, 1, 0, 0, 0, 0, 0): 1,\n", " (1, 1, 0, 0, 0, 0, 0): 1,\n", " (0, 0, 1, 0, 0, 0, 0): 1,\n", " (0, 0, 0, 1, 0, 0, 0): 1,\n", " (0, 0, 0, 0, 1, 0, 0): 1,\n", " (0, 0, 0, 1, 1, 0, 0): 1,\n", " (0, 0, 1, 1, 1, 0, 0): 1,\n", " (0, 0, 0, 0, 0, 1, 0): 1,\n", " (0, 0, 0, 0, 0, 0, 1): 1,\n", " (0, 0, 0, 0, 0, 1, 1): 1,\n", " (0, 0, 0, 0, 1, 1, 1): 1,\n", " (0, 0, 0, 1, 1, 1, 1): 1,\n", " (0, 0, 1, 1, 1, 1, 1): 1}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb2=Q.flow_tree_formula(z,Q.ratAtt_default())\n", "%time Omb2.dict()" ] }, { "cell_type": "code", "execution_count": 18, "id": "divided-indonesian", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 400 ms, sys: 2.18 ms, total: 402 ms\n", "Wall time: 401 ms\n" ] }, { "data": { "text/plain": [ "{(1, 0, 0, 0, 0, 0, 0): 1,\n", " (0, 1, 0, 0, 0, 0, 0): 1,\n", " (1, 1, 0, 0, 0, 0, 0): 1,\n", " (0, 0, 1, 0, 0, 0, 0): 1,\n", " (0, 0, 0, 1, 0, 0, 0): 1,\n", " (0, 0, 0, 0, 1, 0, 0): 1,\n", " (0, 0, 0, 1, 1, 0, 0): 1,\n", " (0, 0, 1, 1, 1, 0, 0): 1,\n", " (0, 0, 0, 0, 0, 1, 0): 1,\n", " (0, 0, 0, 0, 0, 0, 1): 1,\n", " (0, 0, 0, 0, 0, 1, 1): 1,\n", " (0, 0, 0, 0, 1, 1, 1): 1,\n", " (0, 0, 0, 1, 1, 1, 1): 1,\n", " (0, 0, 1, 1, 1, 1, 1): 1}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb3=Q.rat_from_total(z)\n", "%time Omb3.dict()" ] }, { "cell_type": "code", "execution_count": 19, "id": "sized-change", "metadata": {}, "outputs": [], "source": [ "r=8\n", "Q=ChainQuiver(r)\n", "Q.prec([1]*r)\n", "z=Stability([1]*r).randomize()" ] }, { "cell_type": "code", "execution_count": 14, "id": "boxed-median", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 1min 39s, sys: 103 ms, total: 1min 39s\n", "Wall time: 1min 39s\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb2=Q.flow_tree_formula(z,Q.ratAtt_default())\n", "%time Omb2([1]*r)" ] }, { "cell_type": "code", "execution_count": 19, "id": "passing-intranet", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 292 ms, sys: 2.3 ms, total: 294 ms\n", "Wall time: 293 ms\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Omb3=Q.rat_from_total(z)\n", "%time Omb3([1]*r)" ] }, { "cell_type": "code", "execution_count": null, "id": "satellite-tattoo", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 9.2", "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.8.5" } }, "nbformat": 4, "nbformat_minor": 5 }