//// given a elliptic curve E : y^2+xy-x^3- a2 x^2-a4 x /// over F_2^d /// output : the trace of the frobenius or 2^(Ceiling(d/2)+1)-trace. agm1:=function(ab2,ab4) d:=Degree(Parent(ab2)); cc:=2; prec:=d+5; P2:=LocalRing(cc,d,prec); Q2:=LocalField(cc,d,prec); //Q2`SeriesPrinting:=true; F2,phi:=ResidueClassField(P2); S:=PolynomialRing(Q2); Embed(F2,Parent(ab2)); a2:=F2!ab2; a4:=F2!ab4; //a2:=w^5+1; //a4:=w^2+w^5; E:=EllipticCurve([F2!1,a2,0,a4,0]); a2:=Q2!a2; a4:=Q2!a4; pp:=x^2+(a2+1/4)*x+a4; rr:=Roots(pp); if Valuation(rr[1][1]) eq -2 then l0:=-rr[1][1];l1:=rr[2][1]-rr[1][1]; else l0:=-rr[2][1];l1:=rr[1][1]-rr[2][1];end if; l:=Sqrt(l1/l0); ll:=l; for i:=1 to Ceiling(d/2)+5 do ll:=ChangePrecision(2*Sqrt(ll)/(1+ll),prec); end for; a:=1;b:=ll; for i:=1 to d do a1:=ChangePrecision((a+b)/2,prec); b1:=ChangePrecision(Sqrt(a*b),prec); a:=a1;b:=b1; end for; return ChangePrecision(1/a+2^d*a,Ceiling(d/2)+1); end function;