Skip to content
Snippets Groups Projects
plots_and_expressions.ipynb 144 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": 42,
   "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 0x7f554bd7dc90>"
      ]
     },
     "execution_count": 42,
     "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": 43,
   "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 0x7f554bd7fd00>"
      ]
     },
     "execution_count": 43,
     "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": 44,
   "id": "23d48b0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle q$"
      ],
      "text/plain": [
       "q"
      ]
     },
     "execution_count": 44,
     "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": 49,
   "id": "49be9bb7",
   "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": 51,
   "id": "4cacebc7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle c = \\beta r + q\\)</html>"
       "$\\displaystyle c = \\beta r + q$"
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c_in_terms_of_q"
   ]
  },
  {
   "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": 76,
   "id": "5991acb3",
   "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": 76,
     "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": 77,
   "id": "1f66d604",
   "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": 77,
     "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": 80,
   "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": 80,
     "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": 82,
   "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": 91,
   "id": "326bb656",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\beta q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\beta q$"
      ],
      "text/plain": [
       "beta*q"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_terms.const"
   "execution_count": 92,
   "id": "fcd9fa2a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r$"
      ],
      "text/plain": [
       "1/2*beta^2*r"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_terms.linear"
   "execution_count": 93,
   "id": "ade0f7b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{q^{2}}{2 \\, r}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{q^{2}}{2 \\, r}$"
      ],
      "text/plain": [
       "1/2*q^2/r"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_terms.hyperbolic"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cc08c62",
   "metadata": {},
   "source": [
    "Sanity check:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "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": 101,
   "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": 101,
     "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": 108,
   "id": "8986af54",
   "metadata": {},
   "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": 108,
     "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": "code",
   "execution_count": 10,
   "id": "b7799156",
   "metadata": {},
   "outputs": [],
   "source": [
    "var(\"r_alt\",domain=\"real\") # r_alt = r - R temporary substitution\n",
    "\n",
    "bgmlv3_with_q_reparam = (\n",
    "    bgmlv3_with_q\n",
    "    .subs(r == r_alt + R)\n",
    "    /r_alt # This operation assumes r_alt > 0\n",
    ").expand()\n",
    "\n",
    "bgmlv3_d_ineq = (\n",
    "    ((0 <= bgmlv3_with_q_reparam)/2 + d) # Rearrange for d\n",
    "    .subs(r_alt == r - R) # Resubstitute r back in\n",
    "    .expand()\n",
    ")\n",
    "\n",
    "# Check that this equation represents a bound for d\n",
    "assert bgmlv3_d_ineq.lhs() == d\n",
    "\n",
    "bgmlv3_d_upperbound = bgmlv3_d_ineq.rhs() # Keep hold of lower bound for d\n",
    "\n",
    "# Seperate out the terms of the lower bound for d\n",
    "\n",
    "bgmlv3_d_upperbound_without_hyp = (\n",
    "    bgmlv3_d_upperbound\n",
    "    .subs(1/(R-r) == 0)\n",
    ")\n",
    "\n",
    "bgmlv3_d_upperbound_const_term = (\n",
    "    bgmlv3_d_upperbound_without_hyp\n",
    "    .subs(r==0)\n",
    ")\n",
    "\n",
    "bgmlv3_d_upperbound_linear_term = (\n",
    "    bgmlv3_d_upperbound_without_hyp\n",
    "    - bgmlv3_d_upperbound_const_term\n",
    ").expand()\n",
    "\n",
    "bgmlv3_d_upperbound_exp_term = (\n",
    "    bgmlv3_d_upperbound\n",
    "    - bgmlv3_d_upperbound_without_hyp\n",
    ").expand()\n",
    "\n",
    "# Verify the simplified forms of the terms that will be mentioned in text\n",
    "\n",
    "var(\"psi phi\", domain=\"real\") # symbol to represent ch_1^\\beta(v) and\n",
    "# ch_2^\\beta(v)\n",
    "\n",
    "assert bgmlv3_d_upperbound_const_term == ( \n",
    "    (\n",
    "        # keep hold of this alternative expression:\n",
    "        bgmlv3_d_upperbound_const_term_alt := (\n",
    "            phi\n",
    "            + beta*q\n",
    "        )\n",
    "    )\n",
    "    .subs(phi == v.twist(beta).ch[2]) # subs real val of ch_1^\\beta(v)\n",
    "    .expand()\n",
    ")\n",
    "\n",
    "assert bgmlv3_d_upperbound_exp_term == (\n",
    "    (\n",
    "        # Keep hold of this alternative expression:\n",
    "        bgmlv3_d_upperbound_exp_term_alt :=\n",
    "        (\n",
    "            R*phi\n",
    "            + (C - q)^2/2\n",
    "            + R*beta*q\n",
    "            - D*R\n",
    "        )/(r-R)\n",
    "    )\n",
    "    .subs(phi == v.twist(beta).ch[2]) # subs real val of ch_1^\\beta(v)\n",
    "    .expand()\n",
    ")\n",
    "\n",
    "assert bgmlv3_d_upperbound_exp_term == (\n",
    "    (\n",
    "        # Keep hold of this alternative expression:\n",
    "        bgmlv3_d_upperbound_exp_term_alt2 :=\n",
    "        (\n",
    "            (psi - q)^2/2/(r-R)\n",
    "        )\n",
    "    )\n",
    "    .subs(psi == v.twist(beta).ch[1]) # subs real val of ch_1^\\beta(v)\n",
    "    .expand()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9809bd85",
   "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$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "38bbbcd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r$"
      ],
      "text/plain": [
       "1/2*beta^2*r"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_linear_term"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6701d8a7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\beta q + \\phi\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\beta q + \\phi$"
      ],
      "text/plain": [
       "beta*q + phi"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_const_term_alt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7a82d747",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}$"
      ],
      "text/plain": [
       "-1/2*(psi - q)^2/(R - r)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_exp_term_alt2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "927e6929",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r$"
      ],
      "text/plain": [
       "1/2*beta^2*r"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_linear_term"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ff25eea1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\beta q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\beta q$"
      ],
      "text/plain": [
       "beta*q"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_const_term"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "e8359c0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{q^{2}}{2 \\, r}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{q^{2}}{2 \\, r}$"
      ],
      "text/plain": [
       "1/2*q^2/r"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv2_d_upperbound_exp_term"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6823c5b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\frac{1}{2} \\, \\beta^{2} r\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\frac{1}{2} \\, \\beta^{2} r$"
      ],
      "text/plain": [
       "1/2*beta^2*r"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_linear_term"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "160871f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\beta q\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\beta q$"
      ],
      "text/plain": [
       "beta*q"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_const_term_alt.subs(phi == 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1da23b29",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle -\\frac{{\\left(\\psi - q\\right)}^{2}}{2 \\, {\\left(R - r\\right)}}$"
      ],
      "text/plain": [
       "-1/2*(psi - q)^2/(R - r)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bgmlv3_d_upperbound_exp_term_alt2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2997ec1a",
   "metadata": {},
   "source": [
    "## Plots for all Bounds on $d$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d7235dc3",
   "metadata": {},
   "outputs": [],
   "source": [
    "positive_radius_condition = (\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",
    "\n",
    "\n",
    "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": 21,