
// Make newform 184.5.e.d in Magma, downloaded from the LMFDB on 09 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_184_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_184_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_184_5_e_d();".
// 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_184_5_e_d();".
// 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 := [8, 0, 0, -3, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 4, 1, 0, 0, 1], [-1, 0, 0, 1, 0, 0], [0, 3, 0, 0, -1, 0], [0, 4, -1, 0, 0, -1], [0, 0, 3, 0, 0, -1]];
    Rf_basisdens := [1, 4, 1, 2, 4, 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_184_e();"
function MakeCharacter_184_e()
    N := 184;
    order := 2;
    char_gens := [47, 93, 97];
    v := [2, 1, 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_184_e_Hecke();"
function MakeCharacter_184_e_Hecke( : Kf := false)
    N := 184;
    order := 2;
    char_gens := [47, 93, 97];
    char_values := [[1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0], [-1, 0, 0, 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 := 5;
    raw_aps := [[0, 1, 0, 0, -1, -1], [0, -4, 0, 1, -3, 6], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -44, 0, -17, -61, 122], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-529, 0, 0, 0, 0, 0], [0, -100, 0, 353, 253, -506], [0, -347, 0, -127, -220, -694], [0, 0, 0, 0, 0, 0], [0, -107, 0, -991, 884, -214], [0, 0, 0, 0, 0, 0], [0, -421, 0, 943, -1364, -842], [0, 0, 0, 0, 0, 0], [624, 0, -1248, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -1429, 0, 1327, -2756, -2858], [0, 277, 0, 3137, -2860, 554], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-3984, 0, 7968, 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, 0], [0, -517, 0, 9103, -9620, -1034], [0, -2444, 0, 7471, 5027, -10054], [0, 0, 0, 0, 0, 0], [0, -9844, 0, 11393, 1549, -3098], [0, 0, 0, 0, 0, 0], [0, 5269, 0, 11873, -6604, 10538], [0, 0, 0, 0, 0, 0], [0, -15980, 0, 14863, -1117, 2234], [2786, 0, 0, 0, 0, 0], [-1584, 0, 3168, 0, 0, 0], [0, -620, 0, -10193, -10813, 21626], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 10043, 0, -10961, 21004, 20086], [0, -3124, 0, -10399, -13523, 27046], [0, 0, 0, 0, 0, 0], [9744, 0, -19488, 0, 0, 0], [-46466, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 8459, 0, -25457, 33916, 16918], [0, 5893, 0, 33569, -27676, 11786], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 19237, 0, 28961, -9724, 38474], [0, 0, 0, 0, 0, 0], [0, 5044, 0, 20047, 25091, -50182], [-65086, 0, 0, 0, 0, 0], [0, -47996, 0, 37519, -10477, 20954], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [25680, 0, -51360, 0, 0, 0], [0, -22187, 0, -50527, 28340, -44374], [0, 0, 0, 0, 0, 0], [-31920, 0, 63840, 0, 0, 0], [0, 66284, 0, -42271, 24013, -48026], [0, 0, 0, 0, 0, 0], [-43344, 0, 86688, 0, 0, 0], [0, -74884, 0, 50753, -24131, 48262], [0, -37957, 0, 25999, -63956, -75914], [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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 14300, 0, -63103, -48803, 97606], [0, 0, 0, 0, 0, 0], [0, 1067, 0, -96209, 97276, 2134], [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, 54347, 0, 87631, -33284, 108694], [0, 121484, 0, -103903, 17581, -35162], [73726, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -72004, 0, 115553, 43549, -87098], [-419134, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 13739, 0, -130577, 144316, 27478], [0, 95524, 0, -12113, 83411, -166822], [0, -150436, 0, 95489, -54947, 109894], [0, 0, 0, 0, 0, 0], [0, -158444, 0, 141391, -17053, 34106], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -56356, 0, -48991, -105347, 210694], [0, 92444, 0, -158623, -66179, 132358], [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, 115237, 0, 93281, 21956, 230474], [0, 136036, 0, -194897, -58861, 117722], [621502, 0, 0, 0, 0, 0], [-505634, 0, 0, 0, 0, 0], [0, 81013, 0, -136447, 217460, 162026], [587902, 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, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -44363, 0, 216257, -260620, -88726], [0, 250900, 0, -146897, 104003, -208006], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 46117, 0, -235519, 281636, 92234], [0, 0, 0, 0, 0, 0], [0, -164980, 0, 256577, 91597, -183194], [146256, 0, -292512, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [290878, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -265100, 0, 321007, 55907, -111814], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -190933, 0, 72847, -263780, -381866], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-1287646, 0, 0, 0, 0, 0], [0, -385436, 0, 223087, -162349, 324698], [275184, 0, -550368, 0, 0, 0], [0, -28523, 0, 378881, -407404, -57046], [0, 0, 0, 0, 0, 0], [39696, 0, -79392, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-192720, 0, 385440, 0, 0, 0], [0, -262357, 0, -24977, -237380, -524714], [0, -331540, 0, 428993, 97453, -194906], [0, -152603, 0, -404959, 252356, -305206], [-261744, 0, 523488, 0, 0, 0], [0, 0, 0, 0, 0, 0], [-292656, 0, 585312, 0, 0, 0], [0, -92917, 0, -460241, 367324, -185834], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, -266267, 0, 170273, -436540, -532534], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 426140, 0, -137023, 289117, -578234], [0, 0, 0, 0, 0, 0], [0, -320459, 0, -277183, -43276, -640918], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [632446, 0, 0, 0, 0, 0], [-411216, 0, 822432, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_184_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_184_5_e_d();".
// 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_184_5_e_d(:prec:=6)
    chi := MakeCharacter_184_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_184_5_e_d();".
// 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_184_5_e_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_184_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([<3,R![2125568, 0, 59049, 0, 486, 0, 1]>,<5,R![0, 1]>],Snew);
    return Vf;
end function;