# Ticket #9646(closed defect: fixed)

Opened 3 years ago

## Incorrect calculation of elliptic curve formal group law

Reported by: Owned by: hlaw cremona major sage-4.6.2 elliptic curves elliptic curve formal group law wuthrich N/A David Loeffler Chris Wuthrich sage-4.6.2.alpha3

### Description (last modified by hlaw) (diff)

If F(t1, t2) is a formal group law, then F(t1, t2) = t1 + t2 (mod t1*t2). So in particular, the coefficients of t1^i and t2^i are zero for all i > 1. However the formal group law of an elliptic curve as returned by Sage includes (at least) the terms -a1^2*t1^3 and -a1^2*t2^2, as the following example shows:

```sage: P.<a1, a2, a3, a4, a6> = PolynomialRing(ZZ, 5)
sage: E = EllipticCurve(list(P.gens()))
sage: F = E.formal().group_law(prec = 4)
sage: t2 = F.parent().gen()
sage: t1 = F.parent().base_ring().gen()
sage: F(t1, 0)
t1 - a1^2*t1^3   # should be t1
sage: F(0, t2)
t2 - a1^2*t2^3
```

Note also that the coefficient of t1^2*t2 + t1*t2^2 returned by sage is -a1^2 - a2, whereas, according to Silverman AEC IV.1, it should be simply -a2.

This was obtained in Sage 4.4.4 on MacOS X 10.5.8 (32 bit).

## Change History

### comment:1 Changed 3 years ago by hlaw

• Description modified (diff)

Added my Sage version and system info.

### comment:2 Changed 3 years ago by hlaw

The bug appears to be related to the precision in a regular way:

```sage: for prec in srange(4, 7):
....: E = EllipticCurve(list(P.gens()))
....: F = E.formal_group()
....: fg = F.group_law(prec)
....: print prec, fg(0, fg.parent().gen())
....:
4 t2 - a1^2*t2^3
5 t2 + (-a1^3 - a1*a2)*t2^4
6 t2 + (-a1^4 - 2*a1^2*a2 - a1*a3)*t2^5
```

Note that the error is always of degree one less than the precision. This might be related to the following issue, whereby the calculation dies when the precision is set to 2 or 3:

```sage: E = EllipticCurve(list(P.gens()))
sage: F = E.formal_group()
sage: fg = F.group_law(2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/hlaw/Dropbox/phd/thesis/<ipython console> in <module>()

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/formal_group.pyc in group_law(self, prec)
524         t3 = -t1 - t2 - \
525              (a1*lam + a3*lam2 + a2*nu + 2*a4*lam*nu + 3*a6*lam2*nu)/  \
--> 526              (1 + a2*lam + a4*lam2 + a6*lam3)
527         inv = self.inverse(prec)
528

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__sub__ (sage/structure/element.c:11073)()

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6966)()

TypeError: unsupported operand parent(s) for '-': 'Power Series Ring in t2 over Power Series Ring in t1 over Multivariate Polynomial Ring in a1, a2, a3, a4, a6 over Integer Ring' and 'Power Series Ring in t1 over Fraction Field of Multivariate Polynomial Ring in a1, a2, a3, a4, a6 over Integer Ring'
sage: fg = F.group_law(3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Users/hlaw/Dropbox/phd/thesis/<ipython console> in <module>()

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/formal_group.pyc in group_law(self, prec)
524         t3 = -t1 - t2 - \
525              (a1*lam + a3*lam2 + a2*nu + 2*a4*lam*nu + 3*a6*lam2*nu)/  \
--> 526              (1 + a2*lam + a4*lam2 + a6*lam3)
527         inv = self.inverse(prec)
528

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__sub__ (sage/structure/element.c:11073)()

/Users/hlaw/src/sage-src/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6966)()

TypeError: unsupported operand parent(s) for '-': 'Power Series Ring in t2 over Power Series Ring in t1 over Multivariate Polynomial Ring in a1, a2, a3, a4, a6 over Integer Ring' and 'Power Series Ring in t1 over Fraction Field of Multivariate Polynomial Ring in a1, a2, a3, a4, a6 over Integer Ring'
```

