Skip to content
Snippets Groups Projects
plots_and_expressions.ipynb 33.3 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8ebd0216",
   "metadata": {},
   "source": [
    "# Utilities"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b22eb2a9",
   "metadata": {},
   "source": [
    "Define \\chern command in latex $\\newcommand{\\chern}{\\operatorname{ch}}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b87a49bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Requires extra package:\n",
    "#! sage -pip install \"pseudowalls==0.0.3\" --extra-index-url https://gitlab.com/api/v4/projects/43962374/packages/pypi/simple\n",
    "%display latex\n",
    "\n",
    "from pseudowalls import *\n",
    "\n",
    "Δ = lambda v: v.Q_tilt()\n",
    "alpha = stability.Tilt().alpha\n",
    "beta = stability.Tilt().beta\n",
    "\n",
    "def beta_minus(v):\n",
    "    solutions = solve(\n",
    "        stability.Tilt(alpha=0).degree(v)==0,\n",
    "        beta)\n",
    "    return min(map(lambda s: s.rhs(), solutions))\n",
    "\n",
    "class Object(object):\n",
    "  pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d374a2a",
   "metadata": {},
   "source": [
    "Fix a Chern character $v$ with positive rank and $\\originalDelta(v) \\geq 0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ab162897",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\text{Chern Character:} \\\\ \\begin{array}{l} \\mathrm{ch}_{0} = R \\\\ \\mathrm{ch}_{1} = C \\ell^{1} \\\\ \\mathrm{ch}_{2} = D \\ell^{2} \\end{array}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\text{Chern Character:} \\\\ \\begin{array}{l} \\mathrm{ch}_{0} = R \\\\ \\mathrm{ch}_{1} = C \\ell^{1} \\\\ \\mathrm{ch}_{2} = D \\ell^{2} \\end{array}$"
      ],
      "text/plain": [
       "<pseudowalls.chern_character.Chern_Char object at 0x7f1bd72a2010>"
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v = Chern_Char(*var(\"R C D\", domain=\"real\"))\n",
    "v"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "06d8357b",
   "metadata": {},
   "source": [
    "Let $u$ be a semistabilizer fitting problem 1 or 2 (destabilizing $v$ going down $\\Theta_v^{-}$)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0d33d7e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\text{Chern Character:} \\\\ \\begin{array}{l} \\mathrm{ch}_{0} = r \\\\ \\mathrm{ch}_{1} = c \\ell^{1} \\\\ \\mathrm{ch}_{2} = d \\ell^{2} \\end{array}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\text{Chern Character:} \\\\ \\begin{array}{l} \\mathrm{ch}_{0} = r \\\\ \\mathrm{ch}_{1} = c \\ell^{1} \\\\ \\mathrm{ch}_{2} = d \\ell^{2} \\end{array}$"
      ],
      "text/plain": [
       "<pseudowalls.chern_character.Chern_Char object at 0x7f1bccb53110>"
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "u = Chern_Char(*var(\"r c d\", domain=\"real\"))\n",
    "u"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb9c11e7",
   "metadata": {},
   "source": [
    "# Bounds on $\\operatorname{ch}_2(u)=d$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "23d48b0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle q$"
      ],
      "text/plain": [
       "q"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "var(\"q\", domain=\"real\") # Symbol for q=\\chern_1^{\\beta}(u)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "377c2843",
   "metadata": {},
   "source": [
    "Express $c$ in terms of $q:=\\chern_1^{\\beta}(u)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "c_in_terms_of_q = solve(q == u.twist(beta).ch[1], c)[0]\n",
    "assert c_in_terms_of_q.lhs() == c, \"Meant to be an expression for c\""
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle c = \\beta r + q\\)</html>"
       "$\\displaystyle c = \\beta r + q$"
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c_in_terms_of_q"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "760b306b",
   "metadata": {},
   "source": [
    "## $\\chern_2^{P}(u) > 0$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f866f7f",
   "metadata": {},
   "source": [
    "For problem 2, this amounts to $\\chern_2^{\\beta}(u) > 0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b9bb6e1e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle d > \\frac{1}{2} \\, \\beta^{2} r + \\beta q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle d > \\frac{1}{2} \\, \\beta^{2} r + \\beta q$"
      ],
      "text/plain": [
       "d > 1/2*beta^2*r + beta*q"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positive_radius_condition_with_q = (\n",
    "    (\n",
    "        (0 > - u.twist(beta).ch[2])\n",
    "        + d # rearrange for d\n",
    "    )\n",
    "    .subs(solve(q == u.twist(beta).ch[1], c)[0]) # express c in term of q\n",
    "    .expand()\n",
    ")\n",
    "positive_radius_condition_with_q"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "392671ee",
   "metadata": {},
   "source": [
    "Separate out the terms of the corresponding lower bound on $d$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "78a1301a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\left(\\frac{1}{2} \\, \\beta^{2} r, \\beta q, 0\\right)\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\left(\\frac{1}{2} \\, \\beta^{2} r, \\beta q, 0\\right)$"
      ],
      "text/plain": [
       "(1/2*beta^2*r, beta*q, 0)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positive_radius_lowerbound_terms = Object()\n",
    "\n",
    "positive_radius_lowerbound_terms.const = positive_radius_condition_with_q.rhs().subs(r==0)\n",
    "\n",
    "positive_radius_lowerbound_terms.linear = (\n",
    "    positive_radius_condition_with_q.rhs()\n",
    "    - positive_radius_lowerbound_terms.const\n",
    ")\n",
    "\n",
    "positive_radius_lowerbound_terms.hyperbolic = 0\n",
    "\n",
    "(positive_radius_lowerbound_terms.linear,\n",
    " positive_radius_lowerbound_terms.const,\n",
    " positive_radius_lowerbound_terms.hyperbolic)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "900f332b",
   "metadata": {},
   "source": [
    "## $\\Delta(u) \\geq 0$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "62529298",
   "metadata": {},
   "source": [
    "Express this inequality in terms of $q$"
   ]
  },
   "execution_count": 9,
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 0 \\leq {\\left(\\beta r + q\\right)}^{2} - 2 \\, d r\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 0 \\leq {\\left(\\beta r + q\\right)}^{2} - 2 \\, d r$"
      ],
      "text/plain": [
       "0 <= (beta*r + q)^2 - 2*d*r"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
    "bgmlv2_with_q = ((0 <= Δ(u))\n",
    "    .subs(c_in_terms_of_q))\n",
    "bgmlv2_with_q"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "723511fa",
   "metadata": {},
   "source": [
    "Rearrange expression for $d$"
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle d \\leq \\frac{{\\left(\\beta r + q\\right)}^{2}}{2 \\, r}\\)</html>"
       "$\\displaystyle d \\leq \\frac{{\\left(\\beta r + q\\right)}^{2}}{2 \\, r}$"
       "d <= 1/2*(beta*r + q)^2/r"
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_ineq = (bgmlv2_with_q\n",
    "    + 2*d*r # move d to rhs\n",
    ") / (2*r) # scale-out d coefficient (r>0)\n",
    "\n",
    "assert bgmlv2_d_ineq.lhs() == d, \"Should be ineq for d\"\n",
    "\n",
  {
   "cell_type": "markdown",
   "id": "425bcb7c",
   "metadata": {},
   "source": [
    "Keep hold of the upper bound for $d$:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "6ae4f2e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r + \\beta q + \\frac{q^{2}}{2 \\, r}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r + \\beta q + \\frac{q^{2}}{2 \\, r}$"
      ],
      "text/plain": [
       "1/2*beta^2*r + beta*q + 1/2*q^2/r"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound = bgmlv2_d_ineq.rhs().expand()\n",
    "bgmlv2_d_upperbound"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "988aaf5b",
   "metadata": {},
   "source": [
    "Separate out the terms of this lower bound for d"
   ]
  },
   "execution_count": 12,
   "id": "653a3340",
   "metadata": {},
   "outputs": [],
   "source": [
    "bgmlv2_d_upperbound_terms = Object()\n",
    "\n",
    "bgmlv2_d_upperbound_without_hyp = (\n",
    "    bgmlv2_d_upperbound\n",
    "    .subs(1/r == 0)\n",
    ")\n",
    "\n",
    "bgmlv2_d_upperbound_terms.const = (\n",
    "    bgmlv2_d_upperbound_without_hyp\n",
    "    .subs(r==0)\n",
    ")\n",
    "\n",
    "bgmlv2_d_upperbound_terms.linear = (\n",
    "    bgmlv2_d_upperbound_without_hyp\n",
    "    - bgmlv2_d_upperbound_terms.const\n",
    "bgmlv2_d_upperbound_terms.hyperbolic = (\n",
    "    bgmlv2_d_upperbound\n",
    "    - bgmlv2_d_upperbound_without_hyp\n",
    ").expand()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "326bb656",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\left(\\frac{1}{2} \\, \\beta^{2} r, \\beta q, \\frac{q^{2}}{2 \\, r}\\right)\\)</html>"
       "$\\displaystyle \\left(\\frac{1}{2} \\, \\beta^{2} r, \\beta q, \\frac{q^{2}}{2 \\, r}\\right)$"
       "(1/2*beta^2*r, beta*q, 1/2*q^2/r)"
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(bgmlv2_d_upperbound_terms.linear,\n",
    " bgmlv2_d_upperbound_terms.const,\n",
    " bgmlv2_d_upperbound_terms.hyperbolic)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cc08c62",
   "metadata": {},
   "source": [
    "Sanity check:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7ff937ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "assert ( bgmlv2_d_upperbound\n",
    "- bgmlv2_d_upperbound_terms.const\n",
    "- bgmlv2_d_upperbound_terms.linear\n",
    "- bgmlv2_d_upperbound_terms.hyperbolic) == 0, \"Error in terms separation\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "024e8c41",
   "metadata": {},
   "source": [
    "## $\\Delta(v-u) \\geq 0$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2647f43",
   "metadata": {},
   "source": [
    "Express this inequality in terms of $q$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "87544e6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 0 \\leq {\\left(\\beta r - C + q\\right)}^{2} - 2 \\, {\\left(D - d\\right)} {\\left(R - r\\right)}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 0 \\leq {\\left(\\beta r - C + q\\right)}^{2} - 2 \\, {\\left(D - d\\right)} {\\left(R - r\\right)}$"
      ],
      "text/plain": [
       "0 <= (beta*r - C + q)^2 - 2*(D - d)*(R - r)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_with_q = ((0 <= Δ(v-u))\n",
    "    .subs(c_in_terms_of_q)\n",
    ")\n",
    "\n",
    "bgmlv3_with_q"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d36504bb",
   "metadata": {},
   "source": [
    "Rearrange in terms of $d$ assuming $r>R$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle d \\leq D - \\frac{{\\left(\\beta r - C + q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle d \\leq D - \\frac{{\\left(\\beta r - C + q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}$"
      ],
      "text/plain": [
       "d <= D - 1/2*(beta*r - C + q)^2/(R - r)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_ineq = (\n",
    "    (\n",
    "        bgmlv3_with_q\n",
    "        + 2*(D-d)*(R-r) # move d term to lhs\n",
    "    )/2/(r-R) # assume r>R\n",
    ") + D\n",
    "\n",
    "assert bgmlv3_d_ineq.lhs() == d, \"Should be bound for d\"\n",
    "assert not bgmlv3_d_ineq.rhs().has(d), \"Should be bound for d\"\n",
    "\n",
    "bgmlv3_d_ineq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\renewcommand{\\psi}{\\chern_1^{\\beta}(v)}$\n",
    "$\\renewcommand{\\phi}{\\chern_2^{\\beta}(v)}$\n",
    "Redefine psi and phi in latex to be $\\psi$ and $\\phi$"
   ]
  },
   "execution_count": 17,
   "id": "0acd0b7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\left(\\psi, \\phi\\right)\\)</html>"
       "$\\displaystyle \\left(\\psi, \\phi\\right)$"
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ch1bv, ch2bv = var(\"psi phi\", domain=\"real\") # symbol to represent ch_1^\\beta(v) and\n",
    "# ch_2^\\beta(v)\n",
    "ch1bv, ch2bv"
   "cell_type": "markdown",
   "id": "0d880757",
   "source": [
    "Define expression for the different terms of this bound of $d$ in terms of $\\phi$ and $\\psi$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "f122a6d5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r + \\beta q + \\phi - \\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}\\)</html>"
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r + \\beta q + \\phi - \\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}$"
       "1/2*beta^2*r + beta*q + phi - 1/2*(psi - q)^2/(R - r)"
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_terms = Object()\n",
    "\n",
    "bgmlv3_d_upperbound_terms.linear = bgmlv2_d_upperbound_terms.linear\n",
    "bgmlv3_d_upperbound_terms.const = ch2bv + bgmlv2_d_upperbound_terms.const\n",
    "bgmlv3_d_upperbound_terms.hyperbolic = (ch1bv - q)^2/2/(r-R)\n",
    "\n",
    "(bgmlv3_d_upperbound_terms.linear\n",
    " + bgmlv3_d_upperbound_terms.const\n",
    " + bgmlv3_d_upperbound_terms.hyperbolic)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e813c96",
   "metadata": {},
   "source": [
    "Verify that the expression above indeed is equal the upper bound on $d$ given by $\\originalDelta(v-u) \\geq 0$"
   "execution_count": 19,
   "id": "10fb65aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "assert (\n",
    "    (bgmlv3_d_upperbound_terms.linear\n",
    "     + bgmlv3_d_upperbound_terms.const\n",
    "     + bgmlv3_d_upperbound_terms.hyperbolic\n",
    "     - bgmlv3_d_ineq.rhs())\n",
    "    .subs(ch2bv == v.twist(beta).ch[2])\n",
    "    .subs(ch1bv == v.twist(beta).ch[1])\n",
    ") == 0, \"Sanity check\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a777246a",
   "metadata": {},
   "source": [
    "# Specialize to problem 2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9413516f",
   "metadata": {},
   "source": [
    "Add extra attributes to the bound objects above with a specialization to the case $\\chern_2^{\\beta}(v)=0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "dbc8e7a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "for bound_terms in [\n",
    "    positive_radius_lowerbound_terms,\n",
    "    bgmlv2_d_upperbound_terms,\n",
    "    bgmlv3_d_upperbound_terms\n",
    "]:\n",
    "    bound_terms.problem2 = Object()\n",
    "    bound_terms.problem2.const = bound_terms.const.subs(ch2bv == 0)\n",
    "    bound_terms.problem2.linear = bound_terms.linear.subs(ch2bv == 0)\n",
    "    bound_terms.problem2.hyperbolic = bound_terms.hyperbolic.subs(ch2bv == 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95c39f2b",
   "metadata": {},
   "source": [
    "View the specialized bounds:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2e9a7cdc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| 0\\)</html>"
       "$\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| 0$"
       "beta*q ' + ' 1/2*beta^2*r ' + ' 0"
     "output_type": "display_data"
    },
       "<html>\\(\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| \\frac{q^{2}}{2 \\, r}\\)</html>"
       "$\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| \\frac{q^{2}}{2 \\, r}$"
       "beta*q ' + ' 1/2*beta^2*r ' + ' 1/2*q^2/r"
     "output_type": "display_data"
    },
       "<html>\\(\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}\\)</html>"
       "$\\displaystyle \\beta q \\verb| |\\verb|+| \\frac{1}{2} \\, \\beta^{2} r \\verb| |\\verb|+| -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}$"
       "beta*q ' + ' 1/2*beta^2*r ' + ' -1/2*(psi - q)^2/(R - r)"
     "output_type": "display_data"
    "for bound_terms in [\n",
    "    positive_radius_lowerbound_terms,\n",
    "    bgmlv2_d_upperbound_terms,\n",
    "    bgmlv3_d_upperbound_terms\n",
    "]:\n",
    "    pretty_print(bound_terms.problem2.const,\n",
    "        \" + \",bound_terms.problem2.linear,\n",
    "        \" + \",bound_terms.problem2.hyperbolic)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2997ec1a",
   "metadata": {},
   "source": [
    "## Plots for all Bounds on $d$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d7235dc3",
   "metadata": {},
   "outputs": [],
   "source": [
    "v_example = Chern_Char(3,2,-2)\n",
    "q_example = 7/3\n",
    "\n",
    "def plot_d_bound(\n",
    "    v_example,\n",
    "    q_example,\n",
    "    ymax=5,\n",
    "    ymin=-2,\n",
    "    xmax=20,\n",
    "    aspect_ratio=None):\n",
    "\n",
    "    # Equations to plot imminently representing the bounds on d:\n",
    "    eq2 = (bgmlv2_d_upperbound\n",
    "        .subs(R == v_example.ch[0])\n",
    "        .subs(C == v_example.ch[1])\n",
    "        .subs(D == v_example.ch[2])\n",
    "        .subs(beta = beta_minus(v_example))\n",
    "        .subs(q == q_example)\n",
    "    )\n",
    "\n",
    "    eq3 = (bgmlv3_d_upperbound\n",
    "        .subs(R == v_example.ch[0])\n",
    "        .subs(C == v_example.ch[1])\n",
    "        .subs(D == v_example.ch[2])\n",
    "        .subs(beta = beta_minus(v_example))\n",
    "        .subs(q == q_example)\n",
    "    )\n",
    "\n",
    "    eq4 = (positive_radius_condition.rhs()\n",
    "        .subs(q == q_example)\n",
    "        .subs(beta = beta_minus(v_example))\n",
    "    )\n",
    "\n",
    "    example_bounds_on_d_plot = (\n",
    "        plot(\n",
    "            eq3,\n",
    "            (r,v_example.ch[0],xmax),\n",
    "            color='green',\n",
    "            linestyle = \"dashed\",\n",
    "            legend_label=r\"upper bound: $\\Delta(v-u) \\geq 0$\",\n",
    "        )\n",
    "        + plot(\n",
    "            eq2,\n",
    "            (r,0,xmax),\n",
    "            color='blue',\n",
    "            linestyle = \"dashed\",\n",
    "            legend_label=r\"upper bound: $\\Delta(u) \\geq 0$\"\n",
    "        )\n",
    "        + plot(\n",
    "            eq4,\n",
    "            (r,0,xmax),\n",
    "            color='orange',\n",
    "            linestyle = \"dotted\",\n",
    "            legend_label=r\"lower bound: $\\mathrm{ch}_2^{\\beta_{-}}(u)>0$\"\n",
    "        )\n",
    "    )\n",
    "    example_bounds_on_d_plot.ymin(ymin)\n",
    "    example_bounds_on_d_plot.ymax(ymax)\n",
    "    example_bounds_on_d_plot.axes_labels(['$r$', '$d$'])\n",
    "    if aspect_ratio:\n",
    "        example_bounds_on_d_plot.set_aspect_ratio(aspect_ratio)\n",
    "    return example_bounds_on_d_plot"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "683ac3f7",
   "metadata": {},
   "source": [
    "### Bounds on $d$ with Minimal $q=\\operatorname{ch}^{\\beta}_1(u)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f5b1d9bf",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'bgmlv3_d_upperbound' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[23], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m bounds_on_d_qmin \u001b[38;5;241m=\u001b[39m \u001b[43mplot_d_bound\u001b[49m\u001b[43m(\u001b[49m\u001b[43mv_example\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mInteger\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mymin\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43mRealNumber\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m0.5\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m      2\u001b[0m bounds_on_d_qmin\n",
      "Cell \u001b[0;32mIn[22], line 21\u001b[0m, in \u001b[0;36mplot_d_bound\u001b[0;34m(v_example, q_example, ymax, ymin, xmax, aspect_ratio)\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mplot_d_bound\u001b[39m(\n\u001b[1;32m      5\u001b[0m     v_example,\n\u001b[1;32m      6\u001b[0m     q_example,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     11\u001b[0m \n\u001b[1;32m     12\u001b[0m     \u001b[38;5;66;03m# Equations to plot imminently representing the bounds on d:\u001b[39;00m\n\u001b[1;32m     13\u001b[0m     eq2 \u001b[38;5;241m=\u001b[39m (bgmlv2_d_upperbound\n\u001b[1;32m     14\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(R \u001b[38;5;241m==\u001b[39m v_example\u001b[38;5;241m.\u001b[39mch[Integer(\u001b[38;5;241m0\u001b[39m)])\n\u001b[1;32m     15\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(C \u001b[38;5;241m==\u001b[39m v_example\u001b[38;5;241m.\u001b[39mch[Integer(\u001b[38;5;241m1\u001b[39m)])\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     18\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(q \u001b[38;5;241m==\u001b[39m q_example)\n\u001b[1;32m     19\u001b[0m     )\n\u001b[0;32m---> 21\u001b[0m     eq3 \u001b[38;5;241m=\u001b[39m (\u001b[43mbgmlv3_d_upperbound\u001b[49m\n\u001b[1;32m     22\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(R \u001b[38;5;241m==\u001b[39m v_example\u001b[38;5;241m.\u001b[39mch[Integer(\u001b[38;5;241m0\u001b[39m)])\n\u001b[1;32m     23\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(C \u001b[38;5;241m==\u001b[39m v_example\u001b[38;5;241m.\u001b[39mch[Integer(\u001b[38;5;241m1\u001b[39m)])\n\u001b[1;32m     24\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(D \u001b[38;5;241m==\u001b[39m v_example\u001b[38;5;241m.\u001b[39mch[Integer(\u001b[38;5;241m2\u001b[39m)])\n\u001b[1;32m     25\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(beta \u001b[38;5;241m=\u001b[39m beta_minus(v_example))\n\u001b[1;32m     26\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(q \u001b[38;5;241m==\u001b[39m q_example)\n\u001b[1;32m     27\u001b[0m     )\n\u001b[1;32m     29\u001b[0m     eq4 \u001b[38;5;241m=\u001b[39m (positive_radius_condition\u001b[38;5;241m.\u001b[39mrhs()\n\u001b[1;32m     30\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(q \u001b[38;5;241m==\u001b[39m q_example)\n\u001b[1;32m     31\u001b[0m         \u001b[38;5;241m.\u001b[39msubs(beta \u001b[38;5;241m=\u001b[39m beta_minus(v_example))\n\u001b[1;32m     32\u001b[0m     )\n\u001b[1;32m     34\u001b[0m     example_bounds_on_d_plot \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m     35\u001b[0m         plot(\n\u001b[1;32m     36\u001b[0m             eq3,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m     55\u001b[0m         )\n\u001b[1;32m     56\u001b[0m     )\n",
      "\u001b[0;31mNameError\u001b[0m: name 'bgmlv3_d_upperbound' is not defined"
     ]
    }
   ],
   "source": [
    "bounds_on_d_qmin = plot_d_bound(v_example, 0, ymin=-0.5)\n",
    "bounds_on_d_qmin"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "24dd62c1",
   "metadata": {},
   "source": [
    "### Bounds on $d$ with Maximal $q=\\operatorname{ch}^{\\beta}_1(u)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47b30d7e",
   "metadata": {},
   "source": [
    "bounds_on_d_qmax = plot_d_bound(v_example, 4, ymin=-3, ymax=3)\n",
    "bounds_on_d_qmax"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "133ccbe7",
   "metadata": {},
   "source": [
    "### Bounds on $d$ with Mid-way $q=\\operatorname{ch}^{\\beta}_1(u)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "25e4850b",
   "metadata": {},
   "source": [
    "typical_bounds_on_d = plot_d_bound(v_example, 2, ymax=4, ymin=-2, aspect_ratio=1)\n",
    "typical_bounds_on_d"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c6f5622",
   "metadata": {},
   "source": [
    "# Bounds on Semistabilizer Rank $r=\\operatorname{ch}_0(u)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "553bba31",
   "metadata": {},
   "outputs": [],
   "source": [
    "var(\"a_v b_q n\") # Define symbols introduce for values of beta and q\n",
    "beta_value_expr = (beta == a_v/n)\n",
    "q_value_expr = (q == b_q/n)\n",
    "# RENDERED TO LATEX: positive_radius_condition.subs([q_value_expr,beta_value_expr]).factor()\n",
    "# placeholder for the specific values of k (start with 1):\n",
    "var(\"kappa\", domain=\"real\")\n",
    "\n",
    "assymptote_gap_condition1 = (kappa/(2*n^2) < bgmlv2_d_upperbound_exp_term)\n",
    "assymptote_gap_condition2 = (kappa/(2*n^2) < bgmlv3_d_upperbound_exp_term_alt2)\n",
    "\n",
    "r_upper_bound1 = (\n",
    "    assymptote_gap_condition1\n",
    "    * r * 2*n^2 / kappa\n",
    ")\n",
    "\n",
    "assert r_upper_bound1.lhs() == r\n",
    "\n",
    "r_upper_bound2 = (\n",