# How to use lift_x in python?

I am trying to use sage library in python3, but I have the following problem when I try to find points with given x-coordinate:

>>> from sage.all import *
>>> E = EllipticCurve('37a'); E
Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
>>> E.lift_x(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/sage/schemes/elliptic_curves/ell_generic.py", line 847, in lift_x
L = x.parent()
^^^^^^^^
AttributeError: 'int' object has no attribute 'parent'

edit retag close merge delete

2

Try E.lift_x(Integer(1)). The Sage type Integer is more fully-functioned than the Python type int.

Thank you. I know that Sage uses Integers, but I thought it must be something else.

Sort by » oldest newest most voted

This is the same answer, with one more touch about how to work around in the given and in similar situations. I am using the interpreter, and for some comfort let it be the ipython code eating machine.

[dan@k9 ~]\$ ipython
Python 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801]
IPython 8.16.0 -- An enhanced Interactive Python. Type '?' for help.

In : from sage.all import *

In : E = EllipticCurve('37a')

In : E
Out: Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field

In : E.lift_x?


The last question mark asks for the doc string of the method. And here it comes:

Signature: E.lift_x(x, all=False, extend=False)
Docstring:
Return one or all points with given x-coordinate.

This method is deterministic: It returns the same data each
time when called again with the same x.

INPUT:

- x -- an element of the base ring of the curve, or of an extension.

- all (bool, default False) -- if True, return a (possibly
empty) list of all points; if False, return just one point,
or raise a ValueError if there are none.

- extend (bool, default False) --

- if False, extend the base if necessary and possible to
include x, and only return point(s) defined over this
ring, or raise an error when there are none with this
x-coordinate;

- If True, the base ring will be extended if necessary
to contain the y-coordinates of the point(s) with this
x-coordinate, in addition to a possible base change to
include x.

OUTPUT:


... and so on. For us, the parameter x is the interesting one. And it must be an element of the base ring of the curve, of of an extension of the curve. So if we want to lift the integer one, we make an element of the base field of the curve from it.

In : E.lift_x( QQ(1) )
Out: (1 : -1 : 1)

In : E.lift_x( QQ(1), all=True )
Out: [(1 : -1 : 1), (1 : 0 : 1)]

more

Solutions:

1. As John Plameri pointed out, you can to use Integer(1) instead of 1.
2. I could also have done something like: E.lift_x(E.base_field()(1)) or E.lift_x(QQ(1))
>>> from sage.all import EllipticCurve, QQ, Integer
>>> E = EllipticCurve('37a'); E
Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
>>> E.lift_x(Integer(1))
(1 : 0 : 1)
>>> E.lift_x(E.base_field()(1))
(1 : 0 : 1)
>>> E.lift_x(QQ(1))
(1 : 0 : 1)

more