
// Make newform 800.5.h.l in Magma, downloaded from the LMFDB on 23 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_800_h();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_800_h_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_5_h_l();".
// 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_5_h_l();".
// 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 := [3481, 0, 2015, 0, 413, 0, 35, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, -21020, 0, -7788, 0, -862, 0, -28], [4202, 0, 1280, 0, 98, 0, 2, 0], [0, 79808, 0, 32804, 0, 4928, 0, 188], [21980, 0, 10952, 0, 1520, 0, 56, 0], [0, -34940, 0, -16520, 0, -2210, 0, -80], [1192, 0, 480, 0, 58, 0, 2, 0], [0, -2947360, 0, -1188496, 0, -145336, 0, -5056]];
    Rf_basisdens := [1, 1003, 51, 3009, 51, 177, 1, 3009];
    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_h();"
function MakeCharacter_800_h()
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    v := [1, 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_h_Hecke();"
function MakeCharacter_800_h_Hecke( : Kf := false)
    N := 800;
    order := 2;
    char_gens := [351, 101, 577];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 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 := 5;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [18, 0, 2, 0, -1, 0, -1, 0], [0, 36, 0, -1, 0, -2, 0, -2], [0, -2, 0, -2, 0, 3, 0, 0], [0, -35, 0, 2, 0, -4, 0, 6], [0, -60, 0, 2, 0, 10, 0, 0], [-66, 0, 16, 0, -11, 0, 5, 0], [258, 0, 30, 0, -24, 0, -38, 0], [0, 62, 0, 27, 0, -10, 0, 1], [0, 226, 0, -52, 0, -27, 0, -4], [-652, 0, 113, 0, -28, 0, 35, 0], [1108, 0, 95, 0, 30, 0, 86, 0], [-1718, 0, -58, 0, -89, 0, 39, 0], [0, -318, 0, -118, 0, -25, 0, -44], [0, 168, 0, 20, 0, 114, 0, 62], [-688, 0, -93, 0, -136, 0, -3, 0], [-1124, 0, 107, 0, 34, 0, -54, 0], [0, 286, 0, 155, 0, 226, 0, 9], [0, -1121, 0, -170, 0, -88, 0, 30], [0, 1372, 0, -26, 0, -212, 0, 64], [1980, 0, 151, 0, -142, 0, -18, 0], [6326, 0, -28, 0, 40, 0, 276, 0], [0, 215, 0, 374, 0, 62, 0, 62], [6306, 0, -380, 0, 328, 0, -332, 0], [4998, 0, 72, 0, -47, 0, -247, 0], [-40, 0, -291, 0, -324, 0, 76, 0], [6800, 0, -451, 0, -64, 0, -37, 0], [0, -895, 0, -28, 0, -166, 0, -284], [-2186, 0, 108, 0, -435, 0, -491, 0], [0, -3688, 0, -323, 0, 174, 0, 86], [0, 579, 0, 840, 0, 482, 0, 164], [0, 5520, 0, 408, 0, -6, 0, 212], [11184, 0, -1339, 0, -104, 0, 499, 0], [0, 3022, 0, -69, 0, -1294, 0, 59], [0, 4274, 0, -140, 0, -1051, 0, -96], [29480, 0, -863, 0, -556, 0, -212, 0], [-21442, 0, -1236, 0, 101, 0, -179, 0], [0, -12474, 0, 1028, 0, 451, 0, 60], [0, 6680, 0, -276, 0, -570, 0, 420], [21306, 0, -856, 0, 232, 0, -104, 0], [0, 14626, 0, -715, 0, 114, 0, 373], [0, -3537, 0, -18, 0, 1808, 0, -122], [0, -7708, 0, 750, 0, 895, 0, -8], [0, 14648, 0, 276, 0, 1780, 0, -30], [0, -4324, 0, -323, 0, 34, 0, -1040], [-18090, 0, 1480, 0, -811, 0, 813, 0], [8824, 0, -2823, 0, 516, 0, 1872, 0], [20938, 0, -726, 0, -1032, 0, 742, 0], [0, 2461, 0, -1118, 0, -3138, 0, -454], [0, 11024, 0, -1850, 0, -1896, 0, -10], [25916, 0, -1267, 0, -284, 0, 679, 0], [0, -12688, 0, 1755, 0, 2490, 0, 688], [0, 6099, 0, -1652, 0, 1226, 0, 216], [-34630, 0, 3926, 0, 835, 0, -3125, 0], [14416, 0, -515, 0, -3080, 0, -13, 0], [0, 16614, 0, 2021, 0, 126, 0, 1165], [0, 27600, 0, -52, 0, 2419, 0, -1188], [-34972, 0, -1119, 0, 12, 0, -2725, 0], [37608, 0, -1503, 0, -3956, 0, -704, 0], [0, -14534, 0, -744, 0, -4265, 0, 800], [-6652, 0, -3697, 0, -2906, 0, -554, 0], [0, 8366, 0, 3737, 0, 3690, 0, 487], [0, 7543, 0, -1308, 0, 576, 0, 536], [0, 7128, 0, 3130, 0, -221, 0, -656], [0, -35396, 0, 1625, 0, -1818, 0, -476], [0, -42919, 0, 52, 0, -3864, 0, 944], [-220, 0, -2365, 0, -418, 0, -1630, 0], [-22206, 0, 2022, 0, 4680, 0, -2342, 0], [0, -36505, 0, 3012, 0, 808, 0, 1492], [0, -3204, 0, 2492, 0, -3560, 0, -782], [5166, 0, -2796, 0, 3161, 0, -2991, 0], [0, 42864, 0, 1980, 0, 1037, 0, -500], [0, 4852, 0, 2622, 0, 2262, 0, -454], [-160418, 0, 3100, 0, 681, 0, -2111, 0], [-161376, 0, -3979, 0, 424, 0, 2427, 0], [0, 6034, 0, 3778, 0, -5011, 0, -744], [-97686, 0, -8172, 0, 912, 0, 556, 0], [-54880, 0, 2361, 0, -2332, 0, -5173, 0], [0, -52708, 0, -8924, 0, -342, 0, -1454], [-54792, 0, -10545, 0, 1608, 0, 2361, 0], [0, -2218, 0, -4671, 0, 782, 0, -587], [0, 21557, 0, 4938, 0, -98, 0, 254], [0, -11572, 0, 1172, 0, 6896, 0, -2310], [65328, 0, -14591, 0, -464, 0, -3492, 0], [-120368, 0, -7503, 0, 4876, 0, 2091, 0], [0, 12741, 0, 6320, 0, 5884, 0, -372], [-36182, 0, 3016, 0, -4440, 0, -6416, 0], [-95102, 0, -130, 0, 6435, 0, 5707, 0], [87376, 0, -11031, 0, -3048, 0, 956, 0], [0, -101392, 0, -6418, 0, -3640, 0, -212], [86818, 0, 1262, 0, -1385, 0, -7953, 0], [0, -68388, 0, -1685, 0, 2190, 0, -4216], [0, -42764, 0, -11138, 0, -10590, 0, 3030], [-3658, 0, -4728, 0, 8057, 0, -4663, 0], [95754, 0, 8410, 0, 3272, 0, 1174, 0], [-108198, 0, 13980, 0, 6912, 0, -2716, 0], [-146880, 0, -9043, 0, 2392, 0, -9900, 0], [24330, 0, -7608, 0, 1304, 0, -7168, 0], [-16256, 0, -22603, 0, -6272, 0, 13012, 0], [0, -30312, 0, 1908, 0, 2091, 0, 3912], [10568, 0, 16989, 0, -1932, 0, 28, 0], [-85888, 0, -15655, 0, -2012, 0, -6661, 0], [0, 104700, 0, 3473, 0, 13558, 0, -1518], [0, -96429, 0, 7784, 0, -3766, 0, -6280], [3524, 0, -5273, 0, 6806, 0, 946, 0], [0, -43273, 0, -4576, 0, -2728, 0, 4164], [0, 16668, 0, -3374, 0, 8784, 0, 4012], [110252, 0, 20213, 0, 9404, 0, 12535, 0], [95690, 0, 15782, 0, 10471, 0, -10401, 0], [0, -30916, 0, 1182, 0, -1439, 0, -5260], [0, 11891, 0, 9622, 0, -2110, 0, 3426], [0, 25232, 0, -2854, 0, -7654, 0, -6814], [0, 121506, 0, -4345, 0, -3314, 0, -2047], [13876, 0, 5161, 0, 516, 0, 7947, 0], [-114156, 0, 23151, 0, 11102, 0, 42, 0], [-162550, 0, -2462, 0, -5725, 0, -5341, 0], [0, -62332, 0, 1250, 0, -487, 0, 5964], [0, -21380, 0, 632, 0, 17426, 0, 5610], [163920, 0, 11659, 0, -928, 0, 11333, 0], [0, -43199, 0, -15498, 0, -1094, 0, -8002], [0, -35728, 0, -2070, 0, -20517, 0, -1104], [-135524, 0, -29221, 0, -1134, 0, 22218, 0], [0, 211756, 0, -5745, 0, 1018, 0, -652], [-293352, 0, 5223, 0, -8592, 0, 4353, 0], [-293526, 0, 4274, 0, -19400, 0, -218, 0], [0, 93704, 0, -13794, 0, -2704, 0, -7494], [61866, 0, -22122, 0, -18925, 0, 3475, 0], [0, -139918, 0, 12560, 0, -2193, 0, 6948], [0, -11920, 0, 7544, 0, -8906, 0, 6808], [372378, 0, 5874, 0, -3045, 0, -7869, 0], [0, 75638, 0, 16419, 0, 10462, 0, 6687], [0, -54040, 0, -936, 0, 7595, 0, -8340], [110634, 0, -33620, 0, -944, 0, 33908, 0], [259254, 0, -46644, 0, -12904, 0, -180, 0], [0, -21104, 0, 10234, 0, 27461, 0, 372], [327740, 0, 13967, 0, 20114, 0, -1030, 0], [0, 169720, 0, 16574, 0, 11091, 0, 2276], [356886, 0, -6196, 0, -18656, 0, -2252, 0], [0, 273336, 0, 9443, 0, 15802, 0, 836], [58424, 0, 20439, 0, 14064, 0, 3873, 0], [361814, 0, -38076, 0, -10071, 0, 2305, 0], [-18036, 0, 18447, 0, 3274, 0, -14810, 0], [553264, 0, 36589, 0, -10120, 0, 9619, 0], [0, 239340, 0, -1234, 0, -6704, 0, 3798], [0, -30472, 0, 10194, 0, -11235, 0, -10008], [0, 198155, 0, -8252, 0, -39558, 0, 1408], [0, 395784, 0, 424, 0, -878, 0, 3646], [229042, 0, -54998, 0, -15069, 0, -10205, 0], [0, -118210, 0, 24264, 0, 19617, 0, 8752], [96564, 0, -71567, 0, 6092, 0, -20837, 0], [-141904, 0, -6871, 0, -1928, 0, -25792, 0], [-239054, 0, -8798, 0, 12975, 0, -2425, 0], [-247480, 0, -31455, 0, -12604, 0, 16892, 0], [0, -116226, 0, 28059, 0, -3586, 0, -6119], [0, -81116, 0, -16778, 0, -17032, 0, 14144], [-40840, 0, -9131, 0, 24140, 0, -10041, 0], [0, -2949, 0, -13646, 0, 42138, 0, 950], [-266198, 0, -19872, 0, 5368, 0, 19472, 0], [-416884, 0, -39869, 0, 16058, 0, 27002, 0], [0, -96785, 0, -8752, 0, 38536, 0, -2124], [491622, 0, 9260, 0, 1249, 0, -13239, 0], [0, 173248, 0, -1895, 0, -8782, 0, 5618], [0, -314453, 0, -3910, 0, -10046, 0, -5602], [374106, 0, -20722, 0, -17333, 0, 33811, 0], [0, -157846, 0, -29417, 0, -16798, 0, 16561], [0, -521346, 0, -17022, 0, -7335, 0, -3612]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_800_h_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_800_5_h_l();".
// 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_5_h_l(:prec:=8)
    chi := MakeCharacter_800_h();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_5_h_l();".
// 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_5_h_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_800_h();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([<3,R![11376, -720, -308, 0, 1]>,<7,R![-3208976, 179184, -1188, -72, 1]>],Snew);
    return Vf;
end function;