
// Make newform 150.12.a.b in Magma, downloaded from the LMFDB on 27 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_150_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_150_12_a_b();".
// 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_150_12_a_b();".
// 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_150_a();"
function MakeCharacter_150_a()
    N := 150;
    order := 1;
    char_gens := [101, 127];
    v := [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_150_a_Hecke( : Kf := Kf)
    return MakeCharacter_150_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 := 12;
    raw_aps := [[-32], [-243], [0], [-10556], [516912], [-1478402], [1265874], [7842380], [-1561032], [33939570], [14610032], [-290433266], [820995642], [328352908], [19932264], [1077746478], [-10780120560], [-9856407538], [13111086124], [-28727516928], [-13379419682], [51583351520], [-4311034212], [-8526268590], [-72302803586], [-138573578598], [-47953721372], [216496846644], [260696627390], [25912100298], [392101476604], [154546230432], [698512989234], [569975624060], [975905153250], [1203997375952], [1430249571694], [-1001831339252], [841106347224], [-1316435723082], [1727642535720], [1000764385382], [-2373651484008], [4797362505958], [7616574054414], [6088171386800], [196685115812], [-4989839793332], [-12301353212796], [6238908811070], [-2675126954262], [8065152935160], [6229736214242], [-21855004344648], [15453847004394], [-8441638957752], [-28301097765870], [33899914584872], [-7769902666946], [-49272237015918], [18007044822388], [59005208959758], [4519405968244], [91591752912], [102136230081598], [12549492648774], [-14218232162668], [35244733098934], [-168128247366036], [22726359483950], [-175692141086622], [124162125258840], [92321311516924], [196704583652518], [-238179683104180], [125137271270088], [293769711251010], [271848791736214], [19792844747802], [281573282740490], [102527101411680], [485174692810622], [-323025090144768], [-312897617042762], [252259167281360], [246561707094108], [250674203895450], [812064975593494], [217336636229562], [-313113890444252], [746814173072124], [57234293541720], [888726479204284], [-362887449668808], [-613698831230500], [1039266449375328], [264122091984690], [-431808144217278], [-335251531608332], [1596106033709342], [-583002426917036], [-1626613720265706], [-1847980105871052], [277613843986530], [1710435813535172], [7334643994654], [-2591480874028716], [-1531639167203142], [-1344382444530600], [-456173965271398], [-3136873777590956], [489523188989998], [-1212709907848326], [-1368002608229620], [1635764100095432], [-2716844303791758], [579459952964908], [1285315194112464], [-15736188946122], [-493248128424960], [-1009005252140938], [6596814296356918], [1821663157672254], [-1185517083456012], [3324052060806092], [5555588679734802], [-6862687608666610], [6345990074970480], [-1949442408095396], [-9194911712264762], [8934375504729260], [-5251015305787392], [8655828772576352], [6566938317921694], [1884230637681762], [-160666680754270], [-1746508893897282], [-13099639831345316], [3759561615897414], [7651288677752490], [-16156318661354788], [6862205057204922], [-11963565756135332], [1690364749463004], [6087127348793870], [14364131462465160], [12374136266246878], [10577013618153594], [22206822585616940], [8884047490156848], [-22361077063735346], [17726150455958682], [7415737759526188], [-15781475609583816], [-1527620019903956], [-9184289860022688], [237055717889480], [-26131782655127430], [-10693343975479466], [38816629263110442], [39830639969821764], [23560099508492178], [-47501235717716876], [-1669631901727128], [35508147994250754], [1916004996444288], [-9937495556261608], [-28739587940669786], [-53174702099774110], [-17299577983942002], [-19479374002931520], [68763885017598422], [-15345293922546168], [36109337741477038], [34683260159594960], [34400221329668850], [-46263579165860548], [10861207860150162], [-38172849610716452], [728513191631030], [11947204767455284], [-3468335007813408], [14157048114230158], [89902214555420514], [-12225973272882072], [64359641181868290], [69882707088475774], [52668491999301868], [-66028679760451030], [-38920940131963848], [4063650189285478], [-121754028500698452], [-5481990220674028], [136161298526321082], [41703618023247084], [-162632974482342942], [91588281792286802], [-137551357218510002], [136773728762803674], [-31712336072202432], [-573762955327830], [56143062124166432], [100991736304894534], [-51759896646172750], [-77163414378346560], [17373791882803254], [16721307134100320], [-147579417766120812], [-73222236442908990], [151526957506974692], [215399395761469414], [-54721029824533998], [123705388362243028], [-226347733466748756], [195551945811024480], [139269177837560522], [9726847179750604], [176329736415231162], [-73095778815098976], [117517839088658118], [215873103129381182], [-375862636004147200], [-106285389057004110], [-187075002553838732], [-327454302789208596], [29660684532343070], [278654323537687938], [105825947583256560], [-119732254496736836], [-77064855167616048], [-224820168303820322], [148723941405291140], [-431877688637903128], [252530294423715282], [153210558298661188], [-475920098976599616], [-364689523938183790], [-104498019132431442], [184712408147907600], [-399934203705447888], [498183315427844868], [-163383134721296668], [337773934226608108], [530775768390326750], [120135909067490178], [-2425566240202560], [666189640438800124], [402320024742723672], [-230811884810065180], [151140679966848288], [720469524469141414], [335015399421469602], [-129016780642282056], [717432206959835690], [-463811978207753802], [170303022391471680], [135278662959337622], [-389256320356408796], [301156993405226334], [-443001403470551906], [-545526864713526452], [612987346715075124], [235521448373802830], [450493983995208358], [26976728478556314], [686921893015117100], [-1016690281506674310], [-699192056413337478], [1167546416271141268], [751279279392487038], [-744641447430194458], [851480210329182964], [-291277751706271922], [356743182784426640], [-393440693969751146], [-877999890069106412], [-481522474977876516], [-724938165937201090], [693441240994092602], [-4779616402226688], [-929555493082462032], [-1620121777870088368], [-850392344036016336], [-605221754369912338], [-1761160704813931076], [941566422114432072], [-1862306453555282], [-562652592972164946], [-202418582143936480], [177069875388937410], [519047158887275802], [-1069841731289611956], [-2073587963856429702], [1041642710021598432], [604821738465272038], [-645116440548528150], [135944227237879952], [1102786178071661118], [-1835222166239462880], [-1535871032524889516], [-686862691102586642], [620381229865306614], [-1185150804543194200], [805887652040812428], [2136970381962107012], [1911835412681238574], [-1166700675012627996], [-1021100126026812730], [-2532596048157975840], [-1170977765864156522], [-2014558824688606752], [-1746622158810671670], [1697622031187787882], [370514957447861188], [-289568418922336416], [1042556183900142410], [233071648719808200], [664392314090549112], [-205216428863317802], [3380500567843977570], [2627912876032657532], [-3282267245413827266], [-2357878694202995358], [1653404473589691508], [-1947497635025122422], [-509151622478204638], [3151591972117657220], [-2543380433915647172], [987544069233216744], [817128409513311198], [-2552608440274169578], [1768967384405845734], [-558334623541818640], [2484001585521082908], [1678511383759791452], [4901709584764849524], [3918431944044446630], [-3064772528105901582], [3118987332493354682], [3581608825853595484], [191753555088608758], [-3429431376380155686], [2864547875077161690], [-160619935670160688], [-2716671302535780762], [2298881606699521560], [-419015985034373458], [3657315403863835564], [-1794411564993243048], [-5667236875399611906], [6687031576055811572], [4798631805831020854], [3190597356766442082], [6080088612922563388], [-1514629482482242090], [425558401470840858], [2729604292118043600], [345190712093816112], [547072110767713674], [-7709703224680484232], [-1975314655521008666], [-8417755094167623558], [2090392642662759864], [-1805766178346549760], [6556661318769056524], [6237309172368704518], [6087475290952780854], [104613587842984228], [-3447906671749025878], [1926994369912511832], [6101368586721036860], [2756556549843482808], [39014282968683450], [3141753059369905952], [-7926019068472666106], [-4723855021640709480], [6692455415318176992], [6094577664559060558], [-4824507720293043510], [-3291248961380041226], [-6183777879570373878], [4663819784989693938], [119169930569739364], [-4094611682003015406], [5722016893931658740], [2111528730971939448], [5934588121913325872], [-10725050421572509346], [-11922782231395887812], [1514415373727246784], [8568757562219836610], [-7152590018837513442], [13032995507605994400], [-9636750905551254356], [13062853690884687912], [-4770663299388826202], [-8657029071796338520], [-14444198953856719830], [3050354434269782132], [-3679084403251490958], [-3791340246232110250], [-10408902793025036022], [10940159151396872524], [13427837002216466754], [9840740926582232010], [-12596124887822600008], [-5176322435917236986], [4687288227606803802], [6567540328095922828], [-10771394123794299120], [1952631476059403038], [16423419128918708334], [-9662671959253036092], [-4650101241511579348], [11200021811316192094], [8375170554291469362], [-254093073644376480], [11085943654398778084], [13726426602243208314], [1577608844039128728], [-594448118584745910], [-6522558533313477626], [-11530995623666355096], [15034763981171084760], [-20356233079338414722], [8450797786183531494], [13482303074580357948], [9397454640762902730], [-547637736938485228], [8831032678295299800]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_150_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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