
// Make newform 300.9.g.h in Magma, downloaded from the LMFDB on 29 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_300_g();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_300_g_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_300_9_g_h();".
// 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_300_9_g_h();".
// 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 := [3433683820292512484657849089281, 0, -588516817021165377771877458, 0, 42910255095788484704448, 0, -4373061557178808206, 0, 1484695155668670, 0, -101588726286, 0, 23156928, 0, -7378, 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, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-922, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1423431157324590957071749337819988093, 0, 97439320345474574721245443129749, 0, 3485352495014175965316858063, 0, 4746195418588577798202495, 0, 214013909643019174755, 0, 126457566128179947, 0, 32210391788401, 0, -118241503, 0], [-2374313718998962356072521984335899, 0, 15988522642231144261362784701993, 0, 7126746748103003389938313191, 0, -140050706881610814672285, 0, 134747004904914583035, 0, 5205191446634679, 0, 545360564057, 0, 438411229, 0], [-7767748177539020226873719607705391242, 0, -1473149156225017240571482096707663, 0, 257905289910296311314646868010, 0, 86691769095675942519262875, 0, 284564718899432445330, 0, -1605609642957550713, 0, -101803994977442, 0, -5968589155, 0], [0, -510983834350445298184690566, 0, 42910255095788484704448, 0, -4373061557178808206, 0, 1484695155668670, 0, -101588726286, 0, 23156928, 0, -7378, 0, 1], [0, 2286102946760216024014189243114641, 0, -488135239609492118517858798039, 0, 15889852799914567568262183, 0, 893990708450313260895, 0, 1454707853876694735, 0, -104908177452681, 0, -13366675591, 0, -9990143], [18959612788879968454203241251324, 0, -2092818668997351782154051027, 0, 307048508107766448925968, 0, -44424226549043107605, 0, 150878465402940, 0, 852147203931, 0, 84994792, 0, -56323, 0], [-3582208268407457812459773082999060101, 0, 282710209346205493966540669557207, 0, -37567673727464881971509655591, 0, 10475029126320841638840285, 0, -841907185104513957435, 0, 155990425193416521, 0, -51903695295257, 0, 6522599171, 0], [-10303770409953809798553362085042235881, 0, 1305055640077155944800803129395205, 0, 96875049710885773953791899341, 0, 8022390700695158204032815, 0, -7006703647655295554535, 0, 106687622468324331, 0, -7840932369085, 0, 27940379809, 0], [0, -12370583909607752899704971964400389, 0, 1185049326849210503136732085353, 0, 334926758600430895264046121, 0, 33111695571416626953915, 0, -9615576560197871115, 0, -26193217876281, 0, -37487115353, 0, 20596949], [0, -146868508805231148372599489199012429, 0, -39986773812708795760737886002009, 0, -718501964677245201926306727, 0, 1455452294036789810563245, 0, -13979069008262681715, 0, -23769410150578311, 0, 615081057479, 0, 515192467], [0, -361636306388836808583648784537192833, 0, 21053398589594473713522842730141, 0, -1803169386614614640336367363, 0, 51322315211094545556255, 0, -96300953039951192655, 0, -25648690419064557, 0, -3923184692141, 0, 439511153], [0, 59491772755992574410359124796072221801, 0, 59132031186145636229505428318139270, 0, -7577842817073919295320004129661, 0, 1173175902795009552147044010, 0, -91133985746362493381265, 0, 5341402867084775874, 0, 2906961097996085, 0, -315617774114], [0, -16852169989705515576706347509262267, 0, 47389009058756312349490136702559, 0, 3446460383777940257068507263, 0, 396517034323738594366245, 0, 116929110967281142155, 0, -3519056907251343, 0, 1695521995441, 0, 360231947]];
    Rf_basisdens := [1, 1, 1, 205650014751525015049243888872000, 20565001475152501504924388887200, 102825007375762507524621944436000, 19383245667680019896796723, 148630727779770392568637271964000, 319065772307490039453444000, 20565001475152501504924388887200, 68550004917175005016414629624000, 74524702943096140499204040590400, 1684481581504064449111222415592000, 372623514715480702496020202952000, 224878291130792603956348192481532000, 124207838238493567498673400984000];
    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_300_g();"
