
// Make newform 72.8.d.c in Magma, downloaded from the LMFDB on 20 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_72_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_72_d_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_72_8_d_c();".
// 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_72_8_d_c();".
// 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 := [4398046511104, 0, -55297703936, 0, 398721024, 0, -1510912, 0, 24336, 0, -206, 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, -55297703936, 0, 398721024, 0, -1510912, 0, 24336, 0, -206, 0, 1], [0, 601832292352, 0, 3588489216, 0, -13598208, 0, 219024, 0, -1854, 0, 9], [46170898432, 0, -398721024, 0, 1510912, 0, -24336, 0, 206, 0, -1, 0], [-27648851968, 0, 1748762624, 0, 1510912, 0, -24336, 0, 206, 0, -1, 0], [0, -17613124009984, 0, 87565795328, 0, -265594368, 0, 1857616, 0, -68454, 0, 213], [0, 17324287459328, 0, 26052132864, 0, 1293400576, 0, -756912, 0, 50938, 0, 389], [0, 65983045697536, 0, -88403607552, 0, 1372114432, 0, -12419344, 0, 316046, 0, -1057], [1105417207808, 0, -13230145536, 0, 35419648, 0, -251344, 0, 5174, 0, -45, 0], [137610919936, 0, 355729408, 0, 10163712, 0, -6864, 0, 406, 0, 3, 0], [-11655199064064, 0, 23408672768, 0, -96050688, 0, 722576, 0, -43614, 0, -7, 0], [0, 74103755112448, 0, -1392377593856, 0, 3397302784, 0, -23549104, 0, 378362, 0, -4859]];
    Rf_basisdens := [1, 34359738368, 34359738368, 268435456, 134217728, 171798691840, 171798691840, 171798691840, 268435456, 20971520, 1342177280, 34359738368];
    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_72_d();"
function MakeCharacter_72_d()
    N := 72;
    order := 2;
    char_gens := [55, 37, 65];
    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_72_d_Hecke();"
