
// Make newform 1728.4.d.f in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1728_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1728_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_1728_4_d_f();".
// 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_1728_4_d_f();".
// 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 := [81, 0, -63, 0, 40, 0, -7, 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, -207, 0, 76, 0, -16, 0, 1], [-261, 0, 280, 0, -40, 0, 7, 0], [0, -81, 0, 190, 0, -40, 0, 7], [231, 0, 0, 0, 0, 0, 3, 0], [0, 1719, 0, -610, 0, 100, 0, -13], [126, 0, -124, 0, 28, 0, -4, 0], [0, -81, 0, 244, 0, -40, 0, 7]];
    Rf_basisdens := [1, 108, 180, 270, 10, 135, 9, 18];
    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_1728_d();"
function MakeCharacter_1728_d()
    N := 1728;
    order := 2;
    char_gens := [703, 325, 1217];
    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_1728_d_Hecke();"
function MakeCharacter_1728_d_Hecke(Kf)
    N := 1728;
    order := 2;
    char_gens := [703, 325, 1217];
    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 := 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 := 4;
    raw_aps := [[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, 7, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -1], [0, 0, -9, 0, 0, 0, 0, 0], [0, 0, 0, 0, -3, 0, 0, 0], [0, 0, 0, 49, 0, 0, 0, 0], [0, 0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0], [0, 14, 0, 0, 0, 0, 0, 0], [0, 0, -59, 0, 0, 0, 0, 0], [0, 0, 0, 0, -16, 0, 0, 0], [0, 0, 0, 260, 0, 0, 0, 0], [0, 0, 0, 0, 0, 29, 0, 0], [0, 0, 0, 0, 0, 0, 46, 0], [0, 0, 0, 0, 0, 0, 0, -15], [0, 0, -101, 0, 0, 0, 0, 0], [0, 0, 0, -241, 0, 0, 0, 0], [0, 0, 0, 0, 0, -20, 0, 0], [353, 0, 0, 0, 0, 0, 0, 0], [0, -3, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -48], [0, 0, 0, 0, -37, 0, 0, 0], [1111, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2, 0], [0, -899, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 81], [0, 0, 40, 0, 0, 0, 0, 0], [0, 0, 0, 0, 13, 0, 0, 0], [0, -650, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 62], [0, 0, 0, 0, 143, 0, 0, 0], [0, 0, 0, -233, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 96, 0], [0, -1241, 0, 0, 0, 0, 0, 0], [0, 0, -1768, 0, 0, 0, 0, 0], [0, 0, 0, 2095, 0, 0, 0, 0], [0, 0, 0, 0, 0, -23, 0, 0], [0, 0, 0, 0, 0, 0, -340, 0], [0, 0, 0, 0, 0, 0, 0, 124], [0, 0, -1315, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -59, 0, 0], [-37, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 243, 0], [0, -2475, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1829, 0, 0, 0, 0], [0, -974, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -160], [0, 0, -2644, 0, 0, 0, 0, 0], [0, 0, 0, 0, -106, 0, 0, 0], [0, 0, 0, 0, 0, 58, 0, 0], [-379, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -148], [0, 0, 0, 0, -106, 0, 0, 0], [0, 0, 0, 0, 0, 66, 0, 0], [0, 0, 0, 0, 0, 0, 21, 0], [0, -4733, 0, 0, 0, 0, 0, 0], [0, 0, -1408, 0, 0, 0, 0, 0], [0, 0, 0, 0, -122, 0, 0, 0], [0, 0, 0, 3292, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 247, 0], [0, 0, 0, 2372, 0, 0, 0, 0], [0, 0, 0, 0, 0, 697, 0, 0], [3337, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 144, 0], [0, 0, 0, -2057, 0, 0, 0, 0], [6271, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -258], [0, 0, -6371, 0, 0, 0, 0, 0], [0, 0, 0, 0, -390, 0, 0, 0], [0, 0, 0, 0, 0, -341, 0, 0], [0, -3407, 0, 0, 0, 0, 0, 0], [0, 0, -4995, 0, 0, 0, 0, 0], [0, 0, 0, 335, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1154, 0, 0], [0, 0, 0, 0, 0, 0, 97, 0], [0, 0, 8000, 0, 0, 0, 0, 0], [0, 0, 0, 0, 294, 0, 0, 0], [9389, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -109], [0, 0, 1123, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1315, 0, 0], [-15662, 0, 0, 0, 0, 0, 0, 0], [0, 3462, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 362], [0, 0, 0, 0, 535, 0, 0, 0], [5066, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1071, 0], [0, 3555, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -283], [0, 0, 0, 0, 0, -1410, 0, 0], [0, -2565, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 433], [0, 0, 0, -6088, 0, 0, 0, 0], [0, 0, 0, 0, 0, -253, 0, 0], [0, 0, 0, 0, 0, 0, 451, 0], [0, 0, 0, 0, 553, 0, 0, 0], [0, 0, 0, 12611, 0, 0, 0, 0], [0, 0, 8587, 0, 0, 0, 0, 0], [0, 0, 0, 4291, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 645, 0], [0, 0, 0, 0, 0, 0, 0, -468], [0, 0, 0, 0, -357, 0, 0, 0], [0, 0, 0, -21143, 0, 0, 0, 0], [-20459, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 13], [0, 0, 0, 0, -476, 0, 0, 0], [0, 0, 0, 0, 0, 1382, 0, 0], [22646, 0, 0, 0, 0, 0, 0, 0], [0, 10687, 0, 0, 0, 0, 0, 0], [0, 0, 12991, 0, 0, 0, 0, 0], [0, 0, 0, 0, 215, 0, 0, 0], [0, 0, 0, -13067, 0, 0, 0, 0], [0, -10537, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -940, 0, 0, 0], [0, 0, 0, -23612, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2084, 0, 0], [0, 0, 0, 0, 0, 0, 828, 0], [0, 0, 0, 0, 0, 0, 0, -1090], [0, 0, -1865, 0, 0, 0, 0, 0], [-21911, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 137, 0], [0, 0, 0, 0, 0, 0, 0, -1058], [0, 0, 0, -7796, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1761, 0], [0, 0, 16191, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2772, 0, 0], [0, 7410, 0, 0, 0, 0, 0, 0], [0, 0, -9944, 0, 0, 0, 0, 0], [0, 0, 0, -9964, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1387, 0, 0], [0, 13873, 0, 0, 0, 0, 0, 0], [0, 0, 22175, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1071, 0, 0, 0], [-8833, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1000, 0], [0, 0, 0, -39791, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2246, 0], [0, 0, 0, 0, -1748, 0, 0, 0], [0, 0, 0, 1460, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2299, 0], [0, 19875, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 607], [0, 0, 18465, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 134, 0, 0], [0, 0, -3847, 0, 0, 0, 0, 0], [0, 0, 0, 0, -184, 0, 0, 0], [0, 0, 0, -511, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1727, 0, 0], [0, 0, 6625, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1327, 0, 0, 0], [0, 0, 0, 32443, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1140, 0, 0], [0, 0, 0, -18013, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2084, 0, 0], [0, -25278, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 2330, 0, 0, 0], [11449, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3517, 0], [0, 0, 0, 0, 0, 0, 0, 703], [0, 0, 0, 0, 1009, 0, 0, 0], [0, 18101, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1897], [0, 0, 0, 0, -1448, 0, 0, 0], [0, 0, 0, 0, 0, 2337, 0, 0], [0, -10295, 0, 0, 0, 0, 0, 0], [0, 0, -11856, 0, 0, 0, 0, 0], [-47693, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1011, 0], [0, 0, 0, 0, 0, 0, 0, 532], [0, 0, -7704, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -3097, 0, 0], [13003, 0, 0, 0, 0, 0, 0, 0], [0, 14289, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 480, 0, 0, 0], [0, 0, 0, -60860, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 727, 0], [0, 2745, 0, 0, 0, 0, 0, 0], [0, 0, 12980, 0, 0, 0, 0, 0], [0, -7331, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -2480], [0, 0, -2736, 0, 0, 0, 0, 0], [0, 0, 0, 0, 685, 0, 0, 0], [0, 0, 0, 0, 0, 4878, 0, 0], [0, 0, 0, 0, 0, 0, 2730, 0], [0, 0, 4045, 0, 0, 0, 0, 0], [0, 0, 0, 2477, 0, 0, 0, 0], [72295, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -3007, 0, 0], [77, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1430], [0, 0, 0, 12377, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2227, 0], [0, 0, 0, 0, 0, 0, 0, -1505], [0, 0, 0, 0, -2185, 0, 0, 0], [11317, 0, 0, 0, 0, 0, 0, 0], [0, 0, -2007, 0, 0, 0, 0, 0], [0, 0, 0, 0, -3729, 0, 0, 0], [0, 0, 0, 0, 0, 1102, 0, 0], [0, 0, 0, 0, 0, 0, -3097, 0], [0, -26157, 0, 0, 0, 0, 0, 0], [0, 0, 1161, 0, 0, 0, 0, 0], [2287, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -3194], [0, 0, 0, 0, 0, 0, -2738, 0], [0, -25449, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -717], [0, 0, 0, 0, -2605, 0, 0, 0], [0, 0, 0, 52031, 0, 0, 0, 0], [-35521, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6487, 0], [0, -8011, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -937], [0, 0, 0, 0, 0, 3678, 0, 0], [67331, 0, 0, 0, 0, 0, 0, 0], [0, -33026, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1517, 0, 0, 0], [0, 0, 0, 0, 0, 5088, 0, 0], [0, 0, 0, 0, 0, 0, 2576, 0], [0, 0, -49323, 0, 0, 0, 0, 0], [0, 6534, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -354, 0, 0, 0], [0, 3002, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -4455], [0, 0, -27597, 0, 0, 0, 0, 0], [0, 0, 0, 0, -2803, 0, 0, 0], [0, 0, 0, 0, 0, 5985, 0, 0], [0, 3905, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2843], [0, 0, -37841, 0, 0, 0, 0, 0], [0, 0, 0, 16144, 0, 0, 0, 0], [0, -42314, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 815, 0, 0, 0], [0, 0, 0, 30341, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1883, 0, 0], [-27653, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -5563, 0], [0, 0, 0, 0, 0, 0, 0, -1462], [0, 0, 0, 0, 0, 4692, 0, 0], [0, 0, 0, 0, 0, 0, 0, -334], [0, 0, 0, -10343, 0, 0, 0, 0], [0, -42929, 0, 0, 0, 0, 0, 0], [0, 0, -64891, 0, 0, 0, 0, 0], [0, 0, 0, 0, 997, 0, 0, 0], [0, 0, 0, 0, 0, -6955, 0, 0], [0, -31695, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -10], [0, 0, 0, 103840, 0, 0, 0, 0], [0, 0, 0, 0, 0, -9210, 0, 0], [0, 0, 20376, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4317, 0, 0, 0], [0, 0, 0, 0, 0, -4517, 0, 0], [45703, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 7893, 0], [0, 0, 0, 0, 0, 0, 0, 3965], [0, 0, -9779, 0, 0, 0, 0, 0], [0, 0, 0, -34940, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -200, 0], [44126, 0, 0, 0, 0, 0, 0, 0], [0, -12849, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 4583], [0, 0, 22031, 0, 0, 0, 0, 0], [0, 0, -26677, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1160, 0, 0, 0], [0, 0, 0, 4628, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1261, 0], [0, 0, 0, 0, -1900, 0, 0, 0], [0, 0, 0, -16984, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3455, 0], [0, 0, -5845, 0, 0, 0, 0, 0], [0, 0, 0, -31795, 0, 0, 0, 0], [30778, 0, 0, 0, 0, 0, 0, 0], [0, -3655, 0, 0, 0, 0, 0, 0], [6578, 0, 0, 0, 0, 0, 0, 0], [0, -12251, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 3453], [0, 0, 45248, 0, 0, 0, 0, 0], [64838, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2676], [0, 0, 0, 0, 0, 10491, 0, 0], [0, -67790, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 9162, 0, 0], [0, 0, -14707, 0, 0, 0, 0, 0], [0, 0, 0, 117017, 0, 0, 0, 0], [0, 0, 0, 0, 0, -2943, 0, 0], [58829, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -6986, 0], [0, -5773, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -6757, 0, 0, 0], [0, 0, 0, 0, 0, 0, 9241, 0], [0, 0, 0, 0, 0, 0, 0, 1628], [0, 0, 0, 0, 590, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, -5840], [0, 0, 4524, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 11304, 0], [0, -11493, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -5175, 0], [0, 0, 0, 0, 0, 0, 0, 6], [0, 0, 0, 21517, 0, 0, 0, 0], [-22523, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6502, 0], [0, 66694, 0, 0, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1728_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1728_4_d_f();".
// 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_1728_4_d_f(:prec:=8)
    chi := MakeCharacter_1728_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1728_4_d_f();".
// 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_1728_4_d_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1728_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![156, 0, 1]>,<7,R![-147, 0, 1]>,<17,R![-4212, 0, 1]>,<23,R![-3900, 0, 1]>],Snew);
    return Vf;
end function;