default(parisize,"148M");
ellfromeqn(t0*y^3+(s1+s0*x)*y^2 +(r2+r1*x+r0*x^2)*y+(q3+q2*x+q1*x^2+q0*x^3))
ellfromeqn(t0*y^2+(s0*x^2+s1*x+s2)*y+(r0*x^4+r1*x^3+r2*x^2+r3*x+r4))
ellfromeqn(t0*x^2+(s0*y^2+s1*y+s2)*x+(r0*y^4+r1*y^3+r2*y^2+r3*y+r4))
ellfromeqn((t0*x^2+t1*x+t2)*y^2+(r0*x^2+r1*x+r2)*y+(s0*x^2+s1*x+s2))
projisoncurved(E,P)=
{
   my([x,y,z]=P);
  y^2+E.a1*x*y*z+E.a3*y*z^3-(x^3+E.a2*x^2*z^2+E.a4*x*z^4+E.a6*z^6);
}

check_quartic()=
{
  my(E=t0*y^2+(s0*x^2+s1*x+s2)*y+(r0*x^4+r1*x^3+r2*x^2+r3*x+r4));
  my([G,F]=ellfromeqn(E,[x,y,d]));
  print(G[1..5]-ellfromeqn(E));
  my(S=substvec(E,[x,y],[x/d,y/d^2])*d^4);
  print(projisoncurved(G,F)%S);
  print(apply(x->valuation(x,2),F));
  print(apply(x->valuation(x,3),F));
  print(apply(x->valuation(x,'d),F));
  F*Mod(1,2);
  F*Mod(1,3);
  F;
}

check_quartic();

check_biquad()=
{
  my(E=(t0*x^2+t1*x+t2)*y^2+(r0*x^2+r1*x+r2)*y+(s0*x^2+s1*x+s2));
  my([G,F]=ellfromeqn(E,[x,y,d]));
  print(G[1..5]-ellfromeqn(E));
  my(S=substvec(E,[x,y],[x/d,y/d])*d^4);
  print(projisoncurved(G,F)%S);
  print(apply(x->valuation(x,2),F));
  print(apply(x->valuation(x,3),F));
  print(apply(x->valuation(x,'d),F));
  F*Mod(1,2);
  F*Mod(1,3);
  F;
}

check_biquad();
