Ask Your Question
0

Problem with the lift_x fuction in SAGE

asked 2012-06-16 10:59:54 -0500

vescapam gravatar image

updated 2012-06-16 18:59:27 -0500

DSM gravatar image

Hello,

When I work with an elliptic curve and i apply E.lift_x(1407284663933896236729058440000) i obtain the point (1407284663933896236729058440000 : 4215171991512676773155222850458328 : 1) and works fine.

My problem is when i have a value of x that don't in the curve and aplly E.lift_x(x) and it's generate a Raise of Error and stop my program. Well, i have to increment the value of x end try to another point E.lift_x(x+1) and works fine but the problem is that i can't reach that because Raise of Error stop my loop.

How can i debug that? Another fuction like lift_x?

Thank very much. I wait yor answers.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2012-06-16 11:09:52 -0500

DSM gravatar image

Reading through a Python tutorial would be helpful, I think. You could catch the ValueError using a try/except pair:

p=(10^34+1000).next_prime() 
E=EllipticCurve(GF(p),[0,57])

for i in range(10):
    print i,
    try:
        print E.lift_x(i)
    except ValueError:  
        print 'is not on the curve'

gives

0 is not on the curve
1 is not on the curve
2 is not on the curve
3 is not on the curve
4 (4 : 11 : 1)
5 is not on the curve
6 is not on the curve
7 (7 : 20 : 1)
8 (8 : 4398486930972910766515963067497788 : 1)
9 (9 : 1034823061610515416790842872226417 : 1)

If you simply want a random point on the curve and you don't care about it being the 'next' one, you can use .random_element():

sage: E.random_element()
(9537865290021818371758914785117256 : 7089648854090040163853290659008613 : 1)
sage: E.random_element()
(8894960861306214748776439558874048 : 5076442993216186749708177737959875 : 1)
sage: E.random_element()
(713560432970815994889067437364213 : 4835570217047194554079202261200998 : 1)
edit flag offensive delete link more

Comments

Thank you very much. Well explained. You are a genius. :)

vescapam gravatar imagevescapam ( 2012-06-16 11:33:51 -0500 )edit
1

answered 2013-12-09 22:24:48 -0500

John Cremona gravatar image

I think I wrote this function, and exactly for the reasons you are asking I allowed for two alternataives foms of output, controlled by the parameter "all" which defaults to False. For the documentation, as usual do this: {{{ sage: E = EllipticCurve([0,0,0,0,1]) sage: E.lift_x? }}}

I would use the default in situations where you know that x is a valid x-coordinate, otherwise use all=True, for example: {{{ sage: [E.lift_x(x,all=True) for x in [-5..5]] [[], [], [], [], [(-1 : 0 : 1)], [(0 : 1 : 1), (0 : -1 : 1)], [], [(2 : 3 : 1), (2 : -3 : 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: 2012-06-16 10:59:54 -0500

Seen: 350 times

Last updated: Dec 09 '13