function MakeCharacter_72_d_Hecke(Kf)
    N := 72;
    order := 2;
    char_gens := [55, 37, 65];
    char_values := [[1, 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]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+1)]];
    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 := 8;
    raw_aps := [[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, -3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [12, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0], [0, -21, -2, 0, 0, -10, 2, 1, 0, 0, 0, 0], [-3, 0, 0, 8, -1, 0, 0, 0, 0, -1, 2, 0], [0, -49, 1, 0, 0, 0, -4, 2, 0, 0, 0, -2], [-6, 0, 0, 16, 6, 0, 0, 0, 0, -2, -12, 0], [0, -830, 14, 0, 0, 0, -24, 12, 0, 0, 0, 4], [0, 2573, 160, 0, 0, 329, 48, 24, 0, 0, 0, 0], [-3292, 0, 0, 621, 48, 0, 0, 0, -51, 0, 0, 0], [429, 0, 0, -1272, 15, 0, 0, 0, 0, 15, 98, 0], [0, -1637, -11, 0, 0, 0, -212, 106, 0, 0, 0, 22], [870, 0, 0, -2576, 154, 0, 0, 0, 0, 34, -52, 0], [0, -14554, 330, 0, 0, 0, -200, 100, 0, 0, 0, -52], [0, -11897, -608, 0, 0, -949, 304, 152, 0, 0, 0, 0], [0, 15386, 644, 0, 0, -108, -100, -50, 0, 0, 0, 0], [3195, 0, 0, -9672, 937, 0, 0, 0, 0, -87, -722, 0], [4644, 0, 0, -14176, 476, 0, 0, 0, 0, -244, 840, 0], [0, -94336, 2432, 0, 0, 0, 1024, -512, 0, 0, 0, 256], [1129566, 0, 0, 17832, 1400, 0, 0, 0, -1768, 0, 0, 0], [1699428, 0, 0, 19085, 1344, 0, 0, 0, 269, 0, 0, 0], [0, 87779, 2030, 0, 0, -12378, -1582, -791, 0, 0, 0, 0], [0, 433994, -10218, 0, 0, 0, 1704, -852, 0, 0, 0, -44], [2277442, 0, 0, 20304, 880, 0, 0, 0, 7984, 0, 0, 0], [0, -503605, -25344, 0, 0, -29849, 4096, 2048, 0, 0, 0, 0], [-220844, 0, 0, 34057, 2640, 0, 0, 0, -2903, 0, 0, 0], [0, 549914, 27844, 0, 0, 29396, 924, 462, 0, 0, 0, 0], [5097, 0, 0, -15128, -861, 0, 0, 0, 0, 163, 3258, 0], [0, 1054706, -27026, 0, 0, 0, -5048, 2524, 0, 0, 0, 804], [-2506852, 0, 0, -58589, -4240, 0, 0, 0, 771, 0, 0, 0], [0, 1813388, 77624, 0, 0, -16872, 9032, 4516, 0, 0, 0, 0], [0, 2473065, -60857, 0, 0, 0, -4380, 2190, 0, 0, 0, -1166], [-44340, 0, 0, 133088, -8908, 0, 0, 0, 0, 68, 2968, 0], [0, -1639699, -69632, 0, 0, 2801, 11904, 5952, 0, 0, 0, 0], [-7092916, 0, 0, -229345, -17264, 0, 0, 0, 12351, 0, 0, 0], [-68169, 0, 0, 207128, -12739, 0, 0, 0, 0, 2621, 134, 0], [-46758, 0, 0, 146192, -14682, 0, 0, 0, 0, 5918, 7860, 0], [0, -4021774, 100190, 0, 0, 0, 4008, -2004, 0, 0, 0, -3996], [0, -3796821, -187808, 0, 0, -159601, -17584, -8792, 0, 0, 0, 0], [0, 2408234, 57572, 0, 0, -342156, -23044, -11522, 0, 0, 0, 0], [-41037, 0, 0, 126712, -12783, 0, 0, 0, 0, 3601, 8286, 0], [0, -3087534, 85758, 0, 0, 0, 43816, -21908, 0, 0, 0, -4316], [6661274, 0, 0, -231352, -25640, 0, 0, 0, 127608, 0, 0, 0], [0, -2640633, -114592, 0, 0, 42459, -48944, -24472, 0, 0, 0, 0], [-8103212, 0, 0, 128553, 10768, 0, 0, 0, -22199, 0, 0, 0], [27924, 0, 0, -80096, 41708, 0, 0, 0, 0, 3676, -77784, 0], [45108924, 0, 0, 165883, 12640, 0, 0, 0, -11077, 0, 0, 0], [0, 1063233, -58758, 0, 0, -811934, 8454, 4227, 0, 0, 0, 0], [176583, 0, 0, -529128, -403, 0, 0, 0, 0, 621, 59046, 0], [0, -2607362, 65570, 0, 0, 0, -21896, 10948, 0, 0, 0, -20548], [0, 869438, -45326, 0, 0, 0, -121832, 60916, 0, 0, 0, -3588], [19126230, 0, 0, 1051576, 75304, 0, 0, 0, -2680, 0, 0, 0], [0, -6765989, -199010, 0, 0, 645398, 101026, 50513, 0, 0, 0, 0], [0, -14544856, 322264, 0, 0, 0, -152672, 76336, 0, 0, 0, 2640], [0, 12665176, -304536, 0, 0, 0, 27616, -13808, 0, 0, 0, 4272], [0, 9567273, 414016, 0, 0, -90355, 90464, 45232, 0, 0, 0, 0], [135066844, 0, 0, 948067, 56736, 0, 0, 0, 153763, 0, 0, 0], [260679, 0, 0, -779240, 110317, 0, 0, 0, 0, 2797, -136538, 0], [0, -17469368, 435896, 0, 0, 0, 92192, -46096, 0, 0, 0, 29328], [151800, 0, 0, -446016, 74504, 0, 0, 0, 0, 9384, -107792, 0], [0, 18095271, 794464, 0, 0, -8773, 81488, 40744, 0, 0, 0, 0], [-38268, 0, 0, 50592, 53628, 0, 0, 0, 0, -64212, -55800, 0], [0, 31413908, -770676, 0, 0, 0, -44272, 22136, 0, 0, 0, -14808], [-37857266, 0, 0, -52072, -30520, 0, 0, 0, 375208, 0, 0, 0], [0, 7658777, 182976, 0, 0, -877283, -327392, -163696, 0, 0, 0, 0], [-404184, 0, 0, 1274432, -58664, 0, 0, 0, 0, 61880, -79280, 0], [-84518582, 0, 0, -4428744, -291800, 0, 0, 0, -343544, 0, 0, 0], [0, -21915591, -1045974, 0, 0, -1029422, 378582, 189291, 0, 0, 0, 0], [-495129, 0, 0, 1608472, -128819, 0, 0, 0, 0, 123085, -30490, 0], [0, -19067506, 555666, 0, 0, 0, 347320, -173660, 0, 0, 0, -58660], [0, 36655072, -889824, 0, 0, 0, -10368, 5184, 0, 0, 0, -20032], [-61842812, 0, 0, -2663099, -235440, 0, 0, 0, 633061, 0, 0, 0], [-1544811, 0, 0, 4690888, -286585, 0, 0, 0, 0, 56455, 1778, 0], [-173274, 0, 0, 534000, -81702, 0, 0, 0, 0, 14178, 91468, 0], [0, 7188690, -278146, 0, 0, 0, -401112, 200556, 0, 0, 0, 61988], [0, 5515641, -57376, 0, 0, -2582763, 365200, 182600, 0, 0, 0, 0], [-697497, 0, 0, 1906840, 65229, 0, 0, 0, 0, -185651, -177306, 0], [0, -17068515, 283475, 0, 0, 0, -568140, 284070, 0, 0, 0, 47450], [-392959834, 0, 0, -2728304, -230608, 0, 0, 0, 500208, 0, 0, 0], [0, 30251461, 2026018, 0, 0, 4686506, 914974, 457487, 0, 0, 0, 0], [-871233, 0, 0, 2564568, -140267, 0, 0, 0, 0, -49131, 39254, 0], [0, -27160762, 710954, 0, 0, 0, -20552, 10276, 0, 0, 0, -166388], [440209646, 0, 0, 4456272, 359280, 0, 0, 0, -573648, 0, 0, 0], [-530261388, 0, 0, 2132241, 117488, 0, 0, 0, 487409, 0, 0, 0], [0, 30494617, 51178, 0, 0, -10152046, 455446, 227723, 0, 0, 0, 0], [0, 46773431, -1210087, 0, 0, 0, -266084, 133042, 0, 0, 0, 44494], [369771958, 0, 0, -494224, -63280, 0, 0, 0, 391696, 0, 0, 0], [0, -92947173, -4261472, 0, 0, -1430161, -310480, -155240, 0, 0, 0, 0], [502964604, 0, 0, 3732923, 152880, 0, 0, 0, 1592603, 0, 0, 0], [0, 19470869, 1613058, 0, 0, 6385930, -611330, -305665, 0, 0, 0, 0], [0, -148918744, 3622168, 0, 0, 0, 31776, -15888, 0, 0, 0, 52304], [-58313588, 0, 0, 15665759, 1225280, 0, 0, 0, -1488161, 0, 0, 0], [0, 81958700, 2685176, 0, 0, -5613864, -1343224, -671612, 0, 0, 0, 0], [1404072, 0, 0, -3897024, 124760, 0, 0, 0, 0, 315192, -96688, 0], [0, -90315020, 2362156, 0, 0, 0, 1071248, -535624, 0, 0, 0, 197864], [0, -79618979, -4007072, 0, 0, -4417879, 283984, 141992, 0, 0, 0, 0], [0, 130028535, -3131175, 0, 0, 0, 563100, -281550, 0, 0, 0, 241230], [7665750, 0, 0, -22983568, 1415082, 0, 0, 0, 0, 13682, -288596, 0], [6709749, 0, 0, -20030904, 1139751, 0, 0, 0, 0, 98343, -141262, 0], [-2095026, 0, 0, 5746224, 277426, 0, 0, 0, 0, -538854, -714340, 0], [0, -77847785, -3916160, 0, 0, -5387965, 1576000, 788000, 0, 0, 0, 0], [0, 13108081, 1472794, 0, 0, 7628162, -847322, -423661, 0, 0, 0, 0], [0, 136819863, -3834311, 0, 0, 0, -2321892, 1160946, 0, 0, 0, 50062], [-5505252, 0, 0, 16547680, -1628956, 0, 0, 0, 0, 31924, 1390904, 0], [817101478, 0, 0, 14505736, 871320, 0, 0, 0, 2307256, 0, 0, 0], [0, 184084840, 8786192, 0, 0, 5769552, 275568, 137784, 0, 0, 0, 0], [0, -19310058, 596490, 0, 0, 0, -72744, 36372, 0, 0, 0, -443412], [0, -48918986, 955322, 0, 0, 0, -1391496, 695748, 0, 0, 0, -159764], [-706279022, 0, 0, -20939944, -1266808, 0, 0, 0, -3204632, 0, 0, 0], [1517116188, 0, 0, -37756189, -2345520, 0, 0, 0, -4918909, 0, 0, 0], [7000365, 0, 0, -20509560, 476175, 0, 0, 0, 0, 491535, 889570, 0], [0, -47854852, 1216836, 0, 0, 0, 576752, -288376, 0, 0, 0, 220536], [-5115960, 0, 0, 15987008, 14392, 0, 0, 0, 0, 639128, -2373232, 0], [-4354330772, 0, 0, 14352183, 898816, 0, 0, 0, 1768759, 0, 0, 0], [0, 18208487, -638359, 0, 0, 0, -675748, 337874, 0, 0, 0, 170798], [-11549730, 0, 0, 34773936, -1829854, 0, 0, 0, 0, 124746, -314948, 0], [0, 281805126, -7132374, 0, 0, 0, -847944, 423972, 0, 0, 0, 262668], [0, 11048339, 1072480, 0, 0, 8123927, -4301232, -2150616, 0, 0, 0, 0], [0, 124835464, 6781456, 0, 0, 8406608, 2367280, 1183640, 0, 0, 0, 0], [-16458951, 0, 0, 49400424, -3654637, 0, 0, 0, 0, 23571, 1799386, 0], [91321374, 0, 0, -29116592, -2410640, 0, 0, 0, 4632368, 0, 0, 0], [0, 112537069, 635968, 0, 0, -34432735, 2155360, 1077680, 0, 0, 0, 0], [0, -481618805, -22796866, 0, 0, -12612426, -1948734, -974367, 0, 0, 0, 0], [-14194662, 0, 0, 41701136, -1314842, 0, 0, 0, 0, -882850, -1219020, 0], [0, 241028785, 6848064, 0, 0, -25793291, -2457376, -1228688, 0, 0, 0, 0], [-5125605, 0, 0, 15444024, -1317239, 0, 0, 0, 0, 67209, 858734, 0], [0, 667648084, -16583988, 0, 0, 0, -2071536, 1035768, 0, 0, 0, -408664], [-8226692788, 0, 0, -4827841, -597200, 0, 0, 0, 3532959, 0, 0, 0], [-8359311, 0, 0, 24171176, -814597, 0, 0, 0, 0, -906757, -250486, 0], [16879236, 0, 0, -50320992, 2698620, 0, 0, 0, 0, 316716, -87544, 0], [0, 770668122, -17278410, 0, 0, 0, 7535816, -3767908, 0, 0, 0, 138548], [7387133668, 0, 0, -13470739, -1816192, 0, 0, 0, 11955949, 0, 0, 0], [15995835, 0, 0, -48416200, 2315625, 0, 0, 0, 0, -428695, 1129390, 0], [0, -452229543, 11699671, 0, 0, 0, 3776932, -1888466, 0, 0, 0, 357458], [-928494566, 0, 0, -1077816, 189016, 0, 0, 0, -3724040, 0, 0, 0], [0, 616504651, 22116480, 0, 0, -33976697, -2358208, -1179104, 0, 0, 0, 0], [5136102, 0, 0, -13582864, 1664282, 0, 0, 0, 0, 1825442, -3441972, 0], [0, 393952239, 16652864, 0, 0, 926091, -5485856, -2742928, 0, 0, 0, 0], [0, -1008588683, 23302651, 0, 0, 0, -6997228, 3498614, 0, 0, 0, -484342], [20526378, 0, 0, -62455152, 2842326, 0, 0, 0, 0, -876018, 2033492, 0], [0, -261287725, -2558016, 0, 0, 63730399, 4504864, 2252432, 0, 0, 0, 0], [-13574262484, 0, 0, 57044487, 3822240, 0, 0, 0, 3533127, 0, 0, 0], [0, -427689026, -10568084, 0, 0, 62152988, -734348, -367174, 0, 0, 0, 0], [22806129, 0, 0, -70011096, 2250363, 0, 0, 0, 0, -1592709, 4694026, 0], [0, -772177080, 16803320, 0, 0, 0, -9927520, 4963760, 0, 0, 0, -87920], [19598517, 0, 0, -59459384, 4113127, 0, 0, 0, 0, -663833, -1029582, 0], [0, 564564175, -14979583, 0, 0, 0, -5282308, 2641154, 0, 0, 0, 361470], [-15848742, 0, 0, 44428560, 1326374, 0, 0, 0, 0, -3117666, -4817996, 0], [0, 633387206, -14700886, 0, 0, 0, 2105272, -1052636, 0, 0, 0, -981236], [-3387165, 0, 0, 11108728, -4188127, 0, 0, 0, 0, 947233, 6299966, 0], [0, -309757936, 7420272, 0, 0, 0, 1898304, -949152, 0, 0, 0, 1666336], [19477770, 0, 0, -60063344, 9039606, 0, 0, 0, 0, -1630034, -9956588, 0], [0, -89608860, 2521148, 0, 0, 0, 739152, -369576, 0, 0, 0, -575032], [808338, 0, 0, 18384, -435602, 0, 0, 0, 0, 2443398, -1302748, 0], [0, -1512029522, 38610434, 0, 0, 0, 8494808, -4247404, 0, 0, 0, 92892], [-23528316948, 0, 0, 99255, 10976, 0, 0, 0, -54409, 0, 0, 0], [0, 1734949961, -43510297, 0, 0, 0, -5352604, 2676302, 0, 0, 0, 267314], [-3761789418, 0, 0, 9862624, -552800, 0, 0, 0, 17601824, 0, 0, 0], [0, -624261037, -23310368, 0, 0, 32484791, -3732720, -1866360, 0, 0, 0, 0], [0, 983877038, 32536972, 0, 0, -77616964, -1070316, -535158, 0, 0, 0, 0], [0, 393218483, -7160227, 0, 0, 0, 15370636, -7685318, 0, 0, 0, 2384710], [-39089612428, 0, 0, -48093951, -2897760, 0, 0, 0, -7525311, 0, 0, 0], [0, -270978233, -19106282, 0, 0, -54299026, -2227670, -1113835, 0, 0, 0, 0], [0, 1015155453, -23013389, 0, 0, 0, 5624116, -2812058, 0, 0, 0, -1830886], [0, -2417333828, 60932772, 0, 0, 0, 8515888, -4257944, 0, 0, 0, -655752], [24313366148, 0, 0, -104939691, -7496736, 0, 0, 0, 14613, 0, 0, 0], [-26009307, 0, 0, 81048776, -4515785, 0, 0, 0, 0, 3020855, -2659054, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_72_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_72_8_d_c();".
// 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_72_8_d_c(:prec:=12)
    chi := MakeCharacter_72_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_72_8_d_c();".
// 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_72_8_d_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_72_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<5,R![144921907520000, 0, 9140446400, 0, 176920, 0, 1]>],Snew);
    return Vf;
end function;