
// Make newform 800.4.c.i in Magma, downloaded from the LMFDB on 16 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_800_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_800_c_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_800_4_c_i();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_800_4_c_i();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [9, 0, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 0, 2, 0], [0, 6, 0, 2], [0, 12, 0, -4]];
    Rf_basisdens := [1, 3, 3, 3];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_800_c();"
function MakeCharacter_800_c()
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    v := [2, 2, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_800_c_Hecke();"
function MakeCharacter_800_c_Hecke( : Kf := false)
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    char_values := [[1, 0, 0, 0], [1, 0, 0, 0], [-1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 4;
    raw_aps := [[0, 0, 0, 0], [0, 2, -1, 0], [0, 0, 0, 0], [0, -2, -5, 0], [-32, 0, 0, 3], [0, -3, 8, 0], [0, 1, 24, 0], [104, 0, 0, 4], [0, 30, 11, 0], [146, 0, 0, -8], [-88, 0, 0, -3], [0, -89, -16, 0], [50, 0, 0, 20], [0, -94, -37, 0], [0, 70, -13, 0], [0, -79, 24, 0], [360, 0, 0, 10], [-634, 0, 0, 16], [0, 186, 47, 0], [24, 0, 0, 109], [0, 235, -120, 0], [16, 0, 0, 86], [0, -398, 47, 0], [390, 0, 0, 24], [0, 305, 40, 0], [758, 0, 0, -104], [0, -602, -89, 0], [0, -582, 99, 0], [-22, 0, 0, 88], [0, 687, 48, 0], [0, -138, 291, 0], [-448, 0, 0, -203], [0, -539, 64, 0], [1352, 0, 0, 122], [-1390, 0, 0, -120], [280, 0, 0, 25], [0, -805, -400, 0], [0, -870, 59, 0], [0, -874, -313, 0], [0, -1203, 208, 0], [2520, 0, 0, 50], [-1050, 0, 0, -128], [-392, 0, 0, 23], [0, -889, 264, 0], [0, 319, 296, 0], [-1168, 0, 0, -228], [512, 0, 0, 177], [0, -386, -73, 0], [0, -150, 407, 0], [1018, 0, 0, 432], [0, 611, 984, 0], [-1424, 0, 0, 106], [4506, 0, 0, 36], [-2560, 0, 0, -125], [0, 793, 432, 0], [0, 1438, 131, 0], [234, 0, 0, 544], [-616, 0, 0, -201], [0, -2441, 816, 0], [1010, 0, 0, 220], [0, 1010, 491, 0], [0, -1671, 96, 0], [0, 938, -1025, 0], [-4216, 0, 0, 399], [0, 267, 528, 0], [0, -989, -1256, 0], [-9808, 0, 0, 197], [0, -967, -48, 0], [0, -2502, 955, 0], [722, 0, 0, -1024], [0, 975, -1040, 0], [688, 0, 0, -12], [0, 2382, -1305, 0], [0, 2905, 240, 0], [-5928, 0, 0, -528], [0, 1406, 775, 0], [1378, 0, 0, -192], [0, -2957, 1592, 0], [-6942, 0, 0, -640], [-2258, 0, 0, 1092], [600, 0, 0, -1370], [-3650, 0, 0, 120], [4280, 0, 0, 835], [0, 2759, 1336, 0], [-8368, 0, 0, -828], [0, 1098, -889, 0], [-1594, 0, 0, -404], [0, 5277, 1248, 0], [7182, 0, 0, 824], [0, 878, 1031, 0], [0, 1986, 507, 0], [-13008, 0, 0, 462], [0, 5270, 87, 0], [12320, 0, 0, -565], [7400, 0, 0, 1060], [0, -2650, -641, 0], [-13902, 0, 0, 304], [-2982, 0, 0, -704], [0, -3646, 1467, 0], [3614, 0, 0, 1576], [0, 634, -1057, 0], [0, -3173, 1648, 0], [0, -5022, -2217, 0], [8526, 0, 0, -844], [-15568, 0, 0, -23], [0, -1159, -736, 0], [0, -2414, -1409, 0], [0, -4761, 1376, 0], [288, 0, 0, 2318], [-2798, 0, 0, 12], [0, 1270, 2947, 0], [0, 11729, 136, 0], [0, 6045, 40, 0], [10904, 0, 0, -476], [-15912, 0, 0, 793], [13866, 0, 0, -764], [0, 2778, 2603, 0], [0, 150, 4327, 0], [0, 1845, 2520, 0], [12632, 0, 0, -38], [-5810, 0, 0, 1360], [0, -10385, 680, 0], [0, 8143, -328, 0], [0, -14510, -301, 0], [-12624, 0, 0, -129], [5574, 0, 0, 584], [11002, 0, 0, 1368], [560, 0, 0, -1270], [0, 3838, -5885, 0], [0, 6117, -1312, 0], [-21032, 0, 0, 678], [0, -186, -3673, 0], [-26968, 0, 0, 777], [0, 8375, -3520, 0], [-18614, 0, 0, 1664], [-1938, 0, 0, -2312], [0, 8641, 984, 0], [0, 15634, -317, 0], [0, 1635, -920, 0], [-7866, 0, 0, 1280], [-14560, 0, 0, 1155], [17326, 0, 0, 1656], [0, 7470, -4349, 0], [0, -4246, -2141, 0], [-38534, 0, 0, 496], [4032, 0, 0, 62], [0, 1705, -360, 0], [0, -4611, -7664, 0], [15752, 0, 0, -2778], [0, 7510, 5651, 0], [0, -6445, -1120, 0], [-6358, 0, 0, -68], [0, -6958, -5681, 0], [0, -7442, 4235, 0], [0, 9170, -897, 0], [-2744, 0, 0, -3619], [-24832, 0, 0, 1658], [-39162, 0, 0, -1172], [0, 2237, 4408, 0], [-17362, 0, 0, 1360], [0, -21110, -1137, 0], [0, 6379, 7456, 0], [0, -14018, 1675, 0], [20688, 0, 0, 393], [0, -10359, 1144, 0], [0, 7294, -5685, 0], [-12472, 0, 0, 553], [0, 13719, 2296, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_800_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_800_4_c_i();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_800_4_c_i(:prec:=4)
    chi := MakeCharacter_800_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_800_4_c_i();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_800_4_c_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_800_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![64, 0, 80, 0, 1]>,<11,R![160, 64, 1]>],Snew);
    return Vf;
end function;