
// Make newform 55.6.e.a in Magma, downloaded from the LMFDB on 03 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_55_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_55_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_55_6_e_a();".
// 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_55_6_e_a();".
// 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 := [9, 0, -5, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [0, -2, 0, 1], [-3, 0, 1, 0]];
    Rf_basisdens := [1, 1, 3, 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_55_e();"
function MakeCharacter_55_e()
    N := 55;
    order := 4;
    char_gens := [12, 46];
    v := [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_55_e_Hecke();"
function MakeCharacter_55_e_Hecke( : Kf := false)
    N := 55;
    order := 4;
    char_gens := [12, 46];
    char_values := [[0, 0, -1, 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 := 6;
    raw_aps := [[0, 0, 0, 0], [-15, 1, -16, 1], [0, 29, -43, 0], [0, 0, 0, 0], [0, -242, 121, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [260, 1501, -1241, 1501], [0, 0, 0, 0], [0, -4434, 2217, 0], [-3137, 5007, -1870, -5007], [0, 0, 0, 0], [0, 0, 0, 0], [9713, 5282, -14995, -5282], [-14165, 6476, -20641, 6476], [-14281, 0, 0, -28562], [0, 0, 0, 0], [-37837, 2757, 35080, -2757], [-66273, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, -91089, 0], [94838, -26493, -68345, 26493], [0, 0, 0, 0], [107885, 35526, 72359, 35526], [0, 0, 0, 0], [0, 0, 0, 0], [-67315, 57751, -125066, 57751], [0, 0, 0, 0], [0, 0, 0, 0], [78613, 106057, -184670, -106057], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-57062, -165993, 223055, 165993], [-17165, -198474, 181309, -198474], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, -840189, 0], [0, 504066, -252033, 0], [0, 585466, -292733, 0], [0, 0, 0, 0], [0, 0, 0, 0], [235194, 0, 0, 470388], [0, 0, 0, 0], [-344540, -441549, 97009, -441549], [0, 0, 0, 0], [323019, 0, 0, 646038], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-1848123, 0, 0, 0], [-145187, 630232, -485045, -630232], [0, 0, 0, 0], [624244, 0, 0, 1248488], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [3365052, 0, 0, 0], [1022510, 996201, 26309, 996201], [1856038, -429443, -1426595, 429443], [0, 2362566, -1181283, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [2439535, 499301, 1940234, 499301], [0, 0, 0, 0], [95788, -1504743, 1408955, 1504743], [0, 0, 0, 0], [-1587231, 0, 0, -3174462], [2972585, 712501, 2260084, 712501], [666919, 0, 0, 1333838], [-1697287, 1834332, -137045, -1834332], [0, -1790384, 895192, 0], [0, 0, 0, 0], [0, 0, -68664, 0], [0, -1462584, 731292, 0], [0, 0, 0, 0], [-1662965, 1779201, -3442166, 1779201], [0, 0, 0, 0], [-3163040, -2148949, -1014091, -2148949], [0, 0, 3634761, 0], [0, 0, 0, 0], [0, 0, 0, 0], [4441135, 1772451, 2668684, 1772451], [2940413, -2672293, -268120, 2672293], [0, 0, 0, 0], [3631988, -2863743, -768245, 2863743], [0, 0, 0, 0], [-2482806, 0, 0, -4965612], [0, 0, 0, 0], [-1267531, 0, 0, -2535062], [0, -769834, 384917, 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], [-1943737, -4166493, 6110230, 4166493], [4860863, 3191282, -8052145, -3191282], [0, 0, 0, 0], [0, 0, -14684364, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [9871663, -1817768, -8053895, 1817768], [0, 0, 1912711, 0], [12870277, 0, 0, 0], [0, -8644034, 4322017, 0], [10499360, 30951, 10468409, 30951], [-6615412, 6044207, 571205, -6044207], [-9278890, 2096251, -11375141, 2096251], [0, 0, 0, 0], [-21510073, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [11039885, 5347426, 5692459, 5347426], [25031327, 0, 0, 0], [0, 0, 0, 0], [0, 0, -25915639, 0], [0, 0, -30039, 0], [11982763, -6877743, -5105020, 6877743], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-25609373, 0, 0, 0], [-6061187, -7453668, 13514855, 7453668], [0, 0, 0, 0], [0, 0, 0, 0], [1272985, -9353524, 10626509, -9353524], [0, 0, 0, 0], [-506662, 10434107, -9927445, -10434107], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-20165665, -4626549, -15539116, -4626549], [0, 0, 0, 0], [0, 0, -19068689, 0], [3216169, 0, 0, 6432338], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 15048361, 0], [9914735, 13033426, -3118691, 13033426], [0, 0, 0, 0], [7122777, 0, 0, 0], [10070735, 13841526, -3770791, 13841526], [0, 0, 0, 0], [21181813, -11746818, -9434995, 11746818], [0, -15804484, 7902242, 0], [0, 0, 0, 0], [13364144, 0, 0, 26728288], [0, 0, 0, 0], [0, 0, 0, 0], [2024713, 15556807, -17581520, -15556807], [0, 0, 0, 0], [0, 0, 0, 0], [0, -22239334, 11119667, 0], [-17998237, -11062393, 29060630, 11062393], [30611635, 672551, 29939084, 672551], [0, -1696284, 848142, 0], [0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_55_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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