
// Make newform 112.6.a.e in Magma, downloaded from the LMFDB on 01 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_112_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_112_6_a_e();".
// 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_112_6_a_e();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_112_a();"
function MakeCharacter_112_a()
    N := 112;
    order := 1;
    char_gens := [15, 85, 17];
    v := [1, 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;

function MakeCharacter_112_a_Hecke( : Kf := Kf)
    return MakeCharacter_112_a();
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], [2], [-96], [-49], [720], [572], [1254], [94], [-96], [-4374], [6244], [-10798], [12006], [9160], [25836], [1014], [-1242], [7592], [-41132], [37632], [-13438], [-6248], [25254], [-45126], [107222], [47136], [-122204], [129636], [-220558], [170694], [249808], [-12210], [-13902], [431794], [326814], [-173480], [-54532], [-104960], [-160788], [360564], [312732], [-123820], [-323448], [-619954], [-499362], [785932], [-1062764], [-707720], [1044366], [-539716], [177114], [655464], [1387094], [-1888110], [346194], [929088], [382068], [1580560], [-1369114], [-394854], [-673034], [1834680], [1510558], [1875288], [-1510762], [2027094], [-1540088], [1011662], [2157480], [-1157980], [-3175662], [74616], [1798072], [2204606], [177568], [2874684], [-4799646], [-2816428], [-2837970], [154286], [-3728646], [-2326234], [2614824], [-1192258], [-1057928], [-4127556], [3758226], [-451114], [-1951860], [7202176], [-7178010], [-6176316], [-7593296], [1518780], [-1475756], [1313088], [4409316], [2976294], [-6346274], [-1366666], [9558184], [6942870], [-5246622], [3465510], [-4900688], [2283458], [-10315734], [3528378], [-2922600], [-11756710], [4714912], [213842], [-336666], [-14265530], [6596368], [-10248978], [4165426], [3350508], [-9054078], [-6453816], [14316728], [22724954], [-8532492], [22492092], [12689422], [-5139390], [-11606494], [-15099756], [23253556], [23781368], [2513920], [22264584], [-23010776], [15933458], [16862862], [-27540178], [22682040], [23426614], [-18205068], [14741094], [-16962914], [8039286], [-386648], [-35502060], [24881432], [-34145772], [25070060], [-18193842], [-6917966], [27806904], [3795866], [24890442], [3135676], [20243652], [6863236], [9406608], [21027976], [-43092762], [-3858622], [15960072], [4668312], [-34345686], [22818112], [-49404186], [7175418], [4222788], [-16564496], [-44097304], [-53177890], [-35702052], [35421324], [-7144516], [-34784832], [-10972678], [-44052764], [-26409438], [1197892], [-34798926], [-15350960], [39618344], [9727672], [3202722], [20729978], [8158650], [-18892848], [19911780], [47113454], [64380046], [52021202], [30813228], [54869378], [51089196], [-10064900], [-31059780], [-16452324], [87573954], [22620494], [31899146], [99653370], [90097560], [-54759954], [50364988], [-91288072], [29203034], [44201550], [-48906696], [-15940532], [-28899600], [29638974], [-49874246], [-21821794], [41950512], [-80043944], [78901686], [-77046312], [-97026850], [-124141760], [-119432562], [11326872], [-24487662], [19413626], [94748968], [24888978], [63210184], [-52933506], [-60272662], [-90961110], [23087400], [-23315648], [4367424], [-85448926], [27014362], [144732352], [35179674], [-109576562], [-20636160], [-42782938], [-17552178], [80343420], [449280], [87392376], [109394974], [19202080], [-16476370], [-16083030], [-149679444], [-8560880], [-137550498], [133797304], [-45607008], [142492310], [3505218], [105325776], [101973914], [-56249256], [-96178932], [159173402], [157424266], [-118179168], [70690430], [-114618248], [-192232512], [-66368896], [-55776040], [-226930698], [74797066], [51049926], [-130917318], [172528948], [-67875318], [152228852], [-201514952], [150469586], [72516256], [-90272782], [-258628592], [190653192], [-240179770], [-50215042], [-80152842], [93979032], [-136974296], [76290708], [23717672], [152311726], [-105117744], [194460866], [-278147970], [-132338060], [-18703662], [-108082242], [225875958], [-126435882], [-136777218], [-87516274], [178141908], [-231010688], [79800132], [-31157790], [-272873774], [-261514450], [-299717214], [216526768], [171127008], [-31394312], [235814522], [-67790376], [-230480320], [83657376], [-180267178], [-185211864], [-111404430], [-352842390], [-217342448], [-218952960], [203187194], [183347106], [-158698512], [-349733734], [-112865502], [297736522], [-286135918], [-14061480], [-310944536], [-186322410], [127288766], [-213806648], [12913870], [170557104], [-247805094], [305819270], [-154927518], [307335100], [-359040438], [-147673964], [28937166], [242263730], [111829650], [116998826], [-152291252], [-91269538], [-204892938], [426532596], [-272549120], [-301261422], [-76060872], [-86011180], [-171474944], [313184856], [-262065912], [98479090], [213849434], [171958542], [-217404932], [124575806], [79287762], [-176529852], [558644982], [569797842], [-154499664], [-198522706], [-490078494], [17470704], [231360756], [209406430], [550879574], [237000660], [-274067216], [-427965370], [-409729428], [255535522], [547067232], [408364110], [-526003544], [543323510], [-197758482], [470213688], [-289423366], [-406935114], [-65053618], [446798052], [-19996698], [-439463864], [-285041262], [-561300686], [369520104], [4522648], [236487680], [-15688868], [465550188], [-531439810], [76930032], [-6800844], [227277130], [-178325496], [649900034], [497060692], [664092534], [-302690252], [193416786], [365884280], [10286130], [-606117248], [455856078], [286858620], [-284214140], [680052110], [-252279522], [-194779478], [417294210], [-589524646], [-212883462], [-142243632], [-238137692], [443351114], [14073804], [-313625736], [-269726732], [428710230], [-320549376], [-437657790], [-11243368], [134829696], [306438330], [60597254], [-64500672], [318266328], [421209834], [-297126182], [493739004]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_112_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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