Ask Your Question

Converting algebraic geometry Magma's code to Sage

asked 2023-10-24 18:41:19 +0100

Max Alekseyev gravatar image

This is a follow-up to where the OP requested help at MSE forum and got a solution in the form of a Magma code.

I wonder if Sage has enough functionality to get the same things done, without calling Magma. Could someone experienced in algebraic geometry please take a look at that code and convert it to Sage if possible?

edit retag flag offensive close merge delete


I think that if there was someone with such abilities that he/she would have already answered it in my original question. But I upvote your question, maybe it gets more attention.

azerbajdzan gravatar imageazerbajdzan ( 2023-10-24 21:41:24 +0100 )edit

I would not bet on that. Converting a code may just a technical thing, it's just beyond my skills in that particular area.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-10-24 22:12:25 +0100 )edit

I don't see an equivalent to CanonicalDivisor(C), but I am not an expert in algebraic geometry. Parts of Sage were written with Magma as a model (in order to provide a free replacement for Magma), so the functionality might be there. The translation of the first few lines: P2.<x,y,z> = ProjectiveSpace(QQ, 2) and f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5 and C = P2.curve(f).

John Palmieri gravatar imageJohn Palmieri ( 2023-10-28 00:10:56 +0100 )edit

See for some discussion and at least one suggestion.

John Palmieri gravatar imageJohn Palmieri ( 2023-10-28 01:03:45 +0100 )edit

@John Palmieri: The second half of the magma code does not use CanonicalDivisor but explicit rational point so no need to use CanonicalDivisor if a point is known.

azerbajdzan gravatar imageazerbajdzan ( 2023-10-28 11:05:12 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-10-30 16:49:12 +0100

Max Alekseyev gravatar image

Thanks to John Palmieri bringing this question to the attention of sage-support group, the following answer was given by Nils Bruin and Kwankyu:

P2.<x,y,z> = ProjectiveSpace(QQ, 2)
f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
C = Curve(f)
kC = C.function_field()
D = kC(kC.base_field().gen(0)).differential().divisor()
L,m,s = (-D).function_space()

#the routine below is a bit of a shortcut based on how the affine patch for kC
#is chosen. In more general code this would need to be a little more sophisticated
def liftkC(u):
    return sum([(m.numerator()(y/x))/(m.denominator()(y/x))*(z/x)^i for i,m in enumerate(u.list())])

liftedbasis = [liftkC(m(b)) for b in L.basis()]
den = lcm([b.denominator() for b in liftedbasis])
liftedbasis = [parent(x)(b*den) for b in liftedbasis]
phi = C.hom(liftedbasis, P2)

As pointed out by Kwankyu, when the issue # 36592 is fixed, the code can be simplified to:

P2.<x,y,z> = ProjectiveSpace(QQ, 2)
f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
C = Curve(f)
kC = C.function_field()
K = kC.gen().differential().divisor()  # canonical divisor
basis = (-K).basis_function_space()
Basis = [C._pull_from_function_field(f) for f in basis]
phi = C.hom(Basis, P2)
phi.image()  # conic
edit flag offensive delete link more


I hoped for a more simple an easier to read code, but probably it is not that simple. And yes, it partly answers the question. There is still method that uses ordinary point that was in magma code. I do not see how to adapt this sage code of the canonical divisor method to ordinary point divisor method.

azerbajdzan gravatar imageazerbajdzan ( 2023-10-30 18:18:10 +0100 )edit

You may like to ask for further code extension at that thread in the sage-support group.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-10-30 19:20:26 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-10-24 18:41:19 +0100

Seen: 106 times

Last updated: Oct 30 '23