
// Make newform 676.4.h.e in Magma, downloaded from the LMFDB on 19 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_676_h();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_676_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_676_4_h_e();".
// 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_676_4_h_e();".
// 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 := [6561, 9072, 16675, -5712, 2520, -224, 51, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [88255737, 162623830, -71728440, 25532640, -2541224, 485520, -6885, 9826], [57304989, 306645343, 137764200, 83154960, 22456, 3930864, 352863, 64117], [125518095, 647352, 895104, 9050020, -563584, 248640, 13121, 5032], [16692237, 37143703, -255583608, 157075128, -21247016, 4161696, 145287, 99661], [-377106597, 3439516391, -951034728, 338532768, -28710472, 6437424, -91287, 114845], [-5197882509, -2238677237, 1341279912, -462351960, 51933448, -7530096, 351945, -167831], [-4523137929, 2238755969, -1341171048, 400635648, -52001992, 7560336, -134451, 168443]];
    Rf_basisdens := [1, 116697672, 233395344, 12966408, 233395344, 233395344, 233395344, 233395344];
    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_676_h();"
function MakeCharacter_676_h()
    N := 676;
    order := 6;
    char_gens := [339, 509];
    v := [6, 5];
    // 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_676_h_Hecke();"
function MakeCharacter_676_h_Hecke( : Kf := false)
    N := 676;
    order := 6;
    char_gens := [339, 509];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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 := 4;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, 0, 0], [-2, 3, -1, 0, 1, 0, 0, 0], [6, -3, 0, -1, 0, 0, 0, -1], [-7, -5, -2, -3, 0, -2, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [-2, 23, -4, -4, 2, -4, 0, 0], [24, -10, 0, 1, -4, 1, 0, 2], [-8, 2, -6, 0, 12, 13, 0, 0], [-122, 120, -2, 1, 4, -7, -1, 2], [-11, 24, 2, -7, -2, -14, 1, -1], [-86, -80, -6, -29, 0, -11, -7, 0], [-15, -11, -4, 38, 0, 22, -6, 0], [6, 123, 12, -31, -6, -32, 2, -1], [-91, 184, 2, -15, -2, -30, 5, -5], [-140, -11, 11, -6, 11, 0, -6, -6], [-100, 63, 0, 5, -26, -20, 0, -15], [-12, -300, -24, -28, 12, -37, 18, -9], [-84, -76, -8, -58, 0, -33, 8, 0], [494, -250, 0, 59, 6, -41, 0, 18], [-125, 291, 41, 7, -41, 14, -3, 3], [-508, 24, -24, 60, -24, 0, 8, 8], [-146, 332, 40, 4, -40, 8, 2, -2], [-467, -438, -29, 125, 0, 65, -5, 0], [507, -245, 0, -48, -17, 67, 0, 19], [334, -366, -32, 15, 64, -37, -15, 30], [151, 50, -50, -15, -50, 0, -9, -9], [-996, 1004, 8, 16, -16, -13, -16, 32], [50, -176, -76, 58, 76, 116, 22, -22], [2, -203, 4, -8, -2, 22, -60, 30], [-28, 2, -26, 0, 52, -131, 0, 0], [21, 10, -10, -41, -10, 0, -39, -39], [-224, 103, 0, 44, 18, -84, 0, -40], [22, -419, 44, -63, -22, -62, -2, 1], [58, -48, 0, -98, 38, 101, 0, 3], [317, -480, 154, -87, -154, -174, 57, -57], [40, 31, -31, -66, -31, 0, -10, -10], [624, -231, 0, 69, -162, -82, 0, -13], [-419, -547, 128, -279, 0, -136, -7, 0], [31, -707, 62, 196, -31, 159, 74, -37], [437, -343, 94, 15, -188, -60, -15, 30], [-758, 55, -55, -60, -55, 0, 8, 8], [-62, 1402, -124, -211, 62, -249, 76, -38], [733, 645, 88, -134, 0, -74, 14, 0], [-505, -342, -163, 163, 0, 105, -47, 0], [158, -804, 316, -255, -158, -251, -8, 4], [1826, -1938, -112, 34, 224, -235, -34, 68], [970, 780, 190, 212, 0, 87, 38, 0], [-1104, 462, 0, 89, 180, -31, 0, 58], [1346, -2616, 76, -126, -76, -252, -42, 42], [-1042, 8, -8, 108, -8, 0, -24, -24], [-1322, 2416, -228, -40, 228, -80, 10, -10], [96, -9, 0, 356, -78, -220, 0, 136], [-184, 1438, -368, 383, 184, 385, -4, 2], [269, -421, -152, -72, 304, -204, 72, -144], [4071, -4107, -36, -67, 72, -156, 67, -134], [151, -327, 302, -456, -151, -485, 58, -29], [987, 1091, -104, -45, 0, -66, 87, 0], [-52, -2818, -104, 440, 52, 541, -202, 101], [413, -999, -173, 113, 173, 226, 179, -179], [-1839, 1853, 14, -81, -28, -432, 81, -162], [3500, -1724, 0, 358, -52, -381, 0, -23], [1801, -3812, -210, 121, 210, 242, 29, -29], [2577, -106, 106, -313, 106, 0, 129, 129], [1606, 84, -84, 644, -84, 0, 64, 64], [2198, -4395, 1, 292, -1, 584, 88, -88], [-2220, 959, 0, -55, 302, 172, 0, 117], [-367, -35, 35, -79, 35, 0, -101, -101], [-244, 4748, -488, -317, 244, -357, 80, -40], [2639, 2450, 189, -597, 0, -319, 41, 0], [-2853, -2823, -30, 54, 0, -130, 314, 0], [-2892, 6004, 220, -134, -220, -268, -96, 96], [2612, -2742, -130, 156, 260, 381, -156, 312], [-366, -518, -732, 236, 366, 199, 74, -37], [3838, 4246, -408, 24, 0, 73, -122, 0], [4078, -1927, 0, 59, -224, -84, 0, -25], [-4400, -65, 65, -1202, 65, 0, -118, -118], [297, -223, 0, -202, 149, -5, 0, -207], [3605, 3347, 258, 140, 0, 88, -36, 0], [-4590, 2103, 0, -160, 384, 294, 0, 134], [1402, -1438, -36, -142, 72, 433, 142, -284], [1124, -2599, -351, 478, 351, 956, -374, 374], [-571, -247, -324, 1805, 0, 860, 85, 0], [28, -2265, 56, -1104, -28, -1134, 60, -30], [-1249, 1009, -240, -163, 480, -488, 163, -326], [3966, 200, -200, -890, -200, 0, 34, 34], [1959, -761, 0, 260, -437, -421, 0, -161], [-2211, -1919, -292, -522, 0, -198, -126, 0], [1294, -746, 0, 334, 198, -613, 0, -279], [-2094, 3380, -808, -684, 808, -1368, 62, -62], [-3632, 268, -268, 364, -268, 0, 104, 104], [446, 576, -130, 532, 0, 451, -370, 0], [3630, -1643, 0, -397, -344, 296, 0, -101], [5115, -5449, -334, 137, 668, 794, -137, 274], [-1947, 4368, 474, -1115, -474, -2230, 73, -73], [212, 6653, 424, 95, -212, 168, -146, 73], [-4078, -4554, 476, -695, 0, -377, 59, 0], [8547, -195, 195, -89, 195, 0, -163, -163], [-1437, 1515, 78, 53, -156, -706, -53, 106], [-332, 349, -315, 806, 315, 1612, -34, 34], [-13161, -174, 174, 245, 174, 0, 195, 195], [-420, 208, -628, -1537, 0, -735, -67, 0], [382, 9873, 764, 693, -382, 526, 334, -167], [14685, -14618, 67, -83, -134, 739, 83, -166], [686, -292, 292, 854, 292, 0, -286, -286], [3999, -7697, 301, -213, -301, -426, 761, -761], [-7875, -7785, -90, -867, 0, -398, -71, 0], [-8333, 16731, 65, 351, -65, 702, 93, -93], [5953, 454, -454, 2375, -454, 0, 37, 37], [-5287, 5617, 330, -58, -660, -1446, 58, -116], [-206, 4750, -412, 1385, 206, 1267, 236, -118], [3766, 5544, -1778, 435, 0, 293, -151, 0], [968, -643, 0, -1004, 318, 1038, 0, 34], [5526, -11512, -460, 476, 460, 952, 442, -442], [-11858, 6349, 0, 187, -840, -656, 0, -469], [490, 8539, 980, 1228, -490, 1020, 416, -208], [-732, -435, 0, 709, 1602, -754, 0, -45], [5916, -5102, 814, -36, -1628, -2267, 36, -72], [-14391, 14608, 217, 205, -434, 505, -205, 410], [-266, -1875, -532, -95, 266, 10, -210, 105], [-4568, -5554, 986, -815, 0, -213, -389, 0], [3711, -3697, 14, -40, -28, 1888, 40, -80], [12046, 640, -640, 720, -640, 0, -108, -108], [17928, -8944, 0, -323, -40, -41, 0, -364], [1401, 1399, 2, 1045, 0, 378, 289, 0], [-1074, 520, -520, -104, -520, 0, -252, -252], [-10350, 5174, 0, 170, 2, 351, 0, 521], [-604, 253, -1208, -2213, 604, -2552, 678, -339], [2702, 656, -656, 474, -656, 0, 22, 22], [3060, -6077, 43, 1290, -43, 2580, -126, 126], [-2075, -1573, -502, 3525, 0, 1734, 57, 0], [-1575, -1503, -72, 753, 0, 820, -887, 0], [-7371, 7423, 52, -233, -104, 1998, 233, -466], [15085, -15428, -343, -147, 686, 589, 147, -294], [11707, -6377, 0, -1328, 1047, 1055, 0, -273], [11273, 11454, -181, -1535, 0, -827, 119, 0], [-12695, 5725, 0, 34, 1245, 767, 0, 801], [10096, -5328, 0, -1915, 560, 2551, 0, 636], [331, 3689, 662, 276, -331, -121, 794, -397], [-4729, 5571, 842, 580, -1684, 2020, -580, 1160], [-421, 288, -554, 463, 554, 926, 819, -819], [-7025, -6646, -379, -1749, 0, -1207, 665, 0], [-824, -4317, -1648, -225, 824, 50, -550, 275], [-10642, 20736, -548, 196, 548, 392, -542, 542], [-3176, 2636, -540, 77, 1080, -643, -77, 154], [-2770, 1574, 0, -2381, -378, 1863, 0, -518], [13606, -27477, -265, -1144, 265, -2288, 480, -480], [-7235, 27, -27, 733, -27, 0, -17, -17], [11321, 466, -466, -517, -466, 0, 85, 85], [11412, -22480, 344, 2058, -344, 4116, -248, 248], [-1036, 1352, 0, -1646, -1668, 1335, 0, -311], [-599, 415, -184, -4, 368, 5112, 4, -8], [-1441, 546, -546, 3165, -546, 0, 59, 59], [3197, -3037, 160, 195, -320, 1074, -195, 390], [-7501, 8299, 798, -639, -1596, -954, 639, -1278], [13906, -680, 680, -3394, 680, 0, 130, 130], [330, -1898, 660, -95, -330, -533, 876, -438], [10034, -5089, 0, -1564, 144, 766, 0, -798], [-6253, -713, 713, -2601, 713, 0, -579, -579], [-2990, 7504, 1524, -670, -1524, -1340, 394, -394], [9224, 7776, 1448, 1054, 0, 291, 472, 0], [-1311, 16329, -2622, 522, 1311, 837, -630, 315], [15827, -30732, 922, -1477, -922, -2954, -217, 217], [-1168, 9104, -2336, 339, 1168, 1011, -1344, 672], [-7135, -5967, -1168, 202, 0, 10, 182, 0], [-12273, 24240, -306, 663, 306, 1326, 651, -651], [2186, -1768, 418, -190, -836, 299, 190, -380], [-696, 24770, -1392, 1132, 696, 1685, -1106, 553]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_676_h_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_676_4_h_e();".
// 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_676_4_h_e(:prec:=8)
    chi := MakeCharacter_676_h();
    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_676_4_h_e();".
// 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_676_4_h_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_676_h();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![2704, -3744, 9812, 6408, 7869, 144, 89, 0, 1]>,<7,R![437981184, -681583104, 373042176, -30320808, 496873, 33516, -499, -36, 1]>],Snew);
    return Vf;
end function;