Function: ellap
Section: elliptic_curves
C-Name: ellap
Prototype: GDG
Help: ellap(E,{p}): computes the trace of Frobenius a_p for the elliptic
 curve E, defined over Q or a finite field.
Doc:
 Let $E$ be an \kbd{ell} structure as output by \kbd{ellinit}, defined over
 a number field or a finite field $\F_q$. The argument $p$ is best left
 omitted if the curve is defined over a finite field, and must be a prime
 number or a maximal ideal otherwise. This function computes the trace of
 Frobenius $t$ for the elliptic curve $E$, defined by the equation $\#E(\F_q)
 = q+1 - t$ (for primes of good reduction).

 When the characteristic of the finite field is large, the availability of
 the \kbd{seadata} package will speed the computation.

 If the curve is defined over $\Q$, $p$ must be explicitly given and the
 function computes the trace of the reduction over $\F_p$.
 The trace of Frobenius is also the $a_p$ coefficient in the curve $L$-series
 $L(E,s) = \sum_n a_n n^{-s}$, whence the function name. The equation must be
 integral at $p$ but need not be minimal at $p$; of course, a minimal model
 will be more efficient.
 \bprog
 ? E = ellinit([0,1]);  \\ y^2 = x^3 + 0.x + 1, defined over Q
 ? ellap(E, 7) \\ 7 necessary here
 %2 = -4       \\ #E(F_7) = 7+1-(-4) = 12
 ? ellcard(E, 7)
 %3 = 12       \\ OK

 ? E = ellinit([0,1], 11);  \\ defined over F_11
 ? ellap(E)       \\ no need to repeat 11
 %4 = 0
 ? ellap(E, 11)   \\ ... but it also works
 %5 = 0
 ? ellgroup(E, 13) \\ ouch, inconsistent input!
    ***   at top-level: ellap(E,13)
    ***                 ^-----------
    *** ellap: inconsistent moduli in Rg_to_Fp:
      11
      13

 ? Fq = ffgen(ffinit(11,3), 'a); \\ defines F_q := F_{11^3}
 ? E = ellinit([a+1,a], Fq);  \\ y^2 = x^3 + (a+1)x + a, defined over F_q
 ? ellap(E)
 %8 = -3
 @eprog

 If the curve is defined over a more general number field than $\Q$,
 the maximal ideal $p$ must be explicitly given in \kbd{idealprimedec}
 format. If $p$ is above $2$ or $3$, the function currently assumes (without
 checking) that the given model is locally minimal at $p$. There is no
 restriction at other primes.
 \bprog
 ? K = nfinit(a^2+1); E = ellinit([1+a,0,1,0,0], K);
 ? fa = idealfactor(K, E.disc)
 %2 =
 [  [5, [-2, 1]~, 1, 1, [2, -1; 1, 2]] 1]

 [[13, [5, 1]~, 1, 1, [-5, -1; 1, -5]] 2]
 ? ellap(E, fa[1,1])
 %3 = -1 \\ non-split multiplicative reduction
 ? ellap(E, fa[2,1])
 %4 = 1  \\ split multiplicative reduction
 ? P17 = idealprimedec(K,17)[1];
 ? ellap(E, P17)
 %6 = 6  \\ good reduction
 ? E2 = ellchangecurve(E, [17,0,0,0]);
 ? ellap(E2, P17)
 %8 = 6  \\ same, starting from a non-miminal model

 ? P3 = idealprimedec(K,3)[1];
 ? E3 = ellchangecurve(E, [3,0,0,0]);
 ? ellap(E, P3)  \\ OK: E is minimal at P3
 %11 = -2
 ? ellap(E3, P3) \\ junk: E3 is not minimal at P3 | 3
 %12 = 0
 @eprog

 \misctitle{Algorithms used} If $E/\F_q$ has CM by a principal imaginary
 quadratic order we use a fast explicit formula (involving essentially
 Kronecker symbols and Cornacchia's algorithm), in $O(\log q)^2$.
 Otherwise, we use Shanks-Mestre's baby-step/giant-step method, which runs in
 time $\tilde{O}(q^{1/4})$ using $\tilde{O}(q^{1/4})$ storage, hence becomes
 unreasonable when $q$ has about 30~digits. Above this range, the \tet{SEA}
 algorithm becomes available, heuristically in $\tilde{O}(\log q)^4$, and
 primes of the order of 200~digits become feasible.  In small
 characteristic we use Mestre's (p=2), Kohel's (p=3,5,7,13), Satoh-Harley
 (all in $\tilde{O}(p^{2}\*n^2)$) or Kedlaya's (in $\tilde{O}(p\*n^3)$)
 algorithms.
