Ask Your Question
2

EllipticCurve.rank (mwrank) leads to segmentation fault in Sage 9.5/9.0, but to a regular exception in Sage 8.2. Is this a bug of Sage 9.5/9.0?

asked 2022-02-26 18:13:10 +0100

Daniel Lauer gravatar image

Hello, when I try to calculate the rank of elliptic curves, Sage 8.2 works well and tells me in some cases by throwing exceptions, that it could not calculate it. See code example below.

In Sage 9.5 (as well as in Sage 9.0) the same code leads to a segmentation fault. To be more precise, the 1st try of EllipticCurve.rank() leads to a "divison by zero" exception, And the 2nd try (for the same curve or for a curve that leads to the same problem) then leads to segmentation fault.

You may reproduce it on SageMathCell (http://sagecell.sagemath.org). Simply copy the code below and evaluate.

If you agree that this is a bug - what should I do to open a ticket?

Best Regards Daniel Lauer

--


print("Version of Sage: {}".format(version()))

print("\n(1) Everything okay in this simple case of calling EllipticCurve.rank():")
E = EllipticCurve([0,4321,0,1234,0])
print("E = {}".format(E))
k = E.rank(only_use_mwrank=True)
print("rank = {}\n".format(k))


print("\n(2) Still okay: Same method for different curve will lead to an exception. That's okay.")
print(" Problem B (prio 2) is: The exception is a different one, now.")
print(" In Sage 8.2, it was 'rank not provably correct (lower bound: 0)' -- and I think, this is the correct one.")
print(" In Sage 9.0 and 9.5 the exception is 'division by zero'")
E = EllipticCurve([0,20752947797,0,74237199888641440000,0])
print("E = {}".format(E))
try:
  k = E.rank(only_use_mwrank=True)
  print("rank = {}\n".format(k))
except Exception as exc:
  print("Exception: {}".format(str(exc)))

print("\n(3) So, let's do a rank computation for a different curve. This works well in all versions of Sage.")
E = EllipticCurve([0,5432,0,2345,0])
print("E = {}".format(E))
k = E.rank(only_use_mwrank=True)
print("rank = {}\n".format(k))

print("\n(4) Now problem A (prio 1) will occur: If we start a rank computation that shows the same problem as in (2), ...")
print(" ... in Sage 8.2, everything is fine: the same exception will be returned, again.")
print(" ... in Sage 9.0 and 9.5, Sage crashes with 'segmentation fault'")
E = EllipticCurve([0,20752947797,0,74237199888641440000,0])
#E = EllipticCurve([0,108066172377/1024,0,6926399795059430625/4096,0]) # the same behaviour if we choose this elliptic curve here instead of the former one
print("E = {}".format(E))
try:
  k = E.rank(only_use_mwrank=True)
  print("rank = {}\n".format(k))
except Exception as exc:
  print("Exception: {}".format(str(exc)))

print("\n(5) Further code: ...")
print(" ... in Sage 8.2, everything is fine: the code is executed.")
print(" ... in Sage 9.0 and 9.5 this code is never reached because of segmentation fault.")
edit retag flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 2022-02-27 15:43:50 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-15 16:36:52 +0100

Daniel Lauer gravatar image

updated 2022-05-15 16:38:48 +0100

The following is a partial answer.

In the meantime I could analyse the following: The root cause of the problems is the value for the precision in the mwrank library. There seems to be a default value in sage for precision (current value in Sage 9.5 seems to be 150) - and the mwrank library internally works with real numbers limited to that precision. At some point there is are divisions in mwrank by values which are - theoretically - not zero (theoretically they must be positive), but the limited precision may lead to rounding errors and therefore to negative values or even to 0. This seems to be the case here - and this explains the "RR: division by zero" exception, which seems to occur in the NTL library that is used my mwrank for dynamic floating point precision calculations.

I still do not understand why the Sage 9.0/9.5 framework handles this "division by zero" exception in a way that a 2nd call will lead to segmentation fault. And I still do not know what to do to open an appropriate ticket for Sage 9.0/9.5. This is the reason why this is only a partial answer.

Workarounds and Recommendations

(1) The user may increase the precision to avoid this kind of problems. For example add the following 2 lines at the beginning of the code:

from sage.libs.eclib.mwrank import set_precision
set_precision(200)

This is not really a good workaround - since you have only 1 chance: As soon as the "division by zero" exception occured, changing the precision does not help and does not avoid the segmentation fault when called again. So, this

(2) The mwrank library could additionally check its real variables (which theoretically show positive values) for values <= 0 - and it should give an appropriate output in this case. (Internally in C++, it may throw a C++-exception in this case at a deeper level, and on the top C++-level it should catch this exception and give the hint that the precision seems to be too small for this elliptic curve.)

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

1 follower

Stats

Asked: 2022-02-26 18:13:10 +0100

Seen: 276 times

Last updated: May 15 '22