
// Make newform 1728.3.e.s in Magma, downloaded from the LMFDB on 10 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1728_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1728_e_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_e_s();".
// 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_e_s();".
// 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 := [1, 0, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 0, 3, 0], [0, 2, 0, 2], [0, 6, 0, -6]];
    Rf_basisdens := [1, 1, 1, 1];
    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_e();"
function MakeCharacter_1728_e()
    N := 1728;
    order := 2;
    char_gens := [703, 325, 1217];
    v := [2, 2, 1];
    // 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_e_Hecke();"
function MakeCharacter_1728_e_Hecke( : Kf := false)
    N := 1728;
    order := 2;
    char_gens := [703, 325, 1217];
    char_values := [[1, 0, 0, 0], [1, 0, 0, 0], [-1, 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 := 3;
    raw_aps := [[0, 0, 0, 0], [0, 0, 0, 0], [0, -1, 1, 0], [3, 0, 0, -1], [0, -3, 2, 0], [2, 0, 0, -2], [0, 2, 4, 0], [8, 0, 0, 2], [0, 4, 10, 0], [0, -14, 0, 0], [1, 0, 0, -1], [36, 0, 0, -2], [0, 4, -18, 0], [-14, 0, 0, -2], [0, 14, -12, 0], [0, -17, -17, 0], [0, -6, -28, 0], [-52, 0, 0, 8], [-58, 0, 0, -2], [0, -6, -10, 0], [-71, 0, 0, -6], [74, 0, 0, 4], [0, 23, -14, 0], [0, -30, 6, 0], [11, 0, 0, 8], [0, -9, -9, 0], [-34, 0, 0, 4], [0, 1, 24, 0], [68, 0, 0, 2], [0, -64, 6, 0], [5, 0, 0, -23], [0, 43, 4, 0], [0, -46, -42, 0], [-108, 0, 0, 8], [0, -17, -61, 0], [67, 0, 0, -7], [-76, 0, 0, -12], [102, 0, 0, 12], [0, -54, -12, 0], [0, -11, -9, 0], [0, 11, -24, 0], [96, 0, 0, -4], [0, 34, 30, 0], [-1, 0, 0, -10], [0, -37, 69, 0], [-25, 0, 0, 27], [-260, 0, 0, -2], [74, 0, 0, 16], [0, 30, -12, 0], [2, 0, 0, 32], [0, -14, -34, 0], [0, 80, -34, 0], [30, 0, 0, -28], [0, -30, -128, 0], [0, 22, 88, 0], [0, -36, 22, 0], [0, -46, -76, 0], [421, 0, 0, 7], [68, 0, 0, -12], [0, -38, 124, 0], [-256, 0, 0, -22], [0, -2, 12, 0], [-54, 0, 0, 52], [0, -24, -78, 0], [-15, 0, 0, -30], [0, 5, -51, 0], [194, 0, 0, 34], [6, 0, 0, 52], [0, -95, -102, 0], [24, 0, 0, 6], [0, 16, -86, 0], [0, -6, 12, 0], [-367, 0, 0, -17], [142, 0, 0, -42], [-160, 0, 0, 0], [0, 54, 162, 0], [0, -25, -65, 0], [-338, 0, 0, -30], [0, -24, -96, 0], [-435, 0, 0, -16], [0, 38, 48, 0], [76, 0, 0, 12], [0, 10, -100, 0], [571, 0, 0, -12], [171, 0, 0, 27], [0, -38, 184, 0], [0, 96, 86, 0], [-19, 0, 0, 88], [0, 165, 85, 0], [-695, 0, 0, 15], [0, 163, -6, 0], [0, 154, -88, 0], [794, 0, 0, -8], [0, 25, -156, 0], [-414, 0, 0, -26], [0, -260, -54, 0], [0, 9, 195, 0], [0, -18, -188, 0], [142, 0, 0, -40], [-180, 0, 0, -48], [530, 0, 0, -16], [0, 141, -143, 0], [0, 251, -46, 0], [0, 192, -148, 0], [246, 0, 0, -88], [14, 0, 0, -28], [0, 57, -220, 0], [0, 42, 86, 0], [0, 190, -108, 0], [445, 0, 0, 2], [-314, 0, 0, 0], [550, 0, 0, 8], [0, 176, -126, 0], [-338, 0, 0, -60], [-205, 0, 0, -9], [0, 108, 110, 0], [-600, 0, 0, 12], [0, -196, -112, 0], [0, -15, 123, 0], [0, 51, -48, 0], [136, 0, 0, 2], [103, 0, 0, 56], [0, 46, 184, 0], [0, -322, -16, 0], [-196, 0, 0, 72], [0, -83, 315, 0], [-800, 0, 0, -56], [0, 212, 136, 0], [375, 0, 0, -69], [112, 0, 0, 14], [842, 0, 0, -24], [0, -338, -134, 0], [249, 0, 0, -97], [-194, 0, 0, -68], [0, 72, 136, 0], [131, 0, 0, 66], [0, 154, -24, 0], [4, 0, 0, 40], [0, 97, -293, 0], [0, 370, 22, 0], [184, 0, 0, -18], [0, -278, -48, 0], [-5, 0, 0, 33], [0, -70, 88, 0], [926, 0, 0, 32], [0, -26, 294, 0], [-302, 0, 0, -72], [0, 42, -312, 0], [180, 0, 0, -160], [0, 140, -8, 0], [-1290, 0, 0, 28], [0, -346, -152, 0], [632, 0, 0, -50], [0, 154, -58, 0], [484, 0, 0, -90], [0, -186, -296, 0], [119, 0, 0, -87], [0, 132, -20, 0], [-579, 0, 0, -24], [0, 161, -123, 0], [0, -5, 36, 0], [0, -288, -36, 0], [451, 0, 0, 97], [0, 113, -390, 0], [0, 130, -390, 0], [0, -342, 84, 0], [-331, 0, 0, 25], [-778, 0, 0, 54], [-241, 0, 0, -4], [0, -170, 400, 0], [0, -187, -300, 0], [-534, 0, 0, -144], [0, -298, 104, 0], [994, 0, 0, -36], [109, 0, 0, 99], [0, -284, 46, 0], [-784, 0, 0, 98], [0, -281, 213, 0], [-1357, 0, 0, -75], [1162, 0, 0, -58], [-23, 0, 0, -225], [0, 327, 82, 0], [852, 0, 0, -74], [0, -200, 444, 0], [0, -174, 102, 0], [0, 55, -141, 0], [512, 0, 0, -82], [-414, 0, 0, 36], [-215, 0, 0, 158], [0, 320, -102, 0], [358, 0, 0, 28], [0, 217, 420, 0], [-434, 0, 0, 66], [0, -211, -401, 0], [0, -98, 336, 0], [0, -596, 112, 0], [1483, 0, 0, -86], [-214, 0, 0, 16], [0, 68, -596, 0], [0, -4, -312, 0], [0, -443, 125, 0], [-1775, 0, 0, 41], [490, 0, 0, 54], [-581, 0, 0, 74], [0, 185, 174, 0], [0, -42, -480, 0], [-782, 0, 0, 116], [0, -217, -294, 0], [0, -154, 346, 0], [-134, 0, 0, -12], [1335, 0, 0, 62], [0, -338, -204, 0], [707, 0, 0, -79], [0, -379, -44, 0], [0, -80, 68, 0], [785, 0, 0, 72], [1666, 0, 0, 48], [0, -470, 206, 0], [0, 538, -264, 0], [0, 202, -312, 0], [1048, 0, 0, -98], [270, 0, 0, -84], [0, 376, 84, 0], [-794, 0, 0, 88], [0, 235, 150, 0], [-1772, 0, 0, 52], [0, 612, -228, 0], [0, 700, -138, 0], [-2178, 0, 0, 56], [0, -206, 668, 0], [-198, 0, 0, -128], [-980, 0, 0, -24], [-710, 0, 0, 216], [0, 324, 596, 0], [-522, 0, 0, 70], [0, -616, 56, 0], [-1774, 0, 0, 120], [0, 110, -260, 0], [0, -71, -182, 0], [0, -24, 724, 0], [0, -146, -780, 0], [-1174, 0, 0, 130], [1163, 0, 0, 111], [-862, 0, 0, -226], [0, -162, 360, 0], [0, 686, 26, 0], [1229, 0, 0, 35], [0, 143, 576, 0], [172, 0, 0, 310], [0, -690, -34, 0], [-1464, 0, 0, 108], [0, -366, -204, 0], [0, 446, 116, 0], [1993, 0, 0, 60], [0, 105, 459, 0], [0, -425, -468, 0], [-866, 0, 0, 150], [988, 0, 0, 12], [0, 499, -405, 0], [433, 0, 0, 28], [-1771, 0, 0, 7], [0, 163, -444, 0], [-226, 0, 0, 192], [390, 0, 0, -186], [0, 588, 188, 0], [-676, 0, 0, -8], [0, 242, 44, 0], [0, -356, -794, 0], [1202, 0, 0, 208], [0, 110, -496, 0], [782, 0, 0, 78], [812, 0, 0, -168], [1837, 0, 0, 24], [1433, 0, 0, -175], [1723, 0, 0, 8], [-737, 0, 0, 3], [0, 645, -366, 0], [190, 0, 0, -326], [-1235, 0, 0, 166], [0, -302, 824, 0], [0, 204, -20, 0], [1343, 0, 0, -17], [0, 4, 1114, 0], [-764, 0, 0, -226], [1502, 0, 0, -50], [0, -730, 328, 0], [563, 0, 0, -282], [0, 795, 261, 0], [334, 0, 0, -288], [0, -320, 532, 0], [0, -218, -128, 0], [0, -337, 840, 0], [0, -428, 80, 0], [0, 869, -324, 0], [1104, 0, 0, 106], [0, 854, 136, 0], [745, 0, 0, 249], [0, 475, 135, 0], [0, 241, 906, 0], [-1030, 0, 0, -30], [-1702, 0, 0, -4], [0, 313, 251, 0], [-2135, 0, 0, -7]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1728_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1728_3_e_s();".
// 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_e_s(:prec:=4)
    chi := MakeCharacter_1728_e();
    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_e_s();".
// 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_e_s( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1728_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<5,R![1, 0, 34, 0, 1]>,<7,R![-63, -6, 1]>],Snew);
    return Vf;
end function;