Ask Your Question
1

Problem with the lift_x fuction in SAGE

asked 2012-06-16 17:59:54 +0100

vescapam gravatar image

updated 2012-06-17 01:59:27 +0100

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
2

answered 2012-06-16 18:09:52 +0100

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 18:33:51 +0100 )edit
1

answered 2013-12-10 05:24:48 +0100

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 17:59:54 +0100

Seen: 1,705 times

Last updated: Dec 10 '13