
// Make newform 150.16.a.i in Magma, downloaded from the LMFDB on 26 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_16_a_i();".
// 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_16_a_i();".
// 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 := 16;
    raw_aps := [[128], [2187], [0], [511994], [-19947598], [-180100962], [565654514], [-2169230520], [-3443072572], [58843361520], [-131248934648], [-1018926148246], [-678311212798], [1869778918508], [-2655546152576], [7733409097998], [12384358030090], [-28742040118198], [-62114558153336], [17045715067452], [94423385896028], [5162001412320], [-388824931818532], [64970078898710], [-424522131387176], [-177709374002648], [-1949811150984902], [372555317610444], [2740103649616690], [-699626894488362], [-3205200305551366], [6712557138359502], [-10844413821714546], [12615376536285460], [-12464672001689300], [-10554549363756248], [36978102636045694], [-48506299678334912], [43601049221812164], [-60605480460302822], [-153478914202170230], [-10000467220794598], [180720110114949852], [186896180346654908], [-193649441378353826], [161845995494356800], [-214782220815291948], [371663707150200578], [-343302268390027516], [-374140523970084130], [251954538080987218], [84351772907899460], [-723579916491786698], [-1734243169921805298], [1791991359640822494], [-357854591327201212], [1364227593734785680], [-3183427180050433448], [1650864006670616234], [-4538324553762181698], [928843477843005568], [-2603844300831937842], [-5872050445738583556], [-5358050378711457348], [7440431319694569788], [2788494565552935914], [-7873674761291663648], [-17561050714477042396], [11396976285171951324], [-15077967465800135150], [-5115803234699173502], [3548576255674028640], [4084661827533900314], [-5443172052212705922], [3692463884768353820], [-1996354258863293432], [-23331735564632804140], [19033236565496966474], [63354361068836480902], [-1887919994078984410], [88310664988893609830], [-5160603107606568098], [-1371941548663478848], [89055154155633838268], [103944186702906111360], [105338511745097191908], [-3217339342751527650], [99806011298923228544], [166323318329905463052], [30859918736860453038], [152378203529701883964], [227232878805190455620], [139207769647209402054], [-14679930299391670098], [-82365688948037515800], [-265595266433516071152], [230956559131357649040], [28394865963009308902], [-55858676952203099072], [531504783505788982402], [256790274763150689524], [-111260946935120219706], [455239059034877647588], [-393764384541105790570], [-287233988243462970848], [576068359934752949984], [-187451640716878583796], [-582417411057444019242], [105186119797004599200], [-814215776612091970798], [1168624112465762588494], [816930912036113268338], [1178616987701664618914], [785699420959185057980], [-151298562309778421248], [-1623455483808013677598], [1054364249654842661208], [1224828060559044925224], [-185742796817537529502], [-1950815011244337875810], [-2001357203113284344998], [1623619052808679094628], [-1504558788546763509766], [2049045121691698799468], [-458621778142912167248], [-3393850762668352319248], [1906589406093369185190], [-2301369040806431491720], [544327039242429126534], [1761374371412311370218], [-1241007160684135395440], [-5314722914143185548592], [5913136700608649379152], [2523534752326799560394], [-651888372932218117698], [-226931593062512113470], [-7328073053114355741822], [2158402026887609649104], [2720496181492116156074], [4324034325422763763890], [4482402099133025326252], [-1835416962418074885848], [14119227006122208856878], [2105623924501482792884], [9009375650605837184970], [6430138517659254489160], [16923930235980575052298], [-12818440241857214019606], [-3582854641008489627460], [-16285985063892700728612], [-3292831030661496773666], [5537285900013115930302], [4067470344500135614968], [-13945072161045847383996], [14353128339190657157244], [447214403177566907952], [18646140644880790590480], [-3423159385769332918530], [7731494659017798453304], [20556522484647103867652], [-14529469550007221947476], [-19386633429592380526802], [-11848592726468782872686], [41050833495516539233902], [-8481582727393538192166], [17076201329588972239768], [-25143053481791248134248], [-15334654212225448142826], [863372597735493604790], [-7538252468722439159262], [34859900937842424281730], [17041242805097446970502], [-59691096464128296456448], [27633027997779589778068], [-31003051371936944074040], [16406888122750347947550], [-57637351516752686730148], [-79016376054744078456948], [-49280190415946477891962], [-57856550839861151220370], [47028902805749858151254], [-43226799185054075891498], [54725048838737743897258], [-28494363017669414623026], [-40402080092136263119352], [-9023776841166226936860], [-30360916880862105549586], [-98702431224657140641472], [-7129756319036538632830], [-174799143281693740546748], [545441576560662522948], [-373339620352477607812], [-39245775200825593238948], [63698402982406970735052], [-154034610549688118849796], [4608509780321515179558], [115126830671080517889102], [204548575408273912343838], [149903809480013078342814], [273618641867646895899928], [-129338931728181185101380], [38912557406500085516352], [-126072963152573744181546], [256540766835116411462350], [-275597013243930626897710], [255193485715853698676934], [-132813508640888115422880], [68378370248113310332268], [-280613983032465425795090], [366399487301622399437152], [-107024049005054297934476], [352812300007011935298252], [-331037909248162567157702], [279404249478394215965244], [67713136416759040743580], [-373935842248913158270298], [195863619957957603666034], [-450368744472385854103898], [-49884490337432932652336], [13837390634599444135478], [618315845209983231831702], [-646831510668996598213400], [677813077213219497264690], [-697900624085063953160522], [-451787566604029553695716], [336498321553983231536070], [174587194065800111890718], [232449825241576914400360], [56847038929745054572174], [-515215114357863563345998], [37384195792539084563398], [-98273992177733088874460], [809454538038803654209952], [-1076180031059513255951298], [-1168291738125101039255032], [184957658546829084867404], [-660176227562465147572290], [150998801211316666335958], [-532109748208331845413150], [-756984727303992426294948], [697855146748959386521428], [266186163005757177402152], [-568431670163866891200442], [-754580720797929447059150], [290355199834097876284298], [-882425866364179897975860], [953097837652574525583714], [-406981858468407344304198], [-1675455620718645319080880], [263113748242469401441268], [-1493218521124438987882926], [-543562229975056101887998], [-1734505972155600838617356], [1441073273492579723472790], [2027256548357496329307238], [1154536180567286887729230], [-1171859096899711638247598], [803293311606534294037384], [-1109577035845323466774946], [-239251797247763559350756], [-2159347295904847645697262], [-1234633985055398191783036], [-2242454684686618737047570], [-992947452304051905190742], [-65621654224980890115426], [1884138080972419024085600], [-1834687887679062330892860], [-2382897686810221744163998], [-2016164877093752780977072], [-2157372138226887162566982], [3801615730128229139219702], [-1453140695865016586513876], [422021246571671769379948], [1922842864203558254647240], [-402200508936637399572316], [1919931020986498809949018], [2420166983658129063487204], [210332931930570422135810], [-887762551971649886309098], [-2033494904550616782701298], [-4210009599078088123287972], [3529146351191884180234352], [-4608991502367053344183376], [5705144809564387454903902], [-1423814051052721754804636], [1683874522549190806429652], [4192654551556574823653928], [297243135328316814731434], [318113615768057782731320], [4210715588540483235931010], [1807320868453589499718052], [4714939168493744943206844], [641178196326513035116938], [-4083772300271262103881798], [7757079861368841568853618], [-3012416776355603856596100], [1284066057593220882778752], [68735046580549230546978], [-5804884517486843929975630], [1330783550143005392197404], [2790302115208244689708108], [2199738971343940660729074], [877044131696535574869800], [-6110495047417719643845852], [710053639069386308643752], [7089486377298792498736064], [227534954137384219597084], [-8611617268488233773424530], [-9578540382088970598888740], [371913327056891702679198], [3016142060316293044595388], [-11067994497002052172740720], [-2025045046709869332743298], [5361644388934868277372468], [-11341779621380514558605896], [13084653227375406822612710], [-14843629166542787280562550], [3066774916280162755668652], [8797541261792482151596988], [11644114999187510394567570], [-4604506886358743609414848], [9427061822406486203458204], [-9034922997293564158954248], [5827539496008447542930558], [6165357531505097195782698], [-13710565847739817136343898], [-19911786249377494335519180], [-6524479028052392279627052], [16154992823728746308946344], [22604276820958423300809938], [15156054631013144322017902], [-5741947273021241805927946], [-11974908648253675039020040], [-21578837588354170125541292], [5980378877285214955053252], [1128299049609767857527564], [5417840628477555058085830], [-8225418931575774792872622], [3515968264829693706317002], [-3836508518241672187903846], [8438703337630734226261758], [-4330112375449720818871526], [3642820411746213559900040], [1414035771342937919146352], [26109779433282773397976118], [21323765504512700463764610], [24551366176361196939313302], [-33437700464322039697675676], [-7123663467909415852448948], [-17588943601240597208419806], [-25972254732177554985962548], [-11684648694378204261260016], [24738556647493175395880352], [-5029484840662369888099182], [12010514959735290649156010], [43132396725014933748294858], [30270162380529418619851200], [-1246563629881507685961798], [25780728397537602774870614], [-30701467282669031029359772], [6767797512514864333883654], [21232382352105039766555602], [-42624130476400465886589576], [6786697251834672239017490], [-9134239812613851866220936], [-37905874893278845986691072], [35179822954774169334548934], [-14963037914633575603986102], [6963823512196879764525402], [58009586018137753825788802], [-10949551380507420806879140], [-56740980901680525710269192], [-15164479002859333978033200], [-840641173597374768528648], [-3829544295436317652692006], [-46950433371389307774958030], [1146709863156365691197752], [-30395423899828548415251192], [-33167496535951781122962210], [-67619564131410409903744136], [13119056244672217601108652], [70874330615218182905229718], [-44983648911228428639879726], [-67229313607089661558079006], [38175831068013232776648540], [-9071976999745879948041012], [44866443199842307619281752], [43141193146630260685790434], [-87210015017143624023093732], [-22744945526722819679232796], [-74863700573748963377156590], [-15577551418433707851297042], [-55508406734120386462566750], [-9131542944380742330333656], [-39583480759785747865345448], [85304419145804849557810688], [-56111421958681382772721720], [11239317618854183418460570], [-100406063059249390811430448], [-66038705968204429337103348], [67645642802798176116631750], [-17769406281670042354857202], [-8255235855900011914894286], [71481500998328523616935534], [36772562048640872894865360], [-42856362641136960927619648], [-92557192499379645271208526], [-43160078074343576890580298], [-104652819394454881275203552], [25000473284582352600411030], [-28636659828627791767840232], [59530049764503680524629654], [101111366043515805054594708], [118624484000408482838132752], [28041370557104092998925244], [-58425922176188735154750448], [135398606075674439065772120], [114422659779566550142718154], [-124619486470675639593582826], [21983472006151747388639148], [120782853930034512599431740], [35111525102523466890482014], [-162760751401536733032736816], [-129271577983364547371263890], [116345444475605989930653748], [164038090749844489772381094], [34708805560540050881236588], [-100730671632036289725236870], [44120375716694672176614552], [-71604124053386986545687400]];
    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_16_a_i();".
// 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_16_a_i(:prec:=1)
    chi := MakeCharacter_150_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 16));
    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_16_a_i();".
// 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_16_a_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_150_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,16,sign)));
    Vf := Kernel([<7,R![-511994, 1]>],Snew);
    return Vf;
end function;