Skip to content
Snippets Groups Projects
Commit 272f39df authored by Luke Naylor's avatar Luke Naylor
Browse files

Refactor sagesilent content into separate notebook

Squashed commit of the following:

commit 1646c309
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Thu Jul 27 15:27:24 2023 +0100

    Adjust formatting in secondary notebooks

commit 3381ee2d
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Thu Jul 27 15:19:26 2023 +0100

    Adjust titling and formatting in main notebook

commit 2fb2e99f
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Thu Jul 27 13:47:24 2023 +0100

    Change tabs to spaces in notebooks

commit e9dc188d
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 17:11:01 2023 +0100

    Import charact curves plot from new notebook and remove redundant from old

commit ef7d3ae4
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 17:04:51 2023 +0100

    Copy characteristic curves plots to new notebook and integrate into build'

commit 98a0dd21
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 16:57:56 2023 +0100

    Remove redundant example code in main notebook

commit 99976ab1
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 16:52:53 2023 +0100

    Import examples from new notebook instead

commit eac837dd
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 16:47:53 2023 +0100

    Copy recurring examples to separate notebook and integrate into build

commit 1abd1b8f
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 16:33:14 2023 +0100

    Small reorganisation of notebook

commit 2aff2908
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 14:57:22 2023 +0100

    Correct missing imports from previous commits'

commit 48f747d5
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Wed Jul 26 14:11:25 2023 +0100

    Import sage expressions from external script

commit ee88d79f
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 23:03:48 2023 +0100

    Refactor extravagant example into notebook

commit 96b9b38d
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 22:56:42 2023 +0100

    Refactor recurring example into notebook

commit 5be4f14f
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 21:54:24 2023 +0100

    Use imports from notebook pt4

commit 92295236
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 21:51:32 2023 +0100

    Use imports from notebook pt3

commit 1eeb885e
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 21:48:06 2023 +0100

    Use imports from notebook pt2

commit 93b6dcbf
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 21:45:43 2023 +0100

    Use imports from notebook pt1

commit efccff7f
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 17:06:28 2023 +0100

    Adjust Makefile to create correct python library

commit 75552ca3
Author: Luke Naylor <l.naylor@sms.ed.ac.uk>
Date:   Tue Jul 25 16:47:37 2023 +0100

    Add jupyter notebook with most of sagetex scripts
