
// Make newform 1728.3.g.k in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1728_g();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1728_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_1728_3_g_k();".
// 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_3_g_k();".
// 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 := [16, -32, 20, 4, -11, 2, 5, -4, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [14, -32, 11, 9, -7, -1, 3, -1], [112, -160, 46, 57, -44, -11, 30, -11], [-192, 208, -18, -81, 40, 27, -34, 11], [100, -100, 10, 51, -20, -17, 18, -5], [-90, 120, -33, -45, 33, 9, -21, 9], [-48, 62, -15, -24, 17, 6, -11, 4], [268, -360, 104, 127, -94, -33, 64, -25]];
    Rf_basisdens := [1, 1, 4, 4, 2, 2, 1, 4];
    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_g();"
function MakeCharacter_1728_g()
    N := 1728;
    order := 2;
    char_gens := [703, 325, 1217];
    v := [1, 2, 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_g_Hecke();"
function MakeCharacter_1728_g_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 := 3;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 1, -1], [2, 0, 0, 0, 1, 0, 0, 0], [6, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, -3, 0, 1], [0, 0, 0, -1, 0, 1, -2, -3], [4, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 5, 1, -2], [12, 2, -4, 0, 1, 0, 0, 0], [-16, 2, 2, 0, -1, 0, 0, 0], [0, 0, 0, -4, 0, -4, 0, -2], [0, 0, 0, 4, 0, -2, 2, 4], [-21, 1, 1, 0, 4, 0, 0, 0], [0, 0, 0, -6, 0, 6, 4, -2], [-4, 2, 12, 0, 4, 0, 0, 0], [0, 0, 0, 4, 0, -12, 2, -2], [0, 0, 0, 1, 0, -3, 14, 3], [3, -1, -6, 0, -6, 0, 0, 0], [0, 0, 0, 5, 0, 9, 13, 3], [0, 0, 0, 3, 0, -10, 3, 13], [78, 4, 10, 0, 4, 0, 0, 0], [-17, -2, 4, 0, -6, 0, 0, 0], [-1, 3, 17, 0, 6, 0, 0, 0], [0, 0, 0, -5, 0, 7, -9, 9], [0, 0, 0, 4, 0, 3, -18, 4], [-24, 4, 8, 0, -3, 0, 0, 0], [-80, 2, 10, 0, 11, 0, 0, 0], [0, 0, 0, 12, 0, -4, -10, 7], [0, 0, 0, -2, 0, 1, 28, -22], [2, 8, -6, 0, 2, 0, 0, 0], [0, 0, 0, -16, 0, 0, -18, 12], [109, 5, 7, 0, 8, 0, 0, 0], [0, 0, 0, -13, 0, 15, 21, -20], [16, 0, 0, 0, -2, 0, 0, 0], [0, 0, 0, 1, 0, 13, -20, -9], [0, 0, 0, 8, 0, -10, -28, -8], [83, 6, -11, 0, 8, 0, 0, 0], [0, 0, 0, -4, 0, -15, -54, -4], [12, -6, 28, 0, 8, 0, 0, 0], [0, 0, 0, 13, 0, 21, 8, -17], [67, 9, -10, 0, 0, 0, 0, 0], [-155, 6, -9, 0, 6, 0, 0, 0], [0, 0, 0, -4, 0, -20, -42, 3], [0, 0, 0, 9, 0, 21, -2, -23], [0, 0, 0, -3, 0, -31, 51, 19], [0, 0, 0, -20, 0, -8, 2, -20], [10, -4, -40, 0, -6, 0, 0, 0], [166, 2, 42, 0, 4, 0, 0, 0], [0, 0, 0, 1, 0, 15, -44, 11], [50, 8, -16, 0, 2, 0, 0, 0], [0, 0, 0, -6, 0, 34, -50, -10], [-74, 12, -20, 0, -13, 0, 0, 0], [0, 0, 0, -15, 0, -13, -6, 19], [-168, -3, 32, 0, 14, 0, 0, 0], [0, 0, 0, -11, 0, -7, -51, -8], [-20, -8, 16, 0, -2, 0, 0, 0], [-58, -6, -28, 0, 11, 0, 0, 0], [0, 0, 0, 35, 0, 23, 20, 19], [164, 5, -4, 0, -14, 0, 0, 0], [0, 0, 0, 13, 0, -7, -62, 39], [0, 0, 0, 15, 0, -63, -12, 5], [-25, 11, 18, 0, 2, 0, 0, 0], [-5, -1, -43, 0, -2, 0, 0, 0], [0, 0, 0, -26, 0, 30, 68, -36], [38, 4, 56, 0, 6, 0, 0, 0], [0, 0, 0, 11, 0, 36, 47, -11], [-44, 2, 60, 0, -13, 0, 0, 0], [-28, 6, 22, 0, -29, 0, 0, 0], [0, 0, 0, -2, 0, -4, 48, -38], [0, 0, 0, -11, 0, -7, 77, 22], [-202, -10, 4, 0, -5, 0, 0, 0], [0, 0, 0, 50, 0, -6, -14, -6], [0, 0, 0, 37, 0, 25, -4, 39], [161, -9, 19, 0, 4, 0, 0, 0], [-222, 2, 44, 0, 3, 0, 0, 0], [-232, -18, 24, 0, -12, 0, 0, 0], [-181, 4, -8, 0, -24, 0, 0, 0], [0, 0, 0, -6, 0, -58, -46, -10], [-88, 6, 4, 0, 2, 0, 0, 0], [0, 0, 0, 34, 0, 24, -14, -18], [-231, 12, 24, 0, -30, 0, 0, 0], [0, 0, 0, 18, 0, 26, 126, -7], [0, 0, 0, -38, 0, 78, -6, -10], [96, -4, -14, 0, -29, 0, 0, 0], [-29, -6, -68, 0, -26, 0, 0, 0], [-35, -21, -57, 0, -12, 0, 0, 0], [0, 0, 0, -13, 0, -33, -45, 30], [0, 0, 0, -13, 0, -34, -3, -43], [0, 0, 0, 40, 0, 66, 66, -16], [0, 0, 0, 29, 0, 49, -27, -13], [0, 0, 0, 38, 0, 47, 24, -14], [0, 0, 0, 6, 0, -66, 0, 28], [0, 0, 0, -15, 0, -105, -28, 27], [37, -6, -45, 0, -16, 0, 0, 0], [-226, -12, 20, 0, -37, 0, 0, 0], [0, 0, 0, -27, 0, -15, -110, 15], [-160, 28, 8, 0, 22, 0, 0, 0], [0, 0, 0, -17, 0, -61, 88, 61], [9, 5, 19, 0, -44, 0, 0, 0], [0, 0, 0, -67, 0, -22, -47, -13], [4, -14, -40, 0, -18, 0, 0, 0], [0, 0, 0, 33, 0, -67, 34, -41], [-222, -8, -80, 0, -22, 0, 0, 0], [0, 0, 0, 26, 0, 29, -48, 30], [-498, -14, -110, 0, -4, 0, 0, 0], [0, 0, 0, -38, 0, -124, -4, 30], [-119, -27, -2, 0, -26, 0, 0, 0], [0, 0, 0, -41, 0, 115, -5, -7], [234, -10, 84, 0, 16, 0, 0, 0], [260, 4, -78, 0, -23, 0, 0, 0], [0, 0, 0, -27, 0, -47, 14, 11], [0, 0, 0, -4, 0, 44, -88, 21], [328, -24, -18, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, -64, -12], [0, 0, 0, 70, 0, -50, -104, 66], [-109, -18, -19, 0, 4, 0, 0, 0], [0, 0, 0, 16, 0, -47, 108, -48], [-416, 12, -8, 0, 11, 0, 0, 0], [181, 24, 0, 0, 4, 0, 0, 0], [-52, -1, -8, 0, 12, 0, 0, 0], [0, 0, 0, -38, 0, 86, 82, 6], [0, 0, 0, 32, 0, -96, 88, -60], [801, -8, -49, 0, -32, 0, 0, 0], [-248, -10, 68, 0, 36, 0, 0, 0], [0, 0, 0, 54, 0, 42, 34, -70], [0, 0, 0, -16, 0, 16, -22, 65], [344, 6, -76, 0, -41, 0, 0, 0], [0, 0, 0, 13, 0, 9, -52, -81], [0, 0, 0, -29, 0, 75, 196, -47], [0, 0, 0, 45, 0, 65, -1, -18], [454, -8, -32, 0, -6, 0, 0, 0], [-4, -4, 56, 0, -42, 0, 0, 0], [227, 11, 50, 0, -44, 0, 0, 0], [432, -15, -16, 0, 58, 0, 0, 0], [0, 0, 0, 40, 0, -24, 40, 88], [-821, 12, 41, 0, -2, 0, 0, 0], [-630, 8, 14, 0, 28, 0, 0, 0], [0, 0, 0, -45, 0, -89, -28, 127], [160, -19, -48, 0, -6, 0, 0, 0], [0, 0, 0, -29, 0, -113, -1, -60], [0, 0, 0, 36, 0, 68, 76, -52], [-726, -18, 36, 0, -34, 0, 0, 0], [0, 0, 0, 23, 0, 19, -12, 13], [-130, -2, 68, 0, -86, 0, 0, 0], [590, 34, 28, 0, 11, 0, 0, 0], [0, 0, 0, -10, 0, -2, -84, 10], [0, 0, 0, 14, 0, 42, -266, 82], [506, 8, 32, 0, -16, 0, 0, 0], [-42, 6, -168, 0, -23, 0, 0, 0], [0, 0, 0, 59, 0, 143, 24, 95], [0, 0, 0, -59, 0, -123, -36, -57], [0, 0, 0, -67, 0, 121, -54, -83], [0, 0, 0, -12, 0, -2, 100, -36], [0, 0, 0, -79, 0, 21, 55, -14], [-436, 30, -80, 0, 22, 0, 0, 0], [279, -6, 172, 0, -38, 0, 0, 0], [101, 11, -29, 0, 2, 0, 0, 0], [0, 0, 0, 10, 0, -53, -42, 6], [-192, 12, -116, 0, 42, 0, 0, 0], [0, 0, 0, -95, 0, -91, -155, -8], [0, 0, 0, 53, 0, -20, 261, 27], [118, 40, 162, 0, 28, 0, 0, 0], [0, 0, 0, -52, 0, -82, -34, -116], [0, 0, 0, -20, 0, -20, -24, 1], [-506, -14, -20, 0, -39, 0, 0, 0], [-585, 36, 56, 0, 26, 0, 0, 0], [-620, 43, 0, 0, 12, 0, 0, 0], [0, 0, 0, 70, 0, 47, 44, 18], [290, 12, 56, 0, -10, 0, 0, 0], [0, 0, 0, 82, 0, 52, 30, 78], [-26, 52, 40, 0, 50, 0, 0, 0], [0, 0, 0, -43, 0, -103, 71, 110], [-8, 22, 42, 0, 47, 0, 0, 0], [0, 0, 0, -45, 0, 7, -256, 135], [-9, 32, 125, 0, -66, 0, 0, 0], [0, 0, 0, 43, 0, -153, 51, -26], [22, -24, 112, 0, 81, 0, 0, 0], [0, 0, 0, 57, 0, 29, 31, -102], [0, 0, 0, -93, 0, 122, 91, -99], [-152, -58, -108, 0, -51, 0, 0, 0], [204, 38, 160, 0, 62, 0, 0, 0], [0, 0, 0, -25, 0, -65, -74, 5], [577, 51, -129, 0, 46, 0, 0, 0], [-728, 6, 52, 0, -11, 0, 0, 0], [0, 0, 0, -5, 0, 223, -36, 81], [-475, -11, -66, 0, 24, 0, 0, 0], [0, 0, 0, 29, 0, 63, 136, -17], [-666, 16, -16, 0, 78, 0, 0, 0], [0, 0, 0, -42, 0, -1, -110, -86], [0, 0, 0, 12, 0, -164, 54, 114], [-637, -10, 21, 0, 64, 0, 0, 0], [0, 0, 0, 28, 0, -16, 188, -124], [-620, 24, 36, 0, 52, 0, 0, 0], [589, -37, -78, 0, -26, 0, 0, 0], [670, -8, -192, 0, -16, 0, 0, 0], [352, 10, -104, 0, 104, 0, 0, 0], [0, 0, 0, 4, 0, 240, 26, -76], [-727, 17, 15, 0, 86, 0, 0, 0], [0, 0, 0, 14, 0, 118, -170, 53], [-1046, 10, -4, 0, 69, 0, 0, 0], [-97, -31, 166, 0, 30, 0, 0, 0], [0, 0, 0, 77, 0, -14, -205, 27], [-240, 77, -32, 0, 10, 0, 0, 0], [0, 0, 0, 87, 0, 83, 151, 53], [0, 0, 0, 139, 0, 78, 57, -99], [-26, 4, 102, 0, 66, 0, 0, 0], [0, 0, 0, 121, 0, -171, 38, 51], [-657, -25, -166, 0, -22, 0, 0, 0], [268, -9, 44, 0, -70, 0, 0, 0], [0, 0, 0, -47, 0, -203, -77, 76], [0, 0, 0, -30, 0, -33, 134, -66], [0, 0, 0, 20, 0, 236, -210, -108], [-307, -62, -4, 0, -46, 0, 0, 0], [0, 0, 0, 23, 0, 163, 125, -95], [-118, 10, -182, 0, -22, 0, 0, 0], [0, 0, 0, -20, 0, -174, 206, 44], [652, 3, -8, 0, 4, 0, 0, 0], [-232, 48, 176, 0, 115, 0, 0, 0], [0, 0, 0, -9, 0, 243, -53, 13], [-796, -2, -180, 0, 4, 0, 0, 0], [0, 0, 0, -153, 0, 115, 15, -75], [0, 0, 0, 25, 0, 104, 243, -81], [148, -38, 28, 0, 48, 0, 0, 0], [568, 10, 164, 0, 62, 0, 0, 0], [0, 0, 0, -29, 0, 93, 302, -55], [0, 0, 0, 121, 0, 237, -81, -105], [0, 0, 0, 90, 0, -66, -156, -34], [826, -22, -116, 0, -96, 0, 0, 0], [0, 0, 0, -140, 0, 52, 262, -36], [0, 0, 0, 61, 0, 97, 271, 19], [-584, -32, -268, 0, 2, 0, 0, 0], [0, 0, 0, 100, 0, -28, -232, -42], [0, 0, 0, 18, 0, -178, 84, -10], [670, -52, 120, 0, -36, 0, 0, 0], [-696, -25, 64, 0, -6, 0, 0, 0], [0, 0, 0, -85, 0, -80, -211, -67], [0, 0, 0, 28, 0, 248, -96, 148], [0, 0, 0, 52, 0, 24, 166, 148], [0, 0, 0, -24, 0, -392, 32, 10], [0, 0, 0, -72, 0, -56, -58, -111], [-870, 52, -40, 0, 35, 0, 0, 0], [38, -14, 196, 0, -53, 0, 0, 0], [0, 0, 0, -29, 0, -205, -30, 9], [0, 0, 0, -87, 0, 237, 271, -82], [0, 0, 0, -120, 0, 91, 270, -32], [0, 0, 0, 79, 0, -141, 320, 55], [0, 0, 0, 55, 0, -281, 252, 13], [740, 14, -76, 0, 2, 0, 0, 0], [450, -56, 296, 0, 7, 0, 0, 0], [0, 0, 0, -52, 0, 406, 84, 4], [-463, -72, -208, 0, -58, 0, 0, 0], [-1687, 2, 55, 0, -44, 0, 0, 0], [0, 0, 0, -74, 0, 17, -262, 186], [666, 20, 312, 0, 33, 0, 0, 0], [0, 0, 0, -56, 0, -8, -150, -40], [-1277, -3, -95, 0, 40, 0, 0, 0], [945, -84, -120, 0, -26, 0, 0, 0], [0, 0, 0, 133, 0, -231, -17, 224], [0, 0, 0, 22, 0, 167, -62, 154], [298, 58, -148, 0, -96, 0, 0, 0], [-1122, -48, -224, 0, -3, 0, 0, 0], [-1828, -8, 20, 0, 72, 0, 0, 0], [0, 0, 0, 18, 0, -86, -428, 66], [-1260, 3, -156, 0, -30, 0, 0, 0], [1000, -68, -254, 0, -105, 0, 0, 0], [0, 0, 0, -57, 0, 283, -360, 209], [1204, -25, -72, 0, 56, 0, 0, 0], [1670, 84, -72, 0, 125, 0, 0, 0], [0, 0, 0, 24, 0, -88, 6, 240], [-247, 72, 32, 0, 24, 0, 0, 0], [0, 0, 0, -146, 0, 70, -78, 3], [817, -10, -172, 0, -106, 0, 0, 0], [0, 0, 0, 8, 0, -168, 472, 175], [0, 0, 0, -67, 0, 68, 347, -133], [74, 2, 204, 0, -63, 0, 0, 0], [1449, -75, 94, 0, 72, 0, 0, 0], [0, 0, 0, 164, 0, 80, 64, 60], [0, 0, 0, -140, 0, 32, -204, -148], [0, 0, 0, 106, 0, -30, 26, 217], [0, 0, 0, 39, 0, -207, -288, 61], [-1292, 60, 184, 0, 103, 0, 0, 0], [0, 0, 0, 104, 0, -264, 184, 206], [0, 0, 0, -64, 0, -338, 60, 192], [-1131, 1, 22, 0, 114, 0, 0, 0], [-1417, -40, 201, 0, -8, 0, 0, 0], [0, 0, 0, 75, 0, -281, -147, -35], [40, -20, 232, 0, -48, 0, 0, 0], [1072, -41, -144, 0, -154, 0, 0, 0], [0, 0, 0, 172, 0, 83, -214, -84], [-1208, -76, -204, 0, -30, 0, 0, 0], [0, 0, 0, -66, 0, -189, -202, 50], [76, -102, -372, 0, -153, 0, 0, 0], [944, -41, 264, 0, 74, 0, 0, 0], [0, 0, 0, -50, 0, 230, -124, 13], [-785, -53, 77, 0, -16, 0, 0, 0], [0, 0, 0, 173, 0, -48, -245, -53], [0, 0, 0, 68, 0, -108, -66, 178], [-586, 80, -32, 0, -58, 0, 0, 0], [231, 6, -23, 0, -124, 0, 0, 0], [0, 0, 0, 98, 0, -182, 412, -173]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1728_g_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1728_3_g_k();".
// 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_3_g_k(:prec:=8)
    chi := MakeCharacter_1728_g();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_3_g_k();".
// 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_3_g_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1728_g();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<5,R![229, 28, -54, 4, 1]>,<7,R![52441, 0, 51220, 0, 7758, 0, 196, 0, 1]>],Snew);
    return Vf;
end function;