I'm (somewhat) aware of bugs which come from poor treatment of weighted polynomial rings. In my mind this has two solutions.
1) Someone who is an expert in toric varieties has another look through the current code, adds more extensive testing and methods for computations in the area 2) We work with what we currently have for the hyperelliptic curve case and when something appears to be broken we attempt to fix it. I am in no position to do 1) as I do not know enough. As a result I will start one 2) but I am happy for more work to be done in parallel? My current experimentation I believe we want to define the curve in the following way ``` sage: def projective_model(f, h, g): ....: """ ....: Compute the weighted projective model (1 : g + 1 : 1) ....: """ ....: k = f.base_ring() ....: T = toric_varieties.WP([1, g + 1, 1], base_ring=k, names="X, Y, Z") ....: (X, Y, Z) = T.gens() ....: ....: if h.is_zero(): ....: d = f.degree() ....: F = sum(f[i] * X**i * Z**(d - i) for i in range(d + 1)) ....: G = Y**2 - F ....: else: ....: d = max(h.degree(), (f.degree() / 2).ceil()) ....: H = sum(h[i] * X**i * Z**(d - i) for i in range(d + 1)) ....: F = sum(f[i] * X**i * Z**(2*d - i) for i in range(2*d + 1)) ....: G = Y**2 + H*Y - F ....: ....: return T.subscheme([G]) ....: sage: f = x^7 + 1 sage: h = x sage: g = HyperellipticCurve(f, h).genus() # simply make sure this is a "good" choice of f, h for this field sage: g 3 sage: projective_model(f, h, g) Closed subscheme of 2-d toric variety covered by 3 affine patches defined by: -X^7*Z - Z^8 + X*Y*Z^3 + Y^2 ``` Which suggests to me that the generic class for hyperelliptic curves is a child class HyperellipticCurve_generic(AlgebraicScheme_subscheme_toric) and we start building this from here. On Monday, March 11, 2024 at 11:17:02 PM UTC Dima Pasechnik wrote: > Sage's treatment of weighted polynomial rings is buggy, cf. e.g. > https://github.com/sagemath/sage/issues/37167 > > this is something that should be addressed, one way or another > > > > On Mon, Mar 11, 2024 at 9:31 PM Giacomo Pope <giaco...@gmail.com> wrote: > >> Dear all, >> >> *Summary* >> >> To better support arithmetic on Jacobians and have a more natural >> implementation of hyperelliptic curves, we should implement them as toric >> varieties with a weighted polynomial ring (1 : 3 : 1) instead of plane >> projective curves. >> >> *Yes / No* >> >> *Discussion* >> >> I am currently hoping to improve hyperelliptic curves and Jacobians of >> hyperelliptic curve in Sage. One big motivation for me is to try and get >> our computations with similar coverage to what exists in Magma to allow >> more academics in the field to benefit from the open-source community of >> Sage. The first main goal of this is for full featured arithmetic on the >> Jacobians of hyperelliptic curves. >> >> The big blocker for me currently is that currently Sage implements >> hyperelliptic curves in the plane projective model. This is not an issue >> for the current methods, and it also allows for sensible arithmetic on >> Jacobians when there is one point at infinity. However, the more natural >> model I believe is the smooth model which uses a weighted polynomial >> (weights of (1 : 3 : 1)). For example, this would allow us to have a >> natural way of performing arithmetic on the real model of hyperelliptic >> curves. Something important for my own research. >> >> I believe in terms of Sage code this means changing the hyperelliptic >> curves to be toric varieties rather than projective varieties and will >> ultimately lead to a lot of work in rewriting the classes. >> >> This is not unexpected though. For example the docstring of the >> `points()` method discusses the possibility of this change in the future: >> https://github.com/sagemath/sage/blob/e417e2205be84d6d567b8897527fa6945ad09bdb/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py#L805-L858 >> >> This is associated with the sage-devel thread: >> https://groups.google.com/g/sage-devel/c/eKY85KwFldE which discusses >> progress on implementing arithmetic for Jacobians of hyperelliptic curves >> where there are 2, 1 (all cases) or 0 (only even genus) points at infinity. >> The work being done there uses a weighted polynomial ring to compute on the >> smooth model of hyperelliptic curves. >> >> *A note on inheritance* >> >> There is currently another hiccup in this transition. The class >> EllipticCurve_finite_field is a child of HyperellipticCurve_finite_field >> which >> seems to have happened at some point in the past when computing lists of >> points on the curve. As far as I can tell, this inheritance has no other >> used functionality. (Please correct me if I am missing something). I have >> shown in https://github.com/sagemath/sage/pull/37595 that this inherited >> method is always slower than using the group structure on the elliptic >> curve, so this inheritance can be removed once PR 37595 has been merged. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sage-devel" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sage-devel+...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sage-devel/dc78d787-5e82-4fdb-92cd-f299b71972c5n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sage-devel/dc78d787-5e82-4fdb-92cd-f299b71972c5n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/e108e9b8-29c5-4121-b3e9-7971ee71abdbn%40googlegroups.com.