### comment:3 Changed 3 years ago by wuthrich

• Cc wuthrich added; hlaw removed
• Authors hlaw deleted

### comment:4 Changed 3 years ago by wuthrich

There was indeed a precision error in the code and the patch that I attach should fix that. This is quite a bad bug as ALL the computations with formal groups happen to be wrong...

### Changed 3 years ago by wuthrich

exported against 4.6

### comment:5 Changed 3 years ago by wuthrich

• Status changed from new to needs_review

### comment:6 Changed 3 years ago by wuthrich

... and now to the other thing. As I played around with this, I found that I get different results than the  Errata of  Silverman. So I had to dig a little deeper and I found that the formula in Silverman are not correct.

Here is an example. Let E be the elliptic curve y^2 + y = x^3+1 Because a1=a2=0, the formula in the middle of page 120 of Silverman tells us that

F(t,t) = [2](t) = 2*t + t^4 + ...

But I claim that it should be 2*t -7*t^4. Here is an example.

```sage: K = Qp(43,5)
sage: E = EllipticCurve(K,[0,0,1,0,1])
sage: Q = E(-779/43^2,-125945/43^3)
sage: tQ =-Q[0]/Q[1]
sage: tQ
24*43 + 4*43^2 + 32*43^3 + 41*43^4 + 34*43^5 + O(43^6)
```

so the point lies in the formal group. We use the multiplication law on the curve and find

```sage: ttwoQ = -(2*Q)[0]/(2*Q)[1]
sage: ttwoQ
5*43 + 9*43^2 + 21*43^3 + 38*43^4 + 37*43^5 + O(43^6)
```
```sage: sage: 2*tQ +tQ^4
5*43 + 9*43^2 + 21*43^3 + 28*43^4 + 37*43^5 + O(43^6)
sage: sage: 2*tQ -7*tQ^4
5*43 + 9*43^2 + 21*43^3 + 38*43^4 + 37*43^5 + O(43^6)
```

shows that -7 is correct. I have added a docstring in mult_by_n to illustrate that our formula is correct, because this function is computed without using group_law if the base ring is a field of char 0 (instead it uses the multiplication on the curve).

In fact, the error appears as a sign error in the formula for z_3. The corrected formula should read

F(z_1,z_2) = z_1+z_2 -a_1 z_1z_2 -a_2(z_1^2 z_2+z_1 z_2^2) - 2a_3 z_1^3 z_2 +(a_1 a_2-3 a_3) z_1^2 z_2^2 - 2a_3 z_1 z_2^3 + ...

### comment:7 Changed 3 years ago by cremona

I suggest that you write to Silverman, since he likes to keep his errata up to date! And add something in the docstring here to explain why you use a formula different from that in Silverman.

### comment:8 Changed 3 years ago by wuthrich

Yes, I was typing my email as you wrote that :-). and yes, it is a good idea to add a comment in the code.

### Changed 3 years ago by wuthrich

to be applied after the first patch

### comment:9 Changed 3 years ago by davidloeffler

• Status changed from needs_review to positive_review
• Reviewers set to David Loeffler
• Authors set to Chris Wuthrich

### comment:10 Changed 2 years ago by jdemeyer

Is there a reason the milestone is sage-5.0?

### comment:11 Changed 2 years ago by wuthrich

No, this can go in asap.

### comment:12 Changed 2 years ago by wuthrich

• Milestone changed from sage-5.0 to sage-4.6.2

### comment:13 Changed 2 years ago by jdemeyer

• Status changed from positive_review to closed
• Resolution set to fixed
• Merged in set to sage-4.6.2.alpha3
Note: See TracTickets for help on using tickets.