Ask Your Question
1

How to use lift_x in python?

asked 2023-09-20 23:20:01 +0100

podprostor gravatar image

updated 2023-09-21 16:35:10 +0100

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 flag offensive close merge delete

Comments

2

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

John Palmieri gravatar imageJohn Palmieri ( 2023-09-21 03:34:44 +0100 )edit

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

podprostor gravatar imagepodprostor ( 2023-09-21 16:22:35 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2023-10-07 00:12:38 +0100

dan_fulea gravatar image

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]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from sage.all import *

In [2]: E = EllipticCurve('37a')

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

In [4]: 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 [6]: E.lift_x( QQ(1) )
Out[6]: (1 : -1 : 1)

In [7]: E.lift_x( QQ(1), all=True )
Out[7]: [(1 : -1 : 1), (1 : 0 : 1)]
edit flag offensive delete link more
1

answered 2023-09-21 16:34:54 +0100

podprostor gravatar image

updated 2023-09-21 16:42:29 +0100

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)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2023-09-20 23:20:01 +0100

Seen: 453 times

Last updated: Oct 07 '23