// This Magma script performs the computations described in section 6 of "A database of nonhyperelliptic genus 3 curves over Q" to prove
// that the Jacobians of the smooth plane quartic C1 and the hyperelliptic curve C2 of discriminant -8233 both have Mumford Tate group GSp_6.

load "spqdisc.m";
RZ3<x,y,z>:=PolynomialRing(Integers(),3);
RZ<t>:=PolynomialRing(Integers());
f:=x^3*z + x^2*y*z + x^2*z^2 + x*y^3 - x*y^2*z + y^4 - y^3*z - y*z^3;
C1:=Curve(ProjectiveSpace(RZ3),f);
C2:=HyperellipticCurve(t^7-8*t^5-4*t^4+18*t^3-3*t^2-16*t+8, t^4+t^3+t^2+1);
assert tf_disc(f) eq -8233 and Discriminant(C2) eq -8233;
assert LPolynomial(ChangeRing(C1,GF(31))) eq LPolynomial(ChangeRing(C1,GF(31)));
assert LPolynomial(ChangeRing(C1,GF(43))) eq LPolynomial(ChangeRing(C1,GF(43)));
f31:=ChangeRing(Reverse(LPolynomial(ChangeRing(C2,GF(31)))),GF(5));
print "f_31 =", RZ!f31;
f43:=ChangeRing(Reverse(LPolynomial(ChangeRing(C1,GF(43)))),GF(5));
print "f_43 =", RZ!f43;

G:=Sp(6,5);
S:=[H`subgroup:H in MaximalSubgroups(G)];
printf "Sp(6,F_5) has %o maximal subgroups (up to conjugacy)", #S;
S:=[H:H in S|#[g:g in ConjugacyClasses(H)|CharacteristicPolynomial(g[3]) eq f31] gt 0];
printf "%o of these contain an element with charpoly equal to f_31", #S;
S:=[H:H in S|#[g:g in ConjugacyClasses(H)|CharacteristicPolynomial(g[3]) eq f43] gt 0];
printf "%o of these also contain an element with charpoly equal to f_43", #S;
