/*

21 Feb 01
---------

> Consider the modular curve X_0(N). Take a quadratic imaginary field K of
> class number one for simplicity and let O be the ring of integers. Then a
> complete Galois orbit of points on the modular curve is represented by
> [C/L \to C/O] where L goes trough all index N sub-lattices in O. If you
> choose a basis for O then the L's correspond to {A \in M_2(Z)|det A =
> N}/SL_2(Z) . In the case when N splits in K some of the points you get are
> Heegner points (but not all of them). So one needs to compute the sum of
> all this points on the elliptic curve we want to consider (of conductor
> 389?) and presumably we will get a point rational over K. I guess it's
> easy to compute the torsion over K and see if the point you get is
> torsion or not. Another possibility would be to consider E=X_0(11) for
> example and find K for which E(K) has rank 2 and to try to construct a
> non-trivial point there.


Remarks:

1. It is not necessary to do the torsion computation over K alluded to above
   because E is isolated in its isogeny class so all the Galois representations
   rho_{E,ell} are surjective.

<<< Strategy to do an interesting related computation:  >>>

1. Fix a quadratic imaginary extension K of Q.  Let 
O = Z + alpha*Z be the full ring of integers of K.

2. Consider the sum

       sum [C/O --->  C/L]

where L ranges over the rank 2 Z-modules in the vector 
space K = Q x Q such that L/O is a cyclic abelian group
of order N.  I think there are exactly #P^1(Z/NZ) such L.

3. As described in the lemma below, this sum is equal to 
 
      sum [r(alpha)] 
 
where r ranges over coset representatives for Gamma_0(N) \ SL_2(Z),
and the sum is an element of the free abelian group on the points
in the extended upper half plane.

4. 
Let f be a rational newform in S_2(Gamma_0(N)).
Let z be the complex number

       sum <f, {oo, r(alpha)}>

where the pairing is the integration pairing between cusp 
forms and modular symbols.

5. The point z defines an element of the complex elliptic curve
C / Lambda_f, where Lambda_f is the period lattice attached to f.

6. Using the Weierstrass p function attached to Lambda_f, we obtain
a point P = (x,y) on a cubic curve in P^2.

7. Questions:
   a) Is P defined over K?
   b) If E has rank 2, is P ever nonzero?

---------

8. Remark of Grigor:

 Let z=x+iy be a point in H and L=Z+Zt be a lattice. Then z is in L is
 the same as x+iy=m+nt for some m,n \in Z => x=m+Re(t)n and y=nIm(t)
 <=> n=y/Im(t) and m=x-Re(t){y/Im(t)} are integers.

---------

The following code for analytic.m is useful

intrinsic XPeriodIntegral(f::RngSerPowElt, alpha::FldPrElt) -> FldPrElt
{Test function -- to be removed later.}

   return PeriodIntegral(f, PolynomialRing(Rationals())!1, alpha);

end intrinsic;

========================================================

Propose:
  1. Search for quadratic imaginary extensions K of Q such that
     E = X_0(11) has rank 2 over K.

  2. Determine our magic point on E(K).

  3. Why do we always get a nontrivial 5-torsion points in the 
     examples we've tried with rank <= 1?
*/


E := MS("11A");
C := EC("11A");

function TwistHasEvenPositiveRank(d)
   assert d ge 1;
   K := NumberField(x^2+d);
   D := Discriminant(K);
   G := DirichletGroup(AbsoluteValue(D));
   eps := G.1;
   for i in [2..Ngens(G)] do
      eps := eps*G.i;
   end for;
   return Evaluate(eps,-Conductor(C)) eq 1 and 
          TwistedWindingElementModular(E,1,eps) eq E!0;
end function;

function SquareFree(n1, n2)
   return [n : n in [n1..n2] | n eq 1 or &*[f[2] : f in Factorization(n)] eq 1];
end function;

function TwistRank(d)
//   assert d ge 1;
   Ed := QuadraticTwist(C,-d);
   return Rank(Ed);
end function;


// The following D have the property that
// the -D quadratic twist of X_0(11) has rank 2.

D := [ 47, 86, 103, 119, 122, 158, 159, 166, 174 ];
