
// Make newform 576.8.d.i in Magma, downloaded from the LMFDB on 02 June 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_576_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_576_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_576_8_d_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_576_8_d_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 := [588393954824749056, 0, -5239065008185344, 0, 42622339324672, 0, -34316449184, 0, 20722017, 0, -5249, 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], [-4085393788398761463907556352, 0, 61049709231532460480331008, 0, -47161064534799234205768, 0, 29680987308188015463, 0, -7518356074154311, 0, 1474281714143, 0], [5428318086749281856584512052039680, 0, -80404380574125542700512892750336, 0, 68982565919119345776702221600, 0, -41738458208301129881747501, 0, 10705480344185803060685, 0, -1999673255631768141, 0], [0, -8779100542273396254246912, 0, 768480148864288066508672, 0, -621052128924014463832, 0, 390861413713745637, 0, -99062097423877, 0, 19414442957], [8119731775856713858240253952, 0, 203163485827920992575488, 0, -1652833667421921151744, 0, 3009311695377269265, 0, -803570331829809, 0, 203548750673, 0], [-26321120463474134816951111799582720, 0, 394373282668268235789780099800576, 0, -294451391038470521387264038240, 0, 187286409829608166590573351, 0, -46519527751603835117575, 0, 9604260463122588551, 0], [21327133176183278430305308672, 0, 3345697871862294045597696, 0, -27218877748138608686848, 0, 40993312833394811541, 0, -13233202502598453, 0, 3352042416341, 0], [0, -2860870723883734588607232, 0, 12186960934887055639408, 0, -9579945685558333427, 0, 5650740344809803, 0, -1430492210747, 0, 272027128], [0, -1640116802408052532210240359999753216, 0, 6989293762092136930457814454013504, 0, -5553526783620737430792344598796, 0, 3068798992103461612961874759, 0, -764753446748271665770471, 0, 136155681553637655419], [0, -7983413548126675773575874751242353664, 0, 34011568429412584698597541720223296, 0, -26826965634337268278720412056124, 0, 15398603035124136986085809421, 0, -3862305610559629033438829, 0, 711329742045550861201], [0, 1336813979487267211161008493751474176, 0, -113825262793854429637226372917818496, 0, 94569046559860696922640551795336, 0, -59517373035960794461984392351, 0, 15227878243750382877030911, 0, -2956282209538850602711], [0, -2278077369488662363445357102127532032, 0, 183047783393500217059202485053642112, 0, -161156008336154788600510699728152, 0, 101424119350278249468131411757, 0, -26146361492277822134319437, 0, 5037828525667763592277]];
    Rf_basisdens := [1, 13354421848115777422341444, 17275992338554469181670083502080, 238257323682196829820641280, 1297273017561887758476288, 51827977015663407545010250506240, 2162121695936479597460480, 59215509021652469555760, 11214278526764169807551592953287680, 44857114107056679230206371813150720, 22428557053528339615103185906575360, 22428557053528339615103185906575360];
    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_576_d();"
