
// Make newform 126.12.a.h in Magma, downloaded from the LMFDB on 18 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_126_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_126_12_a_h();".
// 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_126_12_a_h();".
// 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_126_a();"
function MakeCharacter_126_a()
    N := 126;
    order := 1;
    char_gens := [29, 73];
    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_126_a_Hecke( : Kf := Kf)
    return MakeCharacter_126_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], [0], [8010], [16807], [-452052], [-1091458], [-9665922], [-3348844], [-59956344], [55940106], [-128343952], [-578037778], [840886998], [333428], [-333958944], [3918222258], [7463827092], [-1084935010], [5115031244], [-29627533944], [-23084922598], [28623995312], [18819334956], [-45381862410], [30119202770], [-51427450710], [-201044492344], [193879485084], [125676461414], [285116021358], [-376078463728], [339781513212], [480043949958], [-491748022036], [-1140211559790], [-652649360008], [898538507054], [1365293897372], [-1757998926984], [1310161182594], [1322690531460], [-1605178457098], [-2622297371232], [-2933414951806], [1383064446114], [-6477814140856], [-7107998608900], [8059271507744], [16200914381244], [5556157741286], [7133042307270], [2955097486176], [9771329897474], [-1163258905500], [29518243861950], [22651095594888], [36934360126818], [3305725092560], [11519323107854], [-51293340072330], [-40454841587860], [4603703080650], [-41195690286316], [-18634863624], [29386838016986], [-96581178662214], [63632373007892], [-82823141871694], [-126365840303748], [36177190696526], [126292398888510], [-34557535289544], [-188092956089776], [26775321235982], [-231233280693820], [-40583006940240], [-299854464625998], [266310462109214], [-221197550827986], [432959635604474], [-28031353420980], [-391965102092866], [263663179093248], [-609007566144382], [-512595762414232], [465655465680684], [-299843404031106], [442804301406554], [39269600770818], [-201069990570448], [-240189524758068], [482039077025808], [-342776073612184], [-468144548822820], [364923774590012], [-1050469269663816], [-10000364695470], [515248405301526], [997178445115004], [-1299841690350778], [-848247454354180], [978521354921706], [-1204768287534372], [-1686331622452746], [2379003924308804], [585496849229282], [971273427520116], [1080113522309166], [-1869688020846120], [-3029400954476662], [-1402443699813856], [478434758269646], [-7823979007482], [1301101159486172], [-3424261934414104], [-2460040473010914], [-3324621936380716], [5218765433015352], [4371634125862362], [1502311982847924], [115627899213638], [1941679749263234], [-3463705885956870], [-4255434308801028], [-3185860856047852], [6393585565605834], [-1141485082262194], [-9797036818439904], [8098176614693432], [7804202238035198], [4886113391569244], [1323959397839736], [1902403043313920], [-7418078249748226], [4486872142228806], [9788035281733970], [14550070726300650], [-1865943931816396], [3150694623588594], [7191033006469830], [6968081027207036], [-3667774352355822], [20840613492650984], [3520820189262060], [16780300285314782], [2724573171497880], [16998473129640566], [-924078229591482], [1212240641326460], [-23915060014726464], [20807680194784646], [4898664026201070], [-5699978347679332], [-18558309707775000], [1982437974533732], [-32116803801298656], [12747766237597640], [3368676570993870], [6666490155866618], [-31815701199014190], [-26463577297109484], [15995354075786070], [-28929537586382392], [6404811124505124], [30866611112179374], [-24142395591747288], [-52218400819060096], [26992223145213494], [13610043785332946], [65419919814307050], [-67934711096259156], [50532876606103694], [6626661617435400], [-13616882605773094], [-34332160082319136], [6994266827280342], [-46069069384737292], [50420489668310130], [1836622842771512], [3841600728828974], [-25487280194396944], [71738087136226284], [-53467520657010130], [-100772828639556666], [-50745373975209120], [-63816646179787542], [89557997546884358], [-47812053334260028], [-81519322441530214], [50889166227384720], [103863634187868578], [-43227126218243364], [-100879753208082244], [-124387580615138670], [15710361258792084], [108674320905248934], [-60006407243909230], [-445984251521386], [-137329095133806018], [102353467426550760], [145950718089704682], [73045318766976032], [-82294438944039994], [49972843907233250], [39262440621656484], [120260954867205282], [-69579550895329168], [46154517929280036], [-121787761616123802], [112551379512310700], [-210301235244183022], [139785592573208346], [6008148282349688], [-120480905122157100], [-262671640571497848], [-39339376779335926], [-194718441105147376], [5051940586495614], [124679108745978456], [-186509314481709270], [293172899447548142], [177555051611037800], [-235670694314902146], [-111423397962530176], [-31067526908059284], [-333380352777906946], [131983484703686070], [-124895376058624176], [-30525611854977256], [306352608241920972], [-18099310605687226], [-64802000979043612], [268965154452929984], [235525017168168870], [-369527487618568036], [58195636996668912], [171325666468021058], [-95599293532135278], [-234250819770057780], [-432730595945999160], [411080996484819252], [-570211823015724148], [72672332585873912], [566311336285913750], [-263008327491162930], [-475662695447920440], [-290605116024973600], [46002523382530140], [-360278219131105708], [377730302258901456], [-428313456576863002], [572146671391699998], [-540792665107585944], [234953861486718362], [-630115058152640142], [-43995252906637404], [-638845527431834242], [-147162324500574340], [228846187037551338], [263651940884799002], [-255931209952634416], [823936615698840996], [-325302579436917322], [-986516834519945986], [449494031623696302], [342777108724819412], [-718410055190639094], [-440570864791798890], [-1038875274244934956], [-231262977889651758], [748261362074835230], [-690002952963128404], [-497037606238924438], [-240849995957276176], [161127738822807314], [-578714376310738648], [-424922874023080260], [121157143565418950], [-975546047652078310], [638833437283052652], [-1368772344479915232], [1224961160103924344], [-25007856188382744], [1139396376267028886], [1104213126475470428], [1480791914443572960], [1178381949669882866], [1080946397292604530], [845338978687038584], [-1573299493749144450], [234028752636118410], [-334753442114902068], [1977551789840855190], [1111155585552413412], [-1400182169461157002], [-1329113066235257166], [437401928586240896], [-1077129249462261366], [120450350993779236], [-989656298425226380], [1571472226207666250], [842656570500484794], [-1077949686317728336], [-1754311710769640652], [2099284236561038948], [886444184151358274], [1755963424851460236], [-2152469660330936242], [1530220259920513032], [1609886490807605150], [-1270702200998266032], [2806316175430669506], [-1881745118607285570], [2695359523200810236], [767312120330455176], [-64059665403640390], [1756144363336832028], [703345454145970176], [789529449623965250], [185182344241829070], [-1898787085435586236], [2953561946883124778], [-742352700246635070], [3139598504439473312], [-1315090200594574458], [-1504222630490384638], [-77492491080628516], [-1118965552985130484], [1171949648202582576], [-2792952819341923950], [-1281325368584312554], [-98956306773012534], [1352594086348225424], [223338196111283532], [-1099622771832141052], [-1901662975425384684], [-4451771351197959370], [-1099278577220190786], [-373013703072793126], [-4806090692703714112], [-4827134692724598418], [-3026052505235329674], [-1704094817847391974], [974624994786195032], [-2856359342697104406], [-738108043487771868], [1220237810117687558], [-2390853940370450284], [5508691799720643120], [891702012585618714], [2419224021003071924], [-772464756005764198], [-1276969676390480982], [-4646091932952551968], [-517351155549808690], [-5506115572093297770], [523981003461964560], [-5045934621704554236], [-1780131999475618578], [18398646194875752], [-2151571318500147394], [-504606116650965978], [-6826705046591157696], [-4766019453745963860], [1889227777351782980], [5429477414211876410], [-1256600915076175998], [4414020482840309768], [2577430519690121354], [4476157349749025364], [5428954740546870284], [3362627550579065424], [-6455786990148161934], [-1708688344554108856], [9751233013596005798], [-5778293734765874580], [2755597432180355856], [-5415573304623162526], [-8027118884355026370], [6387577338457829786], [-5196851977980968622], [7140332763976543206], [-11988512473923080440], [9834244274279958750], [10894889266160410484], [-5600773753115669688], [6161595616264304336], [10606395309116720966], [-6698991866428667500], [10923472907604920976], [-6480630836479155838], [-3175914001926745398], [-66726089967571716], [9681763193430288260], [3041256443483439240], [13226562213565523498], [-6547797383181369424], [-3316202646237329226], [3753197203834006820], [-411671811215214078], [5651101805298027614], [-6203443774715165058], [-2448577878627393424], [15577891465371938118], [9330321140090747034], [9040015796610069128], [6166180526899275734], [-7839559808767104018], [5116114277154775268], [-13859935997740740948], [-12712090343918183950], [-839184041929904958], [10152299512740697884], [-11120666155934672884], [5027187510166988474], [-3982773639527673054], [-490427867340741120], [14165497110479964872], [15773645425148603550], [8826486123290586264], [-6257250511562895030], [1518915492016960502], [753476234949521616], [13714936903833606852], [8798838934150817930], [9757405825950351378], [-10526106000624334572], [16190950578879257910], [-8484931425378534820], [-14185705957346953656]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_126_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_126_12_a_h();".
// 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_126_12_a_h(:prec:=1)
    chi := MakeCharacter_126_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_126_12_a_h();".
// 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_126_12_a_h( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_126_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,12,sign)));
    Vf := Kernel([<5,R![-8010, 1]>],Snew);
    return Vf;
end function;