SetAutoColumns(false);
SetColumns(100);
ClearVerbose();
SetEchoInput(true);
//////////////////////////////////////////////////////////////////////////////
//(1)

_<X>:=PolynomialRing(Rationals());
K<t> := NumberField( -1 + 19*X - 3*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic91b1 := x^3 + (t - 3)*x^2 + (t^2 - 3*t + 19)*x; // Known: x = 0, infty, 1/9.
E:=EllipticCurve(cubic91b1);

//prove that Rank(E(K))=1 by a 2-descent on an isogenous curve
Ed:=Codomain(TwoIsogeny(E![0,0]));
assert RankBound(Ed:Isogeny:=2) eq 1;

//Generators of the MWgroup
gs:=[E|[0,0],[1/4*(t^2 -  2*t + 21) , 1/4*(3*t^2 - 6*t + 51)]];
//gs[2] is really non-torsion:
assert TorsionBound(E,1) eq 2;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
assert IsPSaturated(mwmap,2);
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;

////////////////////////////////////////////
//Chabauty now has changed considerably: It returns
//N,V,R,C, where:
// N - Upper bound computed on the number of points in Domain(mwmap)
//     that map to a rational point under mwmap*cov. This bound can in fact be
//     Infinity() in bad cases.
// V - A set of elements of Domain(mwmap) that have a rational image
//     so, if #V eq N then all points are known.
// R - If the index of Image(mwmap) in the entire Mordell-Weil group is
//     prime to R then the information computed is also valid for the entire
//     Mordell-Weil group.
// C - A Coset-structure (like returned & used by CosetIntersection). Any points
//     with rational image under cov that are not mentioned in V lie in the
//     union of these cosets. In particular, if N eq #V then C is empty.
//     The information in C is usually greatly lifted p-adically. Hence, C
//     can subsequently be used for shallow-deep Brauer-Manin obstruction
//     computations.
//     If #C eq N-#V then each class has at most 1 point with rational image
//     in it.
////////////////////////////////////////////
// What Chabauty tries:
//  - First, using finite field arguments and "Weak" shallow-shallow
//    intersections, a first approximation is made
//  - Using this congruence information, some small combinations in mwmap are
//    tested for rationality. This gives the first approximation for V.
//  - For the found points P0, the ramification index of cov at P0 is
//    determined and it is determined if P0 is the only point with rational
//    image in its fibre of reduction.
//  - For remaining congruence classes, the system of equations is written down
//    to some finite precision. This system is solved. If all solutions
//    found are provably separated (i.e. hensel-liftable) then we know the
//    exact number of solutions and they are Hensel-lifted to some precision.
//    Points for which we run out of precision before they are separated, or
//    will never be separated because they have higher multiplicity, we
//    register the approximation and we flag that the returned N will be
//    Infinity().
//  - Found separated points are tested if there is a small exact
//    representative. If so, this is tested for having rational image and if so,
//    the point is added to V (A high precision p-adic approximation to a
//    small integer valued vector is easy to spot)
//  - Any of the non-separated points and the separated points for which no
//    explicit representative with rational image is found, is added to the
//    coset structure C.
////////////////////////////////////////////

N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
//(2)

K<t> := NumberField( -1 + 19*X - 3*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic91b2 := (-t+1)*x^3 + (-t^2+4*t-3)*x^2 + (t^2-3*t+18)*x; // Known: x = 0, infty, 1, 4.
C:=HyperellipticCurve(cubic91b2);
E,CtoE:=EllipticCurve(C);

//prove that Rank(E(K))=1 by a 2-descent on an isogenous curve
Ed:=Codomain(TwoIsogeny(E![0,0]));
assert RankBound(Ed:Isogeny:=2) eq 1;

//Generators of the MWgroup
gs:=[E|[0,0],[-t + 1 , -4*t + 4]];
//gs[2] is really non-torsion:
assert TorsionBound(E,10) eq 2;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
assert IsPSaturated(mwmap,2);
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

//Chabauty at 3 would probably work, except that two points end up in the
//same fibre and this routine by default does not compute the power series
//sufficiently far to still obtain finiteness.
//Chabauty at 5 with shallow information from 3 does do the trick.
//R is a number that the index of mwmap in E(K) should be prime to in order for
//V to be the subset of G with rational image under mwmap*cov.
N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (3)
K<t> := NumberField( -9 + 19*X + 5*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic123b1 := x^3 + (t + 5)*x^2 + (t^2 + 5*t + 19)*x; // Known: x = 0, infty, 9.
E:=EllipticCurve(cubic123b1);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;
N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (4)
K<t> := NumberField( -9 + 19*X + 5*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic123b2 := (-t+1)*x^3 + (-t^2-4*t+5)*x^2 + (t^2+5*t+10)*x; // Known: x = 0, infty, 1.
C:=HyperellipticCurve(cubic123b2);
E,CtoE:=EllipticCurve(C);

//prove that Rank(E(K))=1 by a 2-descent on an isogenous curve
Ed:=Codomain(TwoIsogeny(E![0,0]));
assert RankBound(Ed:Isogeny:=2) eq 1;

//Generators of the MWgroup
gs:=[E|[0,0],[-t + 1,-4*t + 4]];
//gs[2] is really non-torsion:
assert TorsionBound(E,10) eq 2;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
assert IsPSaturated(mwmap,2);
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

//My routine is sure that an argument at 5 does *not* work, because
//it thinks the shallow information at 5 is not accounted for by the
//actual points with rational image.
N,V,R:=Chabauty(mwmap,cov,7);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (5)
K<t> := NumberField( 27 - 5*X - 7*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic141b1 := x^3 + (t - 7)*x^2 + (t^2 - 7*t - 5)*x; // Known: x = 0, infty, 9.
E:=EllipticCurve(cubic141b1);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;
N,V,R,cl:=Chabauty(mwmap,cov,7);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (6)
K<t> := NumberField( 27 - 5*X - 7*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic141b2 := (-t+1)*x^3 + (-t^2+8*t-7)*x^2 + (t^2-7*t+22)*x; // Known: x = 0, infty, 1, 169/121.
C:=HyperellipticCurve(cubic141b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R,cl:=Chabauty(mwmap,cov,7);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (7)
K<t> := NumberField( 16 + 9*X - 10*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic142b1 := x^3 + (t - 10)*x^2 + (t^2 - 10*t + 9)*x; // Known: x = 0, infty, 9.
E:=EllipticCurve(cubic142b1);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;
N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (8)
K<t> := NumberField( 16 + 9*X - 10*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic142b2 := (-t+1)*x^3 + (-t^2+11*t-10)*x^2 + (t^2-10*t+25)*x; // Known: x = 0, infty, 1.
C:=HyperellipticCurve(cubic142b2);
E,CtoE:=EllipticCurve(C);
gs:=[E|[0,0],[t^2 - 2*t + 1,8*t^2 - 12*t - 12]];
//gs[2] is really non-torsion:
assert TorsionBound(E,10) eq 2;
assert RankBound(E) eq 1;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
assert IsPSaturated(mwmap,2);

[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,3);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (9)
K<t> := NumberField( X^3 - 11*X^2 + 19*X - 25 );   _<x> := PolynomialRing( K );
cubic155b1 := x^3 + (t - 11)*x^2 + (t^2 - 11*t + 19)*x; // Known: x = 0, infty, 9.
E:=EllipticCurve(cubic155b1);

//prove that Rank(E(K))=1 by a 2-descent on an isogenous curve
Ed:=Codomain(TwoIsogeny(E![0,0]));
assert RankBound(Ed:Isogeny:=2) eq 1;

gs:=[E|[0,0],[9 , -3*t + 3]];
//gs[2] is really non-torsion:
assert TorsionBound(E,10) eq 2;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
assert IsPSaturated(mwmap,2);
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;
N,V,R:=Chabauty(mwmap,cov,7);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
//(10)
K<t> := NumberField( X^3 - 11*X^2 + 19*X - 25 );   _<x> := PolynomialRing( K );
cubic155b2 := (t-1)*x^3 + (t^2-12*t+11)*x^2 + (-t^2+11*t+6)*x; // Known: x = 0, infty, 1.
C:=HyperellipticCurve(cubic155b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E:UseHomogeneousSpaces:=false);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R,cl:=Chabauty(mwmap,cov,3);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (11)
K<t> := NumberField( -8 + 9*X + 14*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic158b1 := x^3 + (t + 14)*x^2 + (t^2 + 14*t + 9)*x; // Known: x = 0, infty, 1, 9.
E:=EllipticCurve(cubic158b1);

gs:=[E|[0,0],
       [-t-3,1/2*(-t^2-19*t-8)],
       [1/8*(7*t^2+93*t),1/8*(13*t^2+183*t+136)]];
//gs[2] is really non-torsion:
assert TorsionBound(E,10) eq 2;
assert RankBound(E) eq 2;

//Construct the Mordell-Weil group as a map:
G:=AbelianGroup([2,0,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
//assert IsPSaturated(mwmap,2);

[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=map<E->P1|[E.1,E.3]>;

N,V,R,cl:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (12)
K<t> := NumberField( 8 + 25*X - 18*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic254b2 := (-t+1)*x^3 + (-t^2+19*t-18)*x^2 + (t^2-18*t+33)*x;// Known: x = 0, infty, 1, 1/4.
C:=HyperellipticCurve(cubic254b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E:UseHomogeneousSpaces:=false);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R,cl:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (13)
K<t> := NumberField( X^3 + 10*X^2 - 63*X + 4 );   _<x> := PolynomialRing( K );
cubic326a2 := -t*x^3 + (-t^2 - 10*t)*x^2 + 4*x;// Known: x = 0, infty.
C:=HyperellipticCurve(cubic326a2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E:UseHomogeneousSpaces:=false);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R,cl:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (14)
K<t> := NumberField( -16 - 7*X + 38*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic446b1 := x^3 + (t + 38)*x^2 + (t^2 + 38*t - 7)*x;// Known: x = 0, infty, 1.
C:=HyperellipticCurve(cubic446b1);
E,CtoE:=EllipticCurve(C);
assert RankBound(E) eq 1;
assert TorsionBound(E,10) eq 2;
gs:=[E![0,0],E![1/4*(t^2 + 39*t + 36),2*t^2 + 78*t + 64]];
G:=AbelianGroup([2,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R:=Chabauty(mwmap,cov,3);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (15)
K<t> := NumberField( 4 + 17*X - 6*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic106b2 := (-t+1)*x^3 + (-t^2+7*t-6)*x^2 + (t^2-6*t+21)*x;// Known: x = 0, infty, 1, 9.
C:=HyperellipticCurve(cubic106b2);
E,CtoE:=EllipticCurve(C);
assert RankBound(E) eq 2;
assert #TorsionSubgroup(E) eq 2;
gs:=[E![0,0],E![1/4*(-3*t^2-t),1/4*(7*t^2+33*t+4)],E![t^2-6*t+17,3*t^2-19*t+60]];
G:=AbelianGroup([2,0,0]);
mwmap:=map<G->E|a:->&+[a[i]*gs[i]:i in [1..#gs]]where a:=Eltseq(a)>;

P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R,c5:=Chabauty(mwmap,cov,5);
OK:=IntegerRing(K);
c31,R31:=RelevantCosets(mwmap,cov,Support(31*OK));
R:=LCM(R,R31);
csi:=CosetIntersection(c5,c31:Weak);
assert #csi[2] eq 0;
N:=N-#c5[2];
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (16)
K<t> := NumberField( 4 + X + 10*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic122b2 := (-t + 1)*x^3 + (-t^2 - 9*t + 10)*x^2 + (t^2 + 10*t + 5)*x;// Known: x = 0, infty, 1, 25.
C:=HyperellipticCurve(cubic122b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E:UseHomogeneousSpaces:=false);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R:=Chabauty(mwmap,cov,3);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (17)
K<t> := NumberField( X^3 - 11*X^2 + 35*X - 9 );   _<x> := PolynomialRing( K );
cubic129a1 := x^3 + (t - 11)*x^2 + (t^2 - 11*t + 35)*x;// Known: x = 0, infty, 1, 289/49.

C:=HyperellipticCurve(cubic129a1);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E:UseHomogeneousSpaces:=false);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);
N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (18)
K<t> := NumberField( X^3 - 11*X^2 + 35*X - 9 );   _<x> := PolynomialRing( K );
cubic129a2 := (-t+5)*x^3 + (-t^2+16*t-55)*x^2 + (5*t^2-55*t+166)*x;// Known: x = 0, infty, 9.

C:=HyperellipticCurve(cubic129a2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (19)
K<t> := NumberField( X^3 - 8*X^2 - 11*X + 2 );   _<x> := PolynomialRing( K );
cubic158b2 := (t-1)*x^3 + (t^2-9*t+8)*x^2 + (-t^2+8*t+9)*x;// Known: x = 0, infty, 1, 9.

C:=HyperellipticCurve(cubic158b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (20)
K<t> := NumberField( -4 + 17*X + 2*X^2 + X^3 );   _<x> := PolynomialRing( K );
cubic166b1 := x^3 + (t + 2)*x^2 + (t^2 + 2*t + 17)*x;// Known: x = 0, infty, 1/4.

C:=HyperellipticCurve(cubic166b1);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,5);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (21)
K<t> := NumberField( -4 + 17*X + 2*X^2 + X^3 );   _<x> := PolynomialRing( K );
//originally, it said 166b1 here, just as above. I assume it's b2.
cubic166b2 := (-t+1)*x^3 + (-t^2-t+2)*x^2 + (t^2+2*t+13)*x;// Known: x = 0, infty, 1.

C:=HyperellipticCurve(cubic166b2);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,5);
assert IsPSaturated(mwmap,3);
assert N eq #V and PrimeDivisors(R) subset {2,3};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};

//////////////////////////////////////////////////////////////////////////////
// (22)
K<t> := NumberField( X^3 + 5*X^2 + 3*X - 25 );   _<x> := PolynomialRing( K );
cubic215a1 := x^3 + (t + 5)*x^2 + (t^2 + 5*t + 3)*x;// Known: x = 0, infty, 1.

C:=HyperellipticCurve(cubic215a1);
E,CtoE:=EllipticCurve(C);
bl,G,mwmap:=PseudoMordellWeilGroup(E);
assert bl;
[mwmap(g):g in OrderedGenerators(G)];
P1:=ProjectiveSpace(Rationals(),1);
cov:=Expand(Inverse(CtoE)*map<C->P1|[C.1,C.3]>);

N,V,R:=Chabauty(mwmap,cov,3);
assert N eq #V and PrimeDivisors(R) subset {2};
{EvaluateByPowerSeries(cov,mwmap(g)):g in V};
