#21092: Unhandled case in EllipticCurve_from_cubic
----------------------------+-------------------------------
Reporter: jdemeyer | Type: defect
Status: new | Priority: major
Milestone: sage-7.3 | Component: elliptic curves
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
----------------------------+-------------------------------
I ran into an unexpected error in `EllipticCurve_from_cubic`, with the
following cubic and rational point:
{{{
sage: R.<x,y,z> = QQ[]
sage: cubic = -3*x^2*y + 3*x*y^2 + 4*x^2*z + 4*y^2*z - 3*x*z^2 + 3*y*z^2 -
8*z^3
sage: EllipticCurve_from_cubic(cubic, (-4/5, 4/5, 3/5))
}}}
Note that it works as expected using instead the different rational point
(1, 1, 0).
On investigation, I found there is a case that isn’t handled correctly.
The code computes
{{{
P2 = chord_and_tangent(F, P)
}}}
and if P2 is projectively equivalent to P then it uses a different
algorithm. If they’re different, it then computes
{{{
P3 = chord_and_tangent(F, P2)
}}}
and uses an algorithm that fails if P3 is equivalent to P2.
I think the attached patch fixes this problem. At least, with this patch
it now works for my examples.
Best wishes,
Robin
----------
{{{
#!diff
diff --git a/src/sage/schemes/elliptic_curves/constructor.py
b/src/sage/schemes/elliptic_curves/constructor.py
index ec2d59c..d28dda3 100644
--- a/src/sage/schemes/elliptic_curves/constructor.py
+++ b/src/sage/schemes/elliptic_curves/constructor.py
@@ -873,6 +873,16 @@ def EllipticCurve_from_cubic(F, P, morphism=True):
sage: cubic = x^2*y + 4*x*y^2 + x^2*z + 8*x*y*z + 4*y^2*z +
9*x*z^2 + 9*y*z^2
sage: EllipticCurve_from_cubic(cubic, [1,-1,1], morphism=False)
Elliptic Curve defined by y^2 - 882*x*y - 2560000*y = x^3 -
127281*x^2 over Rational Field
+
+ sage: R.<x,y,z> = QQ[]
+ sage: cubic = -3*x^2*y + 3*x*y^2 + 4*x^2*z + 4*y^2*z - 3*x*z^2 +
3*y*z^2 - 8*z^3
+ sage: EllipticCurve_from_cubic(cubic, (-4/5, 4/5, 3/5) )
+ Scheme morphism:
+ From: Closed subscheme of Projective Space of dimension 2 over
Rational Field defined by:
+ -3*x^2*y + 3*x*y^2 + 4*x^2*z + 4*y^2*z - 3*x*z^2 + 3*y*z^2 -
8*z^3
+ To: Elliptic Curve defined by y^2 + 10*x*y + 112*y = x^3 +
46*x^2 + 336*x over Rational Field
+ Defn: Defined on coordinates by sending (x : y : z) to
+ (1/3*z : y - 1/3*z : 1/112*x - 1/112*y - 1/42*z)
"""
import sage.matrix.all as matrix
@@ -895,9 +905,18 @@ def EllipticCurve_from_cubic(F, P, morphism=True):
raise TypeError('%s is not a projective point'%P)
x, y, z = R.gens()
- # First case: if P = P2 then P is a flex
+ # First case: if P = P2 then P is a flex, or if P2 = P3 then P2 is a
flex
P2 = chord_and_tangent(F, P)
+ flex_point = None
if are_projectively_equivalent(P, P2, base_ring=K):
+ flex_point = P
+ else:
+ P3 = chord_and_tangent(F, P2)
+ if are_projectively_equivalent(P2, P3, base_ring=K):
+ flex_point = P2
+
+ if flex_point is not None:
+ P = flex_point
# find the tangent to F in P
dx = K(F.derivative(x)(P))
dy = K(F.derivative(y)(P))
@@ -934,9 +953,8 @@ def EllipticCurve_from_cubic(F, P, morphism=True):
fwd_defining_poly = [trans_x, trans_y, -b*trans_z]
fwd_post = -a
- # Second case: P is not a flex, then P, P2, P3 are different
+ # Second case: P, P2, P3 are different
else:
- P3 = chord_and_tangent(F, P2)
# send P, P2, P3 to (1:0:0), (0:1:0), (0:0:1) respectively
M = matrix.matrix(K, [P, P2, P3]).transpose()
F2 = M.act_on_polynomial(F)
}}}
--
Ticket URL: <https://trac.sagemath.org/ticket/21092>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.