(* Notebook to demonstrate the use of the explicit formula to show the nonexistence
of elliptic curves with very small conductor.  David Farmer & Sally Koutsoliotas *)

(* The version of the explicit formula used here is from Seection 3 of Andy Booker's paper
"Artin’s Conjecture, Turing’s Method, and the Riemann Hypothesis",
Experimental Mathematics,Vol.15 (2006),No.4, p. 385-407 *)

(* define the digamma function *)

DiGamR[xx_]:=DiGamR[xx]=N[PolyGamma[xx/2],20]/2-Log[Pi]/2 (* $\Gamma_R'/\Gamma_R(xx) *)

(* now we set up the terms on the right side of (3-1) in Booker's paper *)

digamterm[Aa_,mulis_,eps_,ILim_]:=(1/Pi) Re[Sum[
eps Sum[DiGamR[1/2+mulis[[j]]+I y]h[Aa,y],{y,-ILim+eps/2,ILim,eps}],{j,1,Length[mulis]}]]
(* the spectral term, where we evaluate the integral as a Riemann sum of stepsize eps, summed from -ILim to ILim.  Try eps=1/5 and ILim =500 to get a few decimal places of accuracy *)

(* Note: for an elliptic curve L-function, the list of spectral parameters is {1/2, 3/2} *)

coeffterm[Aa_,Sumlim_]:=-2 Sum[c[n]g[Aa,Log[n]]/Sqrt[n],{n,2,Sumlim}]
(* the coefficient sum, where the upper limit is Sumlim. *)

rhsEC[Aa_,lev_]:=g[Aa,0]Log[lev]+digamterm[Aa,{1/2,3/2},1/15,700]+
coeffterm[Aa,1000] (* need to check how many significant figures this gives*)

(* above is the RHS of the explicit formula for the specific case of the L-function
of an elliptic curve/Q with conductor 'lev'.*)

(* we will test with functions of the form g[A,x] = g[A x], where we will decide later
which function g[] to use.  *)

g[Aa_,t_]:=g[Aa t]

h[Aa_,t_]:=h[t/Aa]/Aa

(* Here are four possibilities: g0, g1, g2, and g3.
These have corresponding h0, h1, h2, and h3, in the notation of Booker's paper. *)

g0[t_]:=With[{Nt=Abs[N[t,20]]},If[Nt>1,0,1-Nt]]

h0[t_]:=(Sin[t/2]/(t/2))^2

h0[0]=1

g1[t_]:=With[{Nt=Abs[N[t,20]]},If[Nt>2,0,
If[Nt>1,4/3-2Nt+Nt^2-1/6 Nt^3,2/3-Nt^2+1/2 Nt^3]]]

h1[t_]:=(Sin[t/2]/(t/2))^4

h1[0]=1

Plot[g1[t],{t,-4,4}]

(* Note that g1 \in C^1(R), it is supported on [-2,2], and h1 is non-negative *)

(* The formulas assume that the functions g[] and h[] have been defined,
so we will use g1[] and h1[] *)

g[t_]:=g1[t]

h[t_]:=h1[t]

(* Let's show that there is no elliptic curve of conductor 4.
Choose the test function

rhsEC[2/ Log[2]+0.001,4]

(* since the other side of the explicit formula is non-negative,
we have a contradiction.  Therefore there is no L-function with that
funcitonal equation, and therefore no elliptic curve/Q with that conductor. *)

(* now let's show there is no elliptic curve with conductor 7 *)

rhsEC[2/ Log[2]+0.001,7]

(* that didn't work.  So let's adjust the test function *)

rhs[1.5,7]//Expand

(* the Hasse bound says
|c[2]|\le Sqrt[2]Log[2] \approx 0.98025
|c[3]| \le Sqrt[3]Log[3] \approc 1.9028.
Check that this implies the obove quantity is negative,
so there is no elliptic curve/Q with conductor 7 *)