function MakeCharacter_576_d()
    N := 576;
    order := 2;
    char_gens := [127, 325, 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_576_d_Hecke();"
function MakeCharacter_576_d_Hecke(Kf)
    N := 576;
    order := 2;
    char_gens := [127, 325, 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]];
    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, 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, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0], [0, 0, 0, 316, 0, 0, 0, 0, 0, 0, -1, 0], [0, 7, 7, 0, 0, 7, 0, 0, 0, 0, 0, 0], [-406, 0, 0, 0, -2, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 177, 0, 0, 0, 0, 0, 0, 6, -1], [0, 0, 0, 0, 0, 0, 0, 86, 2, 6, 0, 0], [0, -129, -161, 0, 0, -42, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -260, -39, 77, 0, 0], [0, 123, -787, 0, 0, -85, 0, 0, 0, 0, 0, 0], [-29722, 0, 0, 0, -96, 0, -1, 0, 0, 0, 0, 0], [0, 0, 0, 23775, 0, 0, 0, 0, 0, 0, 108, 1], [0, 0, 0, 0, 0, 0, 0, 671, -259, -462, 0, 0], [0, 1767, 2177, 0, 0, -462, 0, 0, 0, 0, 0, 0], [0, 0, 0, -210887, 0, 0, 0, 0, 0, 0, 142, 2], [0, -4277, 1899, 0, 0, -231, 0, 0, 0, 0, 0, 0], [0, 0, 0, -54917, 0, 0, 0, 0, 0, 0, 162, -118], [0, 0, 0, 0, 0, 0, 0, 3667, 397, 6, 0, 0], [2233906, 0, 0, 0, -75, 0, 35, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -6779, -1599, 3289, 0, 0], [0, 0, 0, -100476, 0, 0, 0, 0, 0, 0, -765, -126], [-3780630, 0, 0, 0, 68, 0, -62, 0, 0, 0, 0, 0], [6867678, 0, 0, 0, 1626, 0, -28, 0, 0, 0, 0, 0], [0, 14106, 26513, 0, 0, -462, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -25577, 3594, 1869, 0, 0], [0, 0, 0, -3998735, 0, 0, 0, 0, 0, 0, -578, 128], [0, -16387, 15067, 0, 0, 8575, 0, 0, 0, 0, 0, 0], [-1594746, 0, 0, 0, 886, 0, -352, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -18100, 14577, -15653, 0, 0], [0, 0, 0, -302913, 0, 0, 0, 0, 0, 0, 1216, 700], [3392774, 0, 0, 0, -3540, 0, 413, 0, 0, 0, 0, 0], [0, 0, 0, 4595983, 0, 0, 0, 0, 0, 0, -810, -222], [0, -27780, 31245, 0, 0, -64416, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 24163, -32802, 6567, 0, 0], [0, -56063, -113017, 0, 0, -6055, 0, 0, 0, 0, 0, 0], [0, 0, 0, -13143877, 0, 0, 0, 0, 0, 0, 7056, 1459], [0, 0, 0, 0, 0, 0, 0, -51650, -60938, 37044, 0, 0], [0, -120393, 76603, 0, 0, 46872, 0, 0, 0, 0, 0, 0], [0, 0, 0, 929409, 0, 0, 0, 0, 0, 0, 8210, -574], [0, 52515, 24433, 0, 0, 14317, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 6067, 61375, -85560, 0, 0], [15898370, 0, 0, 0, -2535, 0, 2871, 0, 0, 0, 0, 0], [0, -326391, -160287, 0, 0, 50622, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 159857, -60060, -27859, 0, 0], [0, 0, 0, -16136309, 0, 0, 0, 0, 0, 0, 8238, -5410], [0, 0, 0, 0, 0, 0, 0, 280241, 30927, 29875, 0, 0], [0, 0, 0, -9829318, 0, 0, 0, 0, 0, 0, -40683, -1138], [0, 114535, 29333, 0, 0, -137251, 0, 0, 0, 0, 0, 0], [290588578, 0, 0, 0, 3562, 0, -156, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 261997, -18797, 65220, 0, 0], [85880426, 0, 0, 0, 26151, 0, -789, 0, 0, 0, 0, 0], [0, 0, 0, 4192492, 0, 0, 0, 0, 0, 0, 347, 1584], [-113709650, 0, 0, 0, -30116, 0, 3720, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 231813, -225345, -232212, 0, 0], [0, -371004, 192447, 0, 0, 63294, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 785647, 367917, -182373, 0, 0], [0, -700817, -637507, 0, 0, 237497, 0, 0, 0, 0, 0, 0], [301514034, 0, 0, 0, -26954, 0, -3370, 0, 0, 0, 0, 0], [0, 0, 0, -30041795, 0, 0, 0, 0, 0, 0, -26928, 6504], [0, -149487, -50887, 0, 0, 321594, 0, 0, 0, 0, 0, 0], [0, 0, 0, -11404661, 0, 0, 0, 0, 0, 0, 153042, 11978], [0, 0, 0, 0, 0, 0, 0, 1526041, 377083, -276264, 0, 0], [-78413866, 0, 0, 0, 35691, 0, -21803, 0, 0, 0, 0, 0], [0, -326484, 57411, 0, 0, -639630, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2984823, 0, 0, 0, 0, 0, 0, -69762, -9424], [767640374, 0, 0, 0, 45471, 0, -11951, 0, 0, 0, 0, 0], [0, 0, 0, -115956326, 0, 0, 0, 0, 0, 0, -78503, -22306], [0, -1544535, -750961, 0, 0, -288451, 0, 0, 0, 0, 0, 0], [-527534042, 0, 0, 0, 195890, 0, 1880, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2545141, -164675, 124230, 0, 0], [0, 0, 0, 0, 0, 0, 0, -915686, -135723, 830085, 0, 0], [0, -670445, 1026253, 0, 0, 61159, 0, 0, 0, 0, 0, 0], [0, 0, 0, 158594101, 0, 0, 0, 0, 0, 0, -76842, -27091], [0, 0, 0, 0, 0, 0, 0, 2074753, -372557, -599016, 0, 0], [0, -852177, -3730615, 0, 0, 582384, 0, 0, 0, 0, 0, 0], [0, -821489, -1640473, 0, 0, -376339, 0, 0, 0, 0, 0, 0], [-118382710, 0, 0, 0, 197122, 0, 37387, 0, 0, 0, 0, 0], [-574997414, 0, 0, 0, -2346, 0, 1112, 0, 0, 0, 0, 0], [0, 0, 0, 37595070, 0, 0, 0, 0, 0, 0, 131389, -39002], [0, -400875, -2888707, 0, 0, 1639553, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -1701419, 936781, -312234, 0, 0], [89091358, 0, 0, 0, -295146, 0, 16182, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2275173, -551238, 1513569, 0, 0], [0, 0, 0, -33920710, 0, 0, 0, 0, 0, 0, 199917, 53114], [-2008587638, 0, 0, 0, -123246, 0, -24155, 0, 0, 0, 0, 0], [-1810559046, 0, 0, 0, 121014, 0, -51812, 0, 0, 0, 0, 0], [0, 548937, -908505, 0, 0, 1096200, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 906514, -710673, -28601, 0, 0], [0, 0, 0, 326496554, 0, 0, 0, 0, 0, 0, -215943, 97214], [0, 0, 0, 0, 0, 0, 0, -4370370, -150306, -1433682, 0, 0], [0, 0, 0, 0, 0, 0, 0, 4890034, 934626, 568651, 0, 0], [0, 0, 0, 236329763, 0, 0, 0, 0, 0, 0, 664048, -38190], [0, 0, 0, -120478931, 0, 0, 0, 0, 0, 0, -219024, 19328], [0, 0, 0, 0, 0, 0, 0, -2101111, 1438529, -793410, 0, 0], [0, -3496299, -7116901, 0, 0, -1681158, 0, 0, 0, 0, 0, 0], [984978446, 0, 0, 0, -519538, 0, -88971, 0, 0, 0, 0, 0], [0, 0, 0, 322017925, 0, 0, 0, 0, 0, 0, -10374, 33281], [0, 3811203, 3815615, 0, 0, 543971, 0, 0, 0, 0, 0, 0], [0, 0, 0, -102719761, 0, 0, 0, 0, 0, 0, -484116, 19009], [0, 3467592, -910329, 0, 0, 2988540, 0, 0, 0, 0, 0, 0], [0, 0, 0, -560840122, 0, 0, 0, 0, 0, 0, -128719, 47632], [-881772794, 0, 0, 0, 841052, 0, 94211, 0, 0, 0, 0, 0], [0, 0, 0, 280409957, 0, 0, 0, 0, 0, 0, -177948, -31382], [987189374, 0, 0, 0, -487071, 0, -132377, 0, 0, 0, 0, 0], [0, 0, 0, 924176575, 0, 0, 0, 0, 0, 0, 59832, 50146], [1326866502, 0, 0, 0, 761398, 0, -147232, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -8840590, -2779564, 3116154, 0, 0], [2071807658, 0, 0, 0, -315765, 0, 10953, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -6316512, -3586617, 5119859, 0, 0], [0, 1738897, -11030547, 0, 0, -36873, 0, 0, 0, 0, 0, 0], [-1916104766, 0, 0, 0, 1652422, 0, 45510, 0, 0, 0, 0, 0], [0, 0, 0, -2908835, 0, 0, 0, 0, 0, 0, 707280, -158844], [0, 0, 0, 0, 0, 0, 0, -3019530, 2886294, -1840829, 0, 0], [-7067576030, 0, 0, 0, -888764, 0, 103587, 0, 0, 0, 0, 0], [0, 0, 0, 478010207, 0, 0, 0, 0, 0, 0, 320268, -70451], [0, 0, 0, 0, 0, 0, 0, -3233396, 4676698, -1953474, 0, 0], [0, 13757547, -2472297, 0, 0, -639156, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1475541225, 0, 0, 0, 0, 0, 0, 117208, -285014], [0, -9058601, 18652857, 0, 0, -116265, 0, 0, 0, 0, 0, 0], [772310718, 0, 0, 0, 610818, 0, 233078, 0, 0, 0, 0, 0], [0, 17345130, -19735163, 0, 0, -2201244, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1533260756, 0, 0, 0, 0, 0, 0, 123271, -50958], [0, 0, 0, 867881863, 0, 0, 0, 0, 0, 0, 1753428, -50241], [0, 21169668, 23670879, 0, 0, -2613126, 0, 0, 0, 0, 0, 0], [0, -8637935, 2498233, 0, 0, -11048135, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 7548342, 1745958, 7888002, 0, 0], [0, 0, 0, 0, 0, 0, 0, -9639843, -4531110, 7561755, 0, 0], [0, 19268867, 6561979, 0, 0, -7836941, 0, 0, 0, 0, 0, 0], [0, 0, 0, -565468971, 0, 0, 0, 0, 0, 0, -1486236, -31994], [0, 0, 0, 0, 0, 0, 0, 8878462, 1384882, -6661008, 0, 0], [0, 0, 0, 0, 0, 0, 0, -2371431, -5073879, 6707957, 0, 0], [0, 9696335, 23654433, 0, 0, 11653737, 0, 0, 0, 0, 0, 0], [-5400502578, 0, 0, 0, 180870, 0, 102135, 0, 0, 0, 0, 0], [-8684733294, 0, 0, 0, 1111533, 0, -114593, 0, 0, 0, 0, 0], [0, -13545858, -48276151, 0, 0, 12147006, 0, 0, 0, 0, 0, 0], [0, 0, 0, -104131063, 0, 0, 0, 0, 0, 0, -1494330, -203495], [0, 2625546, -11901125, 0, 0, 17202588, 0, 0, 0, 0, 0, 0], [-13554431818, 0, 0, 0, -1826248, 0, -58923, 0, 0, 0, 0, 0], [0, 0, 0, -346042195, 0, 0, 0, 0, 0, 0, -2176986, 377499], [0, -2414748, 42760933, 0, 0, -2978322, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 14544194, 6283836, 1419767, 0, 0], [0, 0, 0, 1927408737, 0, 0, 0, 0, 0, 0, -382954, -432016], [0, -353779, -12087085, 0, 0, 15360935, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -19517701, -8925331, 3128706, 0, 0], [0, 22679495, 17000229, 0, 0, 2381139, 0, 0, 0, 0, 0, 0], [-2743051818, 0, 0, 0, 4883936, 0, -95717, 0, 0, 0, 0, 0], [0, 0, 0, 2924099383, 0, 0, 0, 0, 0, 0, -1666752, -104845], [0, 0, 0, 0, 0, 0, 0, -11623211, -1469843, -3765024, 0, 0], [0, 1939281, 43831739, 0, 0, -11812087, 0, 0, 0, 0, 0, 0], [13837076478, 0, 0, 0, -757276, 0, 233428, 0, 0, 0, 0, 0], [0, 0, 0, -595353733, 0, 0, 0, 0, 0, 0, -4144500, -169973], [0, 0, 0, 0, 0, 0, 0, -13019283, -8787453, 10711740, 0, 0], [0, 0, 0, -882545637, 0, 0, 0, 0, 0, 0, -526188, -327509], [0, 0, 0, 0, 0, 0, 0, -18534505, -12182077, -12045300, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1806468, -23666310, -436857, 0, 0], [25635367146, 0, 0, 0, 970766, 0, 261559, 0, 0, 0, 0, 0], [16050263734, 0, 0, 0, 4305096, 0, 474048, 0, 0, 0, 0, 0], [0, -32985873, 20761063, 0, 0, -22379112, 0, 0, 0, 0, 0, 0], [0, 0, 0, -7783602115, 0, 0, 0, 0, 0, 0, -2057366, 17706], [16696109470, 0, 0, 0, -1160034, 0, 270229, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -2844268, 25933662, -25557171, 0, 0], [0, 0, 0, 1328166168, 0, 0, 0, 0, 0, 0, 7568675, -463690], [3043968602, 0, 0, 0, -4059298, 0, -408537, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 73405017, 31075203, -15476676, 0, 0], [0, 0, 0, 0, 0, 0, 0, 27646249, -8214981, 8129229, 0, 0], [0, -34660863, -85910955, 0, 0, 29823183, 0, 0, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_576_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_576_8_d_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_576_8_d_i(:prec:=12)
    chi := MakeCharacter_576_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_576_8_d_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_576_8_d_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_576_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<5,R![438547825080000, 0, 31228398000, 0, 344868, 0, 1]>,<7,R![-67551007232426688, 0, 3800122919856, 0, -4082148, 0, 1]>],Snew);
    return Vf;
end function;