@@ -105,20 +84,17 @@
{{ KNOWL('belyi.galmap', 'Map') }}
{% else %}
Curve
- \(\displaystyle {{data.curve}}\)
- {% if data.g == 0 %}
+ {{data.curve|safe}}
+ {%- if data.g == 0 -%}
, with affine coordinate $x$
{% endif %}
- {% if data["curve_label"] %}
- , isomorphic to curve with label {{data["curve_label"]}}
- {% endif %}
{{ KNOWL('belyi.galmap', 'Map') }}
{% if data.g == 0 %}
-
\(\displaystyle \phi(x) = {{data.map}}\)
+
\(\displaystyle \phi(x) =\) {{data.map|safe}}
{% else %}
-
\(\displaystyle \phi(x,y) = {{data.map}}\)
+
\(\displaystyle \phi(x,y) =\) {{data.map|safe}}
{% endif %}
{% endif %}
diff --git a/lmfdb/belyi/test_belyi.py b/lmfdb/belyi/test_belyi.py
index 6d9139c5c2..9341fe423c 100644
--- a/lmfdb/belyi/test_belyi.py
+++ b/lmfdb/belyi/test_belyi.py
@@ -20,10 +20,11 @@ def test_passport(self):
self.check_args("/Belyi/9T33-5.2.2_5.3.1_2.2.2.2.1-a", "3.1.14175.1")
def test_smooth_equation(self):
- self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"\phi(x) = 9075734485907514624 \frac{x^{9}}{4537867242953757312 x^{9} - 10520021716426424475 x^{8} + 12447550725170242500 x^{6} - 9941569340991356250 x^{4} + 4201111257707812500 x^{2} - 724916949326171875}\)")
+ self.check_args("/Belyi/7T5-7_7_3.3.1-a", r"\frac{50000 x^{5} + 60000 x^{4} + \left(7000 \nu + 5000\right) x^{3} + 50000 x^{2} y + \left(7000 \nu - 11400\right) x^{2} + 40000 x y + \left(455 \nu - 1725\right) x + \left(500 \nu + 2500\right) y - 532 \nu + 284}{50000 x^{5} + 60000 x^{4} + \left(7000 \nu + 5000\right) x^{3} + \left(7000 \nu - 11400\right) x^{2} + \left(455 \nu - 1725\right) x - 532 \nu + 284}")
+ self.check_args("/Belyi/7T5-7_7_3.3.1-a", r"y^{2} = x^{6} + \frac{4}{5} x^{5} + \left(\frac{13}{50} \nu - \frac{19}{50}\right) x^{4} + \left(\frac{21}{125} \nu - \frac{7}{25}\right) x^{3} + \left(-\frac{709}{10000} \nu + \frac{279}{10000}\right) x^{2} + \left(-\frac{153}{6250} \nu + \frac{67}{6250}\right) x + \frac{83}{15625} \nu + \frac{47}{15625}")
def test_plane_equation(self):
- self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"x^{9} t + \left(-126 x^{4} + 420 x^{3} - 540 x^{2} + 315 x - 70\right) = 0")
+ self.check_args("/Belyi/9T33-9_5.1.1.1.1_5.1.1.1.1-a", r"x^{9} t + \left(-126 x^{4} + 420 x^{3} - 540 x^{2} + 315 x - 70")
# web pages
diff --git a/lmfdb/belyi/web_belyi.py b/lmfdb/belyi/web_belyi.py
index a163d42a2c..7226b35d62 100644
--- a/lmfdb/belyi/web_belyi.py
+++ b/lmfdb/belyi/web_belyi.py
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
-from lmfdb.utils import web_latex
from lmfdb.number_fields.web_number_field import WebNumberField
from lmfdb.galois_groups.transitive_group import transitive_group_display_knowl
-from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing, NumberField, factor
-from lmfdb.utils import names_and_urls, prop_int_pretty
+from sage.all import gcd, latex, CC, QQ, FractionField, PolynomialRing
+from lmfdb.utils import (names_and_urls, prop_int_pretty, raw_typeset,
+ web_latex, compress_expression)
from flask import url_for
+import re
from lmfdb import db
@@ -111,37 +112,46 @@ def make_map_latex(map_str, nu=None):
phi_str = lc_str + "\\frac{%s}{%s}" % (num_str, den_str)
return phi_str
-def make_plane_model_latex(crv_str, nu=None):
- if "nu" not in crv_str:
- R0 = QQ
- else:
- R0 = PolynomialRing(QQ, "nu")
- R = PolynomialRing(R0, 2, "t,x")
- f = R(crv_str)
- #return teXify_pol(f)
- return latex(f)+"=0"
-
-def make_plane_model_latex_factored(crv_str, numfld_cs, nu=None):
- R0 = PolynomialRing(QQ,"T")
- K = NumberField(R0(numfld_cs), "nu") # sage factors out constants, ruining integrality
- S0 = PolynomialRing(K,"x")
- S = PolynomialRing(S0,"t")
- t = S.gens()[0]
- f = S(crv_str)
- cs = f.coefficients()
- cs.reverse()
- mons = f.monomials()
- L = len(cs)
- f_str = ""
- for i in range(0,L-1):
- f_str += "%s%s" % (latex(factor(cs[i])), latex(t**(L-i-1)))
- if i != L-2:
- f_str += "+"
- if mons[-1] == 1:
- f_str += latex(factor(cs[-1]))
- else:
- f_str += latex(factor(cs[-1])) + latex(mons[-1])
- return f_str
+#def make_plane_model_latex(crv_str, nu=None):
+# if "nu" not in crv_str:
+# R0 = QQ
+# else:
+# R0 = PolynomialRing(QQ, "nu")
+# R = PolynomialRing(R0, 2, "t,x")
+# f = R(crv_str)
+# #return teXify_pol(f)
+# return latex(f)+"=0"
+#
+#def make_plane_model_latex_factored(crv_str, numfld_cs, nu=None):
+# R0 = PolynomialRing(QQ,"T")
+# K = NumberField(R0(numfld_cs), "nu") # sage factors out constants, ruining integrality
+# S0 = PolynomialRing(K,"x")
+# S = PolynomialRing(S0,"t")
+# t = S.gens()[0]
+# f = S(crv_str)
+# cs = f.coefficients()
+# cs.reverse()
+# mons = f.monomials()
+# L = len(cs)
+# f_str = ""
+# for i in range(0,L-1):
+# f_str += "%s%s" % (latex(factor(cs[i])), latex(t**(L-i-1)))
+# if i != L-2:
+# f_str += "+"
+# if mons[-1] == 1:
+# f_str += latex(factor(cs[-1]))
+# else:
+# f_str += latex(factor(cs[-1])) + latex(mons[-1])
+# return f_str
+
+def belyi_latex(s):
+ str = s.replace('*',' ')
+ str = str.replace('(',r'\left(')
+ str = str.replace(')',r'\right)')
+ str = str.replace('nu',r'\nu')
+ # multidigit exponents
+ str = re.sub(r'\^\s*(\d+)', r'^{\1}',str)
+ return str
###############################################################################
# Belyi map class definitions
@@ -253,17 +263,43 @@ def __init__(self, galmap, triple=None):
my_dict['embedding'] = embed_strs[i]
data['embeddings_and_triples'].append(my_dict)
+ # Friends
+ self.friends = [("Passport", url_for_belyi_passport_label(galmap["plabel"]))]
+ if galmap['label'] != galmap['primitivization']:
+ self.friends.append(("Primitivization", url_for_belyi_galmap_label(galmap["primitivization"])))
+ self.friends.extend(names_and_urls(galmap['friends']))
+
+ curve_ref = ''
+ # add curve link, if in LMFDB
+ if 'curve_label' in galmap.keys():
+ data['curve_label'] = galmap['curve_label']
+ for name, url in self.friends:
+ if "curve" in name.lower() and data['curve_label'] in name:
+ data["curve_url"] = url
+
+ # curve reference
+ curve_ref = ', isomorphic to '
+ if galmap['g'] == 1:
+ curve_ref += 'elliptic'
+ if galmap['g'] == 2:
+ curve_ref += 'genus 2'
+ curve_ref += rf' curve with label
{data["curve_label"]}'
+
+
+
+ # curve equations
crv_str = galmap["curve"]
if crv_str == "PP1":
- data["curve"] = r"\mathbb{P}^1"
+ data["curve"] = r"$\mathbb{P}^1$"
else:
- data["curve"] = make_curve_latex(crv_str, nu=self.embedding)
+ data["curve"] = raw_typeset(crv_str, r'$\displaystyle '+compress_expression(make_curve_latex(crv_str, nu=self.embedding))+'$', extra=curve_ref)
- data["map"] = make_map_latex(galmap["map"], nu=self.embedding)
+ data["map"] = raw_typeset(galmap["map"], r'$\displaystyle '+compress_expression(make_map_latex(galmap["map"], nu=self.embedding))+'$')
data["lambdas"] = [str(c)[1:-1] for c in galmap["lambdas"]]
# plane model
if galmap.get("plane_model"):
- data["plane_model"] = galmap["plane_model_latex"]
+ data["plane_model"] = raw_typeset(compress_expression(galmap["plane_model"])+'=0', r'$\displaystyle '+belyi_latex(galmap["plane_model"])+'=0$', extra=curve_ref)
+
if galmap.get('plane_map_constant_factored'):
data['plane_map_constant_factored'] = galmap['plane_map_constant_factored']
@@ -284,19 +320,6 @@ def __init__(self, galmap, triple=None):
]
self.properties = properties
- # Friends
- self.friends = [("Passport", url_for_belyi_passport_label(galmap["plabel"]))]
- if galmap['label'] != galmap['primitivization']:
- self.friends.append(("Primitivization", url_for_belyi_galmap_label(galmap["primitivization"])))
- self.friends.extend(names_and_urls(galmap['friends']))
-
- # add curve link, if in LMFDB
- if 'curve_label' in galmap.keys():
- data['curve_label'] = galmap['curve_label']
- for name, url in self.friends:
- if "curve" in name.lower() and data['curve_label'] in name:
- data["curve_url"] = url
-
# Downloads
data_label = data["label"]
if galmap["g"] <= 2:
diff --git a/lmfdb/templates/base.html b/lmfdb/templates/base.html
index 6973c6a95f..50ef461adf 100644
--- a/lmfdb/templates/base.html
+++ b/lmfdb/templates/base.html
@@ -62,6 +62,7 @@
{left: "$", right: "$", display: false},
{left: "\\(", right: "\\)", display: false}
],
+ maxExpand: Infinity,
macros: {
"\\C": '{\\mathbb{C}}',
"\\R": '{\\mathbb{R}}',
diff --git a/lmfdb/utils/__init__.py b/lmfdb/utils/__init__.py
index 856a62c7fb..9cd5eba053 100644
--- a/lmfdb/utils/__init__.py
+++ b/lmfdb/utils/__init__.py
@@ -49,6 +49,7 @@
'raw_typeset', 'raw_typeset_poly', 'raw_typeset_poly_factor',
'raw_typeset_qexp', 'raw_typeset_int', 'compress_poly_Q',
'input_string_to_poly', 'dispZmat', 'dispcyclomat',
+ 'compress_expression',
'pos_int_and_factor', 'compress_polynomial']
from flask import (request, make_response, flash, url_for,
@@ -115,6 +116,7 @@
raw_typeset_poly,
compress_poly_Q,
compress_polynomial,
+ compress_expression,
pos_int_and_factor,
raw_typeset_poly_factor,
raw_typeset_qexp,
diff --git a/lmfdb/utils/web_display.py b/lmfdb/utils/web_display.py
index 92f60185da..1582c13bac 100644
--- a/lmfdb/utils/web_display.py
+++ b/lmfdb/utils/web_display.py
@@ -115,12 +115,19 @@ def web_latex(x, enclose=True):
def compress_int(n, cutoff=15, sides=2):
res = str(n)
- if abs(n) >= 10**cutoff:
- short = res[:sides + (1 if n < 0 else 0)] + r'\!\cdots\!' + res[-sides:]
+ minus_width = 1 if '-' in res else 0
+ if len(res) > cutoff+minus_width:
+ short = res[:sides + minus_width] + r'\!\cdots\!' + res[-sides:]
return short, True
else:
return res, False
+def compress_expression(expression, cutoff=15, sides=2):
+ r"""
+ Takes a string and any numbers (consecutive digits) longer than
+ cutoff gets replaced
+ """
+ return re.sub(r'\d+', lambda a: compress_int(str(a.group()),cutoff, sides)[0], expression)
def bigint_knowl(n, cutoff=20, max_width=70, sides=2):
short, shortened = compress_int(n, cutoff=cutoff, sides=sides)