function MakeCharacter_300_g()
    N := 300;
    order := 2;
    char_gens := [151, 101, 277];
    v := [2, 1, 2];
    // 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_300_g_Hecke();"
function MakeCharacter_300_g_Hecke( : Kf := false)
    N := 300;
    order := 2;
    char_gens := [151, 101, 277];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 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 := 9;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -27, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 47, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0], [3001, 0, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 364, 0, 0, 0, 0, 16, 0, 0, 0, 0, 1, 0, 2, 0, 1], [5, 0, -23, -10, 2, 2, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0], [29381, 0, 8, 1, -1, 1, 0, 0, -5, -1, -5, 0, 0, 0, 0, 0], [0, -421, 0, 0, 0, 0, 6, 74, 0, 0, 0, 2, -53, -1, -6, 1], [35, 0, -122, -141, -26, -7, 0, 0, 0, -4, -7, 0, 0, 0, 0, 0], [0, 3233, 0, 0, 0, 0, -109, 608, 0, 0, 0, -4, -48, 2, 12, -2], [0, -962, 0, 0, 0, 0, -49, 0, 0, 0, 0, 23, 0, 7, 0, -14], [0, 2260, 0, 0, 0, 0, 108, 0, 0, 0, 0, -87, 0, -18, 0, 4], [412, 0, -1591, -176, 123, 1, 0, 0, 0, -59, 1, 0, 0, 0, 0, 0], [1177939, 0, 654, -9, -24, -9, 0, 0, -10, -24, 45, 0, 0, 0, 0, 0], [0, -33697, 0, 0, 0, 0, 1092, 2566, 0, 0, 0, -10, 10, 5, 30, -5], [252, 0, -1050, -452, -566, 42, 0, 0, 0, -42, 42, 0, 0, 0, 0, 0], [0, -57056, 0, 0, 0, 0, 1863, 9782, 0, 0, 0, 34, 272, -17, -102, 17], [5672991, 0, 3019, 26, -122, 26, 0, 0, -57, -122, -130, 0, 0, 0, 0, 0], [0, 23601, 0, 0, 0, 0, 1124, 0, 0, 0, 0, -1428, 0, -11, 0, -77], [618, 0, -2133, 219, 1771, -135, 0, 0, 0, -69, -135, 0, 0, 0, 0, 0], [0, -495104, 0, 0, 0, 0, 16224, 10432, 0, 0, 0, -32, 1868, 16, 96, -16], [-791, 0, 2960, 3687, -3409, 49, 0, 0, 0, 106, 49, 0, 0, 0, 0, 0], [0, -173418, 0, 0, 0, 0, 5523, 22765, 0, 0, 0, -90, -810, 45, 270, -45], [0, 562719, 0, 0, 0, 0, 23978, 0, 0, 0, 0, 3784, 0, 577, 0, -385], [-18933275, 0, -10340, -61, 334, -61, 0, 0, -522, 334, 305, 0, 0, 0, 0, 0], [0, 395105, 0, 0, 0, 0, 17670, 0, 0, 0, 0, -5376, 0, 567, 0, 140], [0, -2386398, 0, 0, 0, 0, 76230, -16657, 0, 0, 0, 312, -4920, -156, -936, 156], [924, 0, -1887, 4900, -8237, -903, 0, 0, 0, -3, -903, 0, 0, 0, 0, 0], [0, 2647821, 0, 0, 0, 0, 114430, 0, 0, 0, 0, 9434, 0, -1177, 0, 220], [-51082015, 0, -18437, -88, 1156, -88, 0, 0, 4141, 1156, 440, 0, 0, 0, 0, 0], [-7020, 0, 28743, -11687, 9324, -897, 0, 0, 0, 1131, -897, 0, 0, 0, 0, 0], [-9805039, 0, 10457, 226, -454, 226, 0, 0, -299, -454, -1130, 0, 0, 0, 0, 0], [0, -6505535, 0, 0, 0, 0, 209514, -19202, 0, 0, 0, -650, -4519, 325, 1950, -325], [0, -2622019, 0, 0, 0, 0, 82794, -194726, 0, 0, 0, -58, -14018, 29, 174, -29], [0, 7122256, 0, 0, 0, 0, 309763, 0, 0, 0, 0, 77, 0, 2561, 0, 626], [0, 2198260, 0, 0, 0, 0, 94900, 0, 0, 0, 0, -6663, 0, -682, 0, -3696], [20240, 0, -77387, 9846, -13657, -367, 0, 0, 0, -2839, -367, 0, 0, 0, 0, 0], [-172383000, 0, -15626, -244, 2074, -244, 0, 0, 13132, 2074, 1220, 0, 0, 0, 0, 0], [29604, 0, -114081, -1919, 18793, -57, 0, 0, 0, -4221, -57, 0, 0, 0, 0, 0], [0, -7802370, 0, 0, 0, 0, 253405, -146698, 0, 0, 0, 1026, 16246, -513, -3078, 513], [0, 12780702, 0, 0, 0, 0, 557844, 0, 0, 0, 0, -17291, 0, -8856, 0, 784], [210969823, 0, 156486, -639, -5961, -639, 0, 0, -2339, -5961, 3195, 0, 0, 0, 0, 0], [17048003, 0, 150181, -628, -8132, -628, 0, 0, -23965, -8132, 3140, 0, 0, 0, 0, 0], [0, -7110290, 0, 0, 0, 0, 233436, 140507, 0, 0, 0, -1436, 27428, 718, 4308, -718], [0, 16025467, 0, 0, 0, 0, 702053, 0, 0, 0, 0, -85050, 0, 13228, 0, -4390], [-151737006, 0, 71052, -264, 600, -264, 0, 0, 28732, 600, 1320, 0, 0, 0, 0, 0], [0, 9135267, 0, 0, 0, 0, 394266, 0, 0, 0, 0, 57190, 0, -7935, 0, 4912], [22136, 0, -90773, 203349, -105635, 2903, 0, 0, 0, -3577, 2903, 0, 0, 0, 0, 0], [-1175449025, 0, -227739, 1470, 7281, 1470, 0, 0, -8424, 7281, -7350, 0, 0, 0, 0, 0], [60736, 0, -232414, 91433, 107630, -998, 0, 0, 0, -8534, -998, 0, 0, 0, 0, 0], [0, 15893651, 0, 0, 0, 0, 693646, 0, 0, 0, 0, -46780, 0, 23177, 0, -1272], [0, -2005544, 0, 0, 0, 0, -97470, 0, 0, 0, 0, 96401, 0, -25728, 0, -8649], [-123248, 0, 466313, -193421, 2944, 4885, 0, 0, 0, 16909, 4885, 0, 0, 0, 0, 0], [-1377612471, 0, 251793, 1194, -2634, 1194, 0, 0, 61817, -2634, -5970, 0, 0, 0, 0, 0], [0, -9199105, 0, 0, 0, 0, 293602, 1585562, 0, 0, 0, 1202, -20905, -601, -3606, 601], [-144111, 0, 548001, -144486, -21729, 4230, 0, 0, 0, 19983, 4230, 0, 0, 0, 0, 0], [0, 6299149, 0, 0, 0, 0, -218187, 337738, 0, 0, 0, 5392, -100660, -2696, -16176, 2696], [0, 6289332, 0, 0, 0, 0, 279588, 0, 0, 0, 0, -63687, 0, 24966, 0, 4848], [0, 39810039, 0, 0, 0, 0, -1274284, -800184, 0, 0, 0, -8538, 52262, 4269, 25614, -4269], [21960, 0, -124962, -102412, 70274, 21678, 0, 0, 0, -6234, 21678, 0, 0, 0, 0, 0], [0, -8212924, 0, 0, 0, 0, 295323, 538238, 0, 0, 0, 3842, 246568, -1921, -11526, 1921], [0, -27722582, 0, 0, 0, 0, -1235072, 0, 0, 0, 0, 285265, 0, 85544, 0, -3500], [-5164394069, 0, 356977, -8656, -15536, -8656, 0, 0, -32373, -15536, 43280, 0, 0, 0, 0, 0], [0, 77351462, 0, 0, 0, 0, -2494729, -272110, 0, 0, 0, 2270, 10242, -1135, -6810, 1135], [0, -85255019, 0, 0, 0, 0, -3709391, 0, 0, 0, 0, 20612, 0, 71606, 0, 6482], [-2301055800, 0, 519064, -11302, -7592, -11302, 0, 0, 89624, -7592, 56510, 0, 0, 0, 0, 0], [0, -4195895, 0, 0, 0, 0, -122502, 0, 0, 0, 0, -615248, 0, 38451, 0, 23288], [168676, 0, -681631, -865207, 46703, 16705, 0, 0, 0, -26483, 16705, 0, 0, 0, 0, 0], [0, 154932886, 0, 0, 0, 0, -4951928, -3102415, 0, 0, 0, 8668, 380700, -4334, -26004, 4334], [0, 50893565, 0, 0, 0, 0, -1714068, -3303990, 0, 0, 0, -24982, -632459, 12491, 74946, -12491], [-2002581491, 0, 1856881, 2474, -51926, 2474, 0, 0, 154925, -51926, -12370, 0, 0, 0, 0, 0], [0, -92262122, 0, 0, 0, 0, -4006965, 0, 0, 0, 0, 78721, 0, -96969, 0, 20300], [323950, 0, -1337446, 265512, 921913, 47344, 0, 0, 0, -53042, 47344, 0, 0, 0, 0, 0], [0, 184211139, 0, 0, 0, 0, -6003837, 4936352, 0, 0, 0, 14280, -435897, -7140, -42840, 7140], [244872, 0, -978843, 1127835, -657997, 18489, 0, 0, 0, -37623, 18489, 0, 0, 0, 0, 0], [-4291945623, 0, 1276122, 1269, -75084, 1269, 0, 0, -248690, -75084, -6345, 0, 0, 0, 0, 0], [298208, 0, -1131704, 1524239, -573552, -9976, 0, 0, 0, -41176, -9976, 0, 0, 0, 0, 0], [-20962449789, 0, 898866, -2037, -39108, -2037, 0, 0, -55066, -39108, 10185, 0, 0, 0, 0, 0], [-347460, 0, 1312758, -214150, 670578, 14778, 0, 0, 0, 47526, 14778, 0, 0, 0, 0, 0], [0, -49720016, 0, 0, 0, 0, 1519742, 2858276, 0, 0, 0, 41380, -533036, -20690, -124140, 20690], [-13813693365, 0, -1434866, 5813, 49927, 5813, 0, 0, -21195, 49927, -29065, 0, 0, 0, 0, 0], [0, -134836007, 0, 0, 0, 0, -5904037, 0, 0, 0, 0, 372262, 0, 334672, 0, 15294], [106217, 0, -157223, -859478, 207925, -135946, 0, 0, 0, 4247, -135946, 0, 0, 0, 0, 0], [0, 125480538, 0, 0, 0, 0, -4000528, 7801892, 0, 0, 0, -59484, 195026, 29742, 178452, -29742], [246095, 0, -1018703, 540660, -877344, 37412, 0, 0, 0, -40501, 37412, 0, 0, 0, 0, 0], [0, 263760356, 0, 0, 0, 0, -8676121, 1037793, 0, 0, 0, -3046, -1308606, 1523, 9138, -1523], [0, -126273411, 0, 0, 0, 0, -5354852, 0, 0, 0, 0, -1538026, 0, 190613, 0, 28297], [-1287228, 0, 4929705, -2399489, -628729, 19017, 0, 0, 0, 181173, 19017, 0, 0, 0, 0, 0], [0, 110590292, 0, 0, 0, 0, -3662792, 15242661, 0, 0, 0, 11768, -705232, -5884, -35304, 5884], [-771324, 0, 3081783, -6092, 2558485, -57441, 0, 0, 0, 118395, -57441, 0, 0, 0, 0, 0], [-26856771439, 0, -3195943, -42722, 122534, -42722, 0, 0, -19471, 122534, 213610, 0, 0, 0, 0, 0], [0, -151734172, 0, 0, 0, 0, -6776079, 0, 0, 0, 0, 2508279, 0, -94881, 0, 100754], [-648571, 0, 2363584, 3863427, -825117, 74333, 0, 0, 0, 82034, 74333, 0, 0, 0, 0, 0], [226638, 0, -1084374, -4482568, 802696, 113184, 0, 0, 0, -48546, 113184, 0, 0, 0, 0, 0], [0, 291506779, 0, 0, 0, 0, -9418646, 18975670, 0, 0, 0, -59006, -287454, 29503, 177018, -29503], [-65853099346, 0, 2901074, 82174, -150382, 82174, 0, 0, -276848, -150382, -410870, 0, 0, 0, 0, 0], [0, -409979249, 0, 0, 0, 0, 13368298, 17912804, 0, 0, 0, 70858, 1313214, -35429, -212574, 35429], [0, 554018908, 0, 0, 0, 0, 24077324, 0, 0, 0, 0, -1070153, 0, 796762, 0, -198000], [0, -205715813, 0, 0, 0, 0, -9222892, 0, 0, 0, 0, 3793202, 0, -637277, 0, 67303], [804419, 0, -2949086, -3628145, 1983290, -82747, 0, 0, 0, -103096, -82747, 0, 0, 0, 0, 0], [-94033581433, 0, -3227097, -20406, 52194, -20406, 0, 0, -633161, 52194, 102030, 0, 0, 0, 0, 0], [0, -987326030, 0, 0, 0, 0, 31858799, 9752594, 0, 0, 0, -59738, -97562, 29869, 179214, -29869], [0, 407942135, 0, 0, 0, 0, 17698403, 0, 0, 0, 0, 709390, 0, -971114, 0, -53900], [0, 727139733, 0, 0, 0, 0, 31526682, 0, 0, 0, 0, -134460, 0, 478647, 0, -227040], [345520, 0, -1065817, 8827131, -2772255, -143717, 0, 0, 0, -28829, -143717, 0, 0, 0, 0, 0], [-88306312745, 0, 8047718, -134069, -271444, -134069, 0, 0, 60818, -271444, 670345, 0, 0, 0, 0, 0], [0, -552828056, 0, 0, 0, 0, 17371927, -42741347, 0, 0, 0, -84542, -3817638, 42271, 253626, -42271], [0, -1131734349, 0, 0, 0, 0, 36456503, -5303776, 0, 0, 0, -52032, -545281, 26016, 156096, -26016], [0, 1110842481, 0, 0, 0, 0, 48447438, 0, 0, 0, 0, -107626, 0, -344829, 0, 361064], [-27027095507, 0, 10031765, 41686, -484534, 41686, 0, 0, -961303, -484534, -208430, 0, 0, 0, 0, 0], [-124206781459, 0, -1625674, -77417, 140981, -77417, 0, 0, 623715, 140981, 387085, 0, 0, 0, 0, 0], [792633, 0, -3725391, -1347278, -6717187, 359742, 0, 0, 0, -164625, 359742, 0, 0, 0, 0, 0], [0, 504548279, 0, 0, 0, 0, -16371257, -49915218, 0, 0, 0, 149984, -308968, -74992, -449952, 74992], [0, 693717052, 0, 0, 0, 0, 30203834, 0, 0, 0, 0, 1285507, 0, 900520, 0, 555333], [0, 1247890152, 0, 0, 0, 0, 54320240, 0, 0, 0, 0, 665037, 0, 788542, 0, 449248], [4786400, 0, -17929811, 2461790, 6031687, -286471, 0, 0, 0, -642847, -286471, 0, 0, 0, 0, 0], [-122443176773, 0, 1105538, 102643, -93844, 102643, 0, 0, -339226, -93844, -513215, 0, 0, 0, 0, 0], [0, -1521881484, 0, 0, 0, 0, 48582910, -35360028, 0, 0, 0, 39180, -3840176, -19590, -117540, 19590], [0, 847664248, 0, 0, 0, 0, 35892036, 0, 0, 0, 0, 8648459, 0, 237222, 0, -576660], [0, -629376065, 0, 0, 0, 0, -27401277, 0, 0, 0, 0, -912352, 0, 2579850, 0, -12270], [-120865759297, 0, 12289247, 136450, -219226, 136450, 0, 0, 2305315, -219226, -682250, 0, 0, 0, 0, 0], [275772, 0, 216054, -1860674, -1720891, -689094, 0, 0, 0, 59046, -689094, 0, 0, 0, 0, 0], [-50840731944, 0, -3115490, -250984, 347170, -250984, 0, 0, 1751388, 347170, 1254920, 0, 0, 0, 0, 0], [-7622132, 0, 29290166, -2286254, 4149242, 58954, 0, 0, 0, 1080454, 58954, 0, 0, 0, 0, 0], [0, 700515788, 0, 0, 0, 0, -22882042, 64589445, 0, 0, 0, -244, -2207580, 122, 732, -122], [0, -1610321549, 0, 0, 0, 0, 52933804, 4880998, 0, 0, 0, -324026, 6725019, 162013, 972078, -162013], [-61851374031, 0, 1584513, 55014, 43566, 55014, 0, 0, 993617, 43566, -275070, 0, 0, 0, 0, 0], [0, -1473034672, 0, 0, 0, 0, -63946245, 0, 0, 0, 0, 458199, 0, -1210347, 0, 247136], [-116032380047, 0, 2509892, -177575, -447781, -177575, 0, 0, -3430165, -447781, 887875, 0, 0, 0, 0, 0], [0, -51900333, 0, 0, 0, 0, 1721692, 84047030, 0, 0, 0, 367398, 1424299, -183699, -1102194, 183699], [-4561646, 0, 17836802, -15122172, 7888692, -130244, 0, 0, 0, 670270, -130244, 0, 0, 0, 0, 0], [-81356111764, 0, -33476527, -25853, 1138583, -25853, 0, 0, -946066, 1138583, 129265, 0, 0, 0, 0, 0], [0, 1180002930, 0, 0, 0, 0, 51065952, 0, 0, 0, 0, 6129939, 0, -2613492, 0, 520044], [0, 2476959629, 0, 0, 0, 0, -79340283, -86367946, 0, 0, 0, -29104, 4269040, 14552, 87312, -14552], [0, -1006353230, 0, 0, 0, 0, -42561088, 0, 0, 0, 0, -13838967, 0, 533632, 0, 37988], [246594, 0, 366840, 7456182, -12188154, -709686, 0, 0, 0, 66156, -709686, 0, 0, 0, 0, 0], [-32016483829, 0, 28271123, 40834, -762574, 40834, 0, 0, 2614987, -762574, -204170, 0, 0, 0, 0, 0], [-7660466, 0, 29639873, 18403677, -6528064, -49733, 0, 0, 0, 1101457, -49733, 0, 0, 0, 0, 0], [0, 3295228666, 0, 0, 0, 0, -105578125, 13800897, 0, 0, 0, 166126, 6054310, -83063, -498378, 83063], [0, -2641617319, 0, 0, 0, 0, -114143674, 0, 0, 0, 0, -7771482, 0, 2871547, 0, 455175], [45829830157, 0, 11097668, 287683, -381394, 287683, 0, 0, 650254, -381394, -1438415, 0, 0, 0, 0, 0], [-4730692, 0, 19425559, 10481915, 20791177, -634633, 0, 0, 0, 766475, -634633, 0, 0, 0, 0, 0], [0, -1379371985, 0, 0, 0, 0, 43397971, 85524688, 0, 0, 0, 385696, -7399845, -192848, -1157088, 192848], [0, -1212802203, 0, 0, 0, 0, -52863310, 0, 0, 0, 0, 8050522, 0, 1112755, 0, 1769984], [97387718033, 0, 73205707, -141040, -2952416, -141040, 0, 0, -2357895, -2952416, 705200, 0, 0, 0, 0, 0], [0, -3085918498, 0, 0, 0, 0, -134743003, 0, 0, 0, 0, 5997061, 0, 1167121, 0, -1166], [0, 3051751065, 0, 0, 0, 0, -97984512, -148597886, 0, 0, 0, -182886, 3032001, 91443, 548658, -91443], [-7896399, 0, 27928350, 5375421, 26127768, 1361871, 0, 0, 0, 933504, 1361871, 0, 0, 0, 0, 0], [0, 4028545413, 0, 0, 0, 0, -128383280, 38787186, 0, 0, 0, -246, 12165226, 123, 738, -123], [0, -3914777376, 0, 0, 0, 0, -169147882, 0, 0, 0, 0, -14467577, 0, -1044128, 0, -700399], [0, 4960653249, 0, 0, 0, 0, -160261554, 4167204, 0, 0, 0, 179622, -1347318, -89811, -538866, 89811], [3578324, 0, -12152600, 16744608, -30461856, -888196, 0, 0, 0, -384304, -888196, 0, 0, 0, 0, 0], [-59504380261, 0, -29060785, -351662, 1577222, -351662, 0, 0, 4039187, 1577222, 1758310, 0, 0, 0, 0, 0], [13792207, 0, -53658319, 5196668, 7632761, 247588, 0, 0, 0, -2005685, 247588, 0, 0, 0, 0, 0], [0, 1843872302, 0, 0, 0, 0, -60657186, 143395384, 0, 0, 0, -247408, -9836414, 123704, 742224, -123704], [6269031, 0, -24634692, 8533629, 36965221, 244539, 0, 0, 0, -930510, 244539, 0, 0, 0, 0, 0], [0, -3186042605, 0, 0, 0, 0, -141395861, 0, 0, 0, 0, 24040802, 0, 4422098, 0, -1694812], [0, 1546937999, 0, 0, 0, 0, 65290502, 0, 0, 0, 0, 27842978, 0, -7555583, 0, 359240], [0, 2170215298, 0, 0, 0, 0, -68364729, -275020127, 0, 0, 0, 928150, 15395606, -464075, -2784450, 464075], [-610452, 0, 5985768, -23684445, 13588776, -1955244, 0, 0, 0, 366528, -1955244, 0, 0, 0, 0, 0], [0, 660787271, 0, 0, 0, 0, 31694090, 0, 0, 0, 0, -36924776, 0, 7317361, 0, 205576], [0, -1659247284, 0, 0, 0, 0, -67237869, 0, 0, 0, 0, -48558389, 0, 4532865, 0, 2524048], [359314775269, 0, -23343987, -166398, 284682, -166398, 0, 0, -5441055, 284682, 831990, 0, 0, 0, 0, 0], [0, 97634193, 0, 0, 0, 0, -3045505, 103592364, 0, 0, 0, -169956, 317261, 84978, 509868, -84978]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_300_g_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_300_9_g_h();".
// 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_300_9_g_h(:prec:=16)
    chi := MakeCharacter_300_g();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 9));
    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_300_9_g_h();".
// 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_300_9_g_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_300_g();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,9,sign)));
    Vf := Kernel([<7,R![2600757082907060397408256, 0, -52166784840953810944, 0, 194864255690496, 0, -28013434, 0, 1]>],Snew);
    return Vf;
end function;