parent 3e2de5e9
No related branches found
No related tags found
No related merge requests found
Pipeline #28644 passed
main.* main.*
!main.tex !main.tex
plots_and_expressions.*
!plots_and_expressions.ipynb
examples.*
!examples.ipynb
characteristic_curves.*
!characteristic_curves.ipynb
filtered_sage.txt filtered_sage.txt
_minted-main/* _minted-main/*
sage-plots-for-main.tex sage-plots-for-main.tex
.vscode/* .vscode/*
sagetex.sty sagetex.sty
.ipynb_checkpoints
__pycache__
...@@ -5,17 +5,35 @@ MAINTEXFILE = main.tex ...@@ -5,17 +5,35 @@ MAINTEXFILE = main.tex
TEXFILES = ${MAINTEXFILE} TEXFILES = ${MAINTEXFILE}
SAGETEXSCRIPT = main.sagetex.sage SAGETEXSCRIPT = main.sagetex.sage
main.pdf: ${TEXFILES} main.sagetex.sout.tmp filtered_sage.txt main.pdf: ${TEXFILES} main.sagetex.sout.tmp
latexmk latexmk
main.sagetex.sout.tmp: ${SAGETEXSCRIPT} main.sagetex.sout.tmp: ${SAGETEXSCRIPT} plots_and_expressions.py examples.py characteristic_curves.py
PYTHONPATH=./sagetexscripts/ sage ${SAGETEXSCRIPT} PYTHONPATH=./sagetexscripts/ sage ${SAGETEXSCRIPT}
${SAGETEXSCRIPT}: ${TEXFILES} filtered_sage.txt ${SAGETEXSCRIPT}: ${TEXFILES}
latexmk || echo this shoud fail latexmk || echo this shoud fail
filtered_sage.txt: ${MAINTEXFILE} filter_sage.sed plots_and_expressions.py: plots_and_expressions.ipynb
./filter_sage.sed ${MAINTEXFILE} > $@ jupyter nbconvert --to script plots_and_expressions.ipynb
mv plots_and_expressions.py plots_and_expressions.sage
sed -e "/get_ipython/d" -i plots_and_expressions.sage
sage --preparse plots_and_expressions.sage
mv plots_and_expressions.sage.py plots_and_expressions.py
examples.py: plots_and_expressions.py examples.ipynb
jupyter nbconvert --to script examples.ipynb
mv examples.py examples.sage
sed -e "/get_ipython/d" -i examples.sage
sage --preparse examples.sage
mv examples.sage.py examples.py
characteristic_curves.py: characteristic_curves.ipynb
jupyter nbconvert --to script characteristic_curves.ipynb
mv characteristic_curves.py characteristic_curves.sage
sed -e "/get_ipython/d" -i characteristic_curves.sage
sage --preparse characteristic_curves.sage
mv characteristic_curves.sage.py characteristic_curves.py
.PHONY: clean nosage noappendix .PHONY: clean nosage noappendix
clean: clean:
......
This diff is collapsed.
%% Cell type:code id:abe149f0 tags:
``` sage
# Requires extra package:
#! sage -pip install "pseudowalls==0.0.3" --extra-index-url https://gitlab.com/api/v4/projects/43962374/packages/pypi/simple
%display latex
from pseudowalls import *
Δ = lambda v: v.Q_tilt()
mu = stability.Mumford().slope
ts = stability.Tilt
var("beta", domain="real")
def beta_minus(v):
beta = stability.Tilt().beta
solutions = solve(
stability.Tilt(alpha=0).degree(v)==0,
beta)
return min(map(lambda s: s.rhs(), solutions))
class Object(object):
pass
```
%% Cell type:code id:77fff07c tags:
``` sage
var("m") # Initialize symbol for variety parameter
recurring = Object()
recurring.chern = Chern_Char(3, 2, -2)
recurring.b = beta_minus(recurring.chern)
recurring.twisted = recurring.chern.twist(recurring.b)
# RENDERED TO LATEX: recurring.b
# RENDERED TO LATEX: recurring.b.denominator()
# RENDERED TO LATEX: recurring.twisted.ch[1]
n = recurring.b.denominator()
m = 2
recurring.loose_bound = (
m*n^2*recurring.twisted.ch[1]^2
) / gcd(m, 2*n^2)
# RENDERED TO LATEX: loose_bound
extravagant = Object()
extravagant.chern = Chern_Char(29, 13, -3/2)
extravagant.b = beta_minus(extravagant.chern)
extravagant.twisted = extravagant.chern.twist(extravagant.b)
extravagant.actual_rmax = 49313
# RENDERED TO LATEX: extravagant.b
# RENDERED TO LATEX: extravagant.b.denominator()
# RENDERED TO LATEX: extravagant.twisted.ch[1]
n = extravagant.b.denominator()
m = 2
extravagant.loose_bound = (
m*n^2*extravagant.twisted.ch[1]^2
) / gcd(m, 2*n^2)
```
%% Cell type:code id:9edbb954 tags:
``` sage
recurring.loose_bound
```
%% Output
$\displaystyle 144$
144
%% Cell type:code id:21b52c4d tags:
``` sage
extravagant.loose_bound
```
%% Output
$\displaystyle 215296$
215296
%% Cell type:code id:712b7324 tags:
``` sage
from plots_and_expressions import r_upper_bound_all_q, Delta, nu, n, R
```
%% Cell type:code id:ab9a828f tags:
``` sage
recurring.n = recurring.b.denominator()
recurring.bgmlv = recurring.chern.Q_tilt()
recurring.corrolary_bound = (
r_upper_bound_all_q.expand()
.subs(Delta==recurring.bgmlv)
.subs(nu==1) ## \ell^2=1 on P^2
.subs(R==recurring.chern.ch[0])
.subs(n==recurring.n)
)
```
%% Cell type:code id:2965357d tags:
``` sage
extravagant.n = extravagant.b.denominator()
extravagant.bgmlv = extravagant.chern.Q_tilt()
extravagant.corrolary_bound = (r_upper_bound_all_q
.expand()
.subs(Delta==extravagant.bgmlv)
.subs(nu==1) ## \ell^2=1 on P^2
.subs(R==extravagant.chern.ch[0])
.subs(n==extravagant.n)
)
```
%% Cell type:code id:5baed51c tags:
``` sage
float(extravagant.corrolary_bound)
```
%% Output
$\displaystyle 53838.5009765625$
53838.5009765625
%% Cell type:code id:fcc15f60 tags:
``` sage
float(recurring.corrolary_bound)
```
%% Output
$\displaystyle 37.515625$
37.515625
%% Cell type:code id:ef8f09ff tags:
``` sage
import numpy as np
def bound_comparisons(example):
n = example.b.denominator()
a_v = example.b.numerator()
def theorem_bound(v_twisted, q_val, k):
return int(min(
n^2*q_val^2/k,
v_twisted.ch[0]
+ n^2*(v_twisted.ch[1] - q_val)^2/k
))
def k(n, a_v, b_q):
n = int(n)
a_v = int(a_v)
b_q = int(b_q)
k = -a_v*b_q % n
return k if k > 0 else k + n
b_qs = list(range(example.twisted.ch[1]*n+1))
qs = list(map(lambda x: x/n,b_qs))
ks = list(map(lambda b_q: k(n, a_v, b_q), b_qs))
theorem2_bounds = [
theorem_bound(example.twisted, q_val, 1)
for q_val in qs
]
theorem3_bounds = [
theorem_bound(example.twisted, q_val, k)
for q_val, k in zip(qs,ks)
]
return qs, theorem2_bounds, theorem3_bounds
```
%% Cell type:code id:9cd102ac tags:
``` sage
np.array(bound_comparisons(recurring))
```
%% Output
$\displaystyle \begin{array}{l}
\verb|[[0|\verb| |\verb|1/3|\verb| |\verb|2/3|\verb| |\verb|1|\verb| |\verb|4/3|\verb| |\verb|5/3|\verb| |\verb|2|\verb| |\verb|7/3|\verb| |\verb|8/3|\verb| |\verb|3|\verb| |\verb|10/3|\verb| |\verb|11/3|\verb| |\verb|4]|\\
\verb| |\verb|[0|\verb| |\verb|1|\verb| |\verb|4|\verb| |\verb|9|\verb| |\verb|16|\verb| |\verb|25|\verb| |\verb|36|\verb| |\verb|28|\verb| |\verb|19|\verb| |\verb|12|\verb| |\verb|7|\verb| |\verb|4|\verb| |\verb|3]|\\
\verb| |\verb|[0|\verb| |\verb|0|\verb| |\verb|4|\verb| |\verb|3|\verb| |\verb|8|\verb| |\verb|25|\verb| |\verb|12|\verb| |\verb|15|\verb| |\verb|19|\verb| |\verb|6|\verb| |\verb|5|\verb| |\verb|4|\verb| |\verb|3]]|
\end{array}$
array([[0, 1/3, 2/3, 1, 4/3, 5/3, 2, 7/3, 8/3, 3, 10/3, 11/3, 4],
[0, 1, 4, 9, 16, 25, 36, 28, 19, 12, 7, 4, 3],
[0, 0, 4, 3, 8, 25, 12, 15, 19, 6, 5, 4, 3]], dtype=object)
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment