
// Make newform 64.22.a.b in Magma, downloaded from the LMFDB on 01 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_64_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_64_22_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_64_22_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_64_a();"
function MakeCharacter_64_a()
    N := 64;
    order := 1;
    char_gens := [63, 5];
    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_64_a_Hecke( : Kf := Kf)
    return MakeCharacter_64_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 := 22;
    raw_aps := [[0], [-71604], [28693770], [-853202392], [-86731179612], [895323442786], [3257566804818], [-23032467644420], [146495714575224], [734051633521170], [-3146664162057568], [12963813600992362], [45714648841476042], [24073607797047556], [-449991905173684752], [-2064837217091540454], [3780497099978396340], [7619813346829729138], [18791158016925310732], [-4526486567453771928], [-25571455286910443926], [99336442530925070480], [-2958180217887529284], [118802976167736540090], [-569053013925353654302], [265047048338677414698], [1512935754254011024904], [1785675547468913713092], [-3338942741755898173310], [-3047118204055779681486], [-7046800725771337766272], [-9427867190096541370932], [-2017533314391401983062], [-33865264915070239467740], [34079959428680529569850], [23885647990935177756152], [-127314886015670115483758], [236288953992980513192236], [-315463511837579624680632], [-408353460952695284240574], [-791545410335895474841380], [473054721711831778539418], [-427959738699386191929408], [-1884760392211834475423806], [-83241567090843147644598], [-881455250662631920447000], [-3797550729150071156329412], [-3920107127321192536694176], [1121734352066837891182572], [-379307217709669305087830], [4030144405347173314557834], [-17522048813246623378977360], [9552133818580811872325042], [-6296547800140430825898252], [-14524765786236504589593342], [41342962954132574260961064], [51878570377323278171314530], [-23553826435387451936606128], [-52904105139417754673924678], [21792171284949614354133882], [5392430288981782341279316], [-39294676877561267880966294], [-123827318580164600252070308], [-158511379146348935490707688], [115881584741861386662732314], [50975779742185771293370482], [464134020445434542696141668], [-239093179636632420666532462], [301925308006396494675864852], [-492020983346494986609531950], [-669642632250722639053929246], [589124263059407340786449160], [-1618266915829412340575610832], [-112579202034963751946996774], [-1616874318052205334583223180], [-73013893676511524154278016], [-438997518622505007172239990], [1338521091709647064305624802], [-2072923943891327771383530798], [-412923669842691251058870790], [3559210567975067847593767980], [3996632669868149870150739178], [5742956413481608410072178032], [-6992135823463285126278541966], [-8740474328485645446348678760], [-11596709344144857802512676044], [6440839322514293445293894850], [-8276915222804485644310571542], [-4933147331864705955692077662], [-415139487664832346118756336], [-7307155677489662257971433668], [-13080548385678253201942415520], [-16813115918246289849943009912], [26738164707817603151549347908], [-19281859530195414626414675300], [2463402983903575706661631704], [-23478179567484233200753496910], [56582032760739513813733466922], [27453766121000429572269600676], [15430221003738954722123991058], [-8664921669005824603602558548], [-112653488718625007329904797758], [130345396925477251715822297436], [164552366743807821178715494170], [96958900506454165565509839028], [12542250400692596322826579778], [213235652966683779290797133412], [57418199856529657106180674194], [-11846072718437094733470160200], [16056689917222854927998019002], [99070060802763663306292503008], [-145877135114140364954020749014], [-95243845705182102603213428982], [336525912761645691571862525380], [8771080533827159585904243032], [42990281080730811456147725442], [-46199901992538900428170581044], [-45411813323240362323973624152], [164555941238120525227393982946], [-221389916995486531002096073860], [-254394831229743764289147486662], [799394244878065083081357879074], [-461946924086047662480530272278], [-335857355322094845126852873084], [441273495252691238145124044508], [-123968785607929950674469945102], [-1276074245894460529902579837110], [1070392289269778886827136744720], [-764278698848274688454979164872], [1187553525852339745344419933266], [-162225251592843254165173393940], [1094988252098955975120227076744], [-1438762669406955031347767380048], [-213374429940988937302182069158], [3158544482401209831390188998362], [-1202659763824440492519723800830], [2339222997718673102508064994826], [1293440098633969802449152348412], [415582403609351710732989629202], [-6347072519824556191947068180790], [1032888644525031562803272323588], [-5483613524943472364227348514022], [1507506192096169319885327878424], [-3249155070851260137225098058828], [3886790247853883603726166355570], [-4764998790453395984103328868760], [-2097052528344691479608069080454], [5935968785987718270336728105658], [2890455276866999727659977368340], [-5573440222025942703450825935136], [-3236225059799106419468034647678], [3379995690738990470919052114482], [4759787254227798299130166149916], [4280651358276493486873070528088], [-4034976075011996840266010015708], [-10096467239240028058405450371888], [-20486929945706841944680941462280], [11515473132924391938185930832930], [14017215590826459130638327032138], [9635116267138341102510755131458], [-17081750088079456099460808832548], [-14323852728450966130346022975846], [14395055447805158059753603035368], [26710664490288908787947401766628], [-36371391566654659323543046448622], [-28107782704212233894824622761416], [32003754467851191489652033085792], [42102803915535171188847887436202], [-16747334593315040953044628026190], [-54117802606553595910567702735014], [52474681541886134742744673800180], [33573513190557001428617504371378], [-61862821671785150221698435793368], [80657042504529959411384222811434], [25331759319017563079567929685840], [-1006923244954005837978898345350], [-83911862838966807832657265889452], [-22678069183892908374789750151062], [115723541056935351743003383409864], [7686716011172110022689797729730], [112832938444280041072483017197888], [22082518087482302491203403082508], [-127605455324219134257184981360694], [-19457598071895403048472244202902], [128453341258361467713294328028304], [41493258080241762517045801485690], [76636473951361876301248378627282], [118413180928988504187322863021676], [10033791855689003358180460222730], [-12923643099278782148390244286848], [-68150217056671676156847121957246], [177072230941418245088513436844836], [79077181917370811278138923112828], [-294745830695811816215686445212782], [-278509928487376452886164159371988], [301582791504867861290977637547594], [13040478957138059967445944255602], [-94934406615711655457827579603214], [-363555385154903604032772235525182], [155769417880512138725670780200424], [276484776766832406128784527851170], [240963007993532976341417759516432], [330053709380368358402206908314362], [579592614270303015524277434199650], [42723947596729944519097994889540], [-341940414602761156417839711859278], [-700799737090987208289031414961920], [-338187855879761081449315483029684], [-444933039766054387876084575217110], [-524871900817181243768231029497692], [-68206117801010126062958972509102], [270293574399617180092121136583098], [-196925896826036526288068530287496], [-836462796720921876244285492065708], [-307134754907467075755665419738680], [-418985888798853522457918842183478], [189119593890962949474634634290928], [-1493635010567204445172402840381038], [81822122419397916395780262627768], [-856918428902772757918770795696174], [-619184009537197209079505489268182], [211094055130016360632528719450200], [1871011971412392755779843420609410], [1091006991370070096805234206742224], [-573521765144391032575027219581828], [-1580687866470745849326911224389830], [564464849907145031605056523952634], [-1986446160289605121659541374536160], [32600675173845735481998801714248], [135313541765107453130383316034948], [-762040192356161433900592442309054], [2510364555143732781983875533438940], [-1580533274057004756705452484228928], [-1600584147917528263506304178986518], [1589908672673205144276748860710116], [721737180714852222623838669519888], [1598802291214870089719007427331090], [880696627311666894034933133901306], [-1927584752833907596186824144398700], [-3918914463658998867599950575687288], [-524585890883968457083581164935524], [-1878043839009696522928986633566732], [-982661509376536656165104304183256], [-506851662011221299051296989032350], [903053509069657562797424547107154], [-2052323968956664460387375516040840], [4782291114051055084166636933521568], [-3928452832362845403230160556159572], [1679747101168704763985216228303620], [-7198965195613909087906794959897616], [5521491620612231231681909621510002], [5624373168065507264142198532129602], [-1407707237755675472646288931555992], [-5758276314952936942371029388010390], [-5746261192408871391142759878715614], [-4233033651544094526101742707652420], [-9311152773150149077995254563980422], [3172649398392202656187866943050772], [-1708877280654269353423509960180438], [-6135075138016013057393738169259942], [4036179445685060256586656124840064], [-1346229062799070964270532306569268], [-8986890727171325744358907964177270], [8309614158730294212636628683157906], [-1480520579407989011515735692641502], [-1263207057704977077742646656140500], [16902592540809256152825230608007490], [-3024005134715795549668842694181478], [-2461335746094402574556446295256524], [13463945997321772418925773547496266], [-9435741360881398783577270901115742], [2052161158776780926325036070139452], [-2647399315183183407617391783701446], [3924297790198339468765904137969760], [11379405589260112436421265479443378], [3281633148543531906158730646093784], [-12876064630870247071160910322450188], [17627747479527844138546984451519410], [17502148556188752540050649534940202], [18814764719349879612694330860788988], [-20689806995214494179361802973678176], [10687039161828274641714982902565832], [-12381531883392780231675314672837352], [-24191164813017124398392000063729462], [-8855228194643109459120283502439068], [-44491843421039743371614407446127728], [-11618888241198759375596260957961326], [18006375589460708609124922597926522], [-31002994452329213427058460521090120], [-36992327583666981180291541716122910], [-28762864087803465466981752766757502], [-53649092578199480579211151259259108], [51567954140782255968873538843194714], [-16760359317185877812678768289082332], [-4478857923978069809872944741979934], [57968724133618882845487476322376850], [30194347281521860370791814222929952], [-24943391166230170407398990903446374], [29733476116439590492255188411968820], [76383089034615213591003110632278412], [-35930116137375442291337189733264406], [-909063517400736502530889240162398], [-70874097606249085678880293980002800], [-73483040246260441442414074293636804], [31912480266509655776607003899120788], [22284989665036228253870319974258018], [18824639268336137290528452609800772], [33169479887234803307649007442125570], [101145670423098284036141560163841240], [12024801091748025385161654239943946], [-29567762698202009788013200510121136], [78936834058802755162589425594335930], [58424553643023034105595043899742882], [-14005070558636437192902097069030484], [-85219872601173859271883727364390712], [58854138774471000924869090877446090], [-39953332543641670600895953193000100], [-64967661013620984642630057684804288], [-75846775002332383697507581092573886], [-38418099167381724482108516344917870], [23156123523749072305740115144916668], [136322628463092074480221494406007738], [-82162158970939593530715503362301742], [-91414663877542950622422240185114656], [-186760660515699768904944398703629046], [705941389091412558857360666118962], [-119082491830395487762186865962275380], [-4166128440660253625680753748617004], [62826083790509392836424356565202208], [-911652912178302954709163373665814], [-153107327556867546764153926253074622], [32702553628059873767812907711787762], [140115101766497502291488761177442240], [-88015076418466099102801202518006644], [-911183619647724965918357988749852], [56096243059629328346700899637258132], [83344913043808383363944155344834130], [75819289219479609149568061313983074], [-113401625758122370644541717522022518], [-13690271891139781295052374298348112], [-177915065413768633311182232366416294], [27679371365057116308627154809441498], [-6435261965340425539264371244165110], [31276042015075607724698610343036712], [383140004758848151968692219082786066], [-110836186415624647995965600787661140], [80863102433382169328959964679159658], [-64663081607027963748527552495127548], [428306559138574411150208528297114352], [-157239410868720352459124174572630758], [447689912752655194778183381043606028], [340454876670179274598372222153007978], [408639392464174965020681593630890018], [-116386045602694086528451702494165616], [305263533350772830307571091976793210], [146532396696991467544651324811409594], [-164695651583563078844542468094004000], [-59652981989077073470373365527735612], [118333802272043823889264083049504818], [-25605292120180305412601141041060776], [-191983820900213468324913475936914038], [-149669003098656990080094533071075158], [664780797658761811854935990848432848], [419845127468324291869980059794371540], [529937033862326276008219321635826732], [486263649973340555085410209237190474], [123530655651750800523099854604550722], [499375360804332449792145278802652904], [17726637475786476343926571941739322], [-734532981327129977133522686189485332], [721268782086533969574183457549217860], [-625013110735322667104035975838315856], [-95535437618452316989741256820790950], [-97891441529264866360147781597438248], [-116157564719155035229724383988468558], [519247279541565723714770754756365820], [-560241220062024446681386042494880608], [585607846970315299451592128088415394], [-1319208870643825658656466997853413390], [-1464408930520028854708411497301655782], [-70334480978923393760373969174471822], [-807224523521716819657080368000591766], [505658111261784365359509369410097848], [14236601915745798016886086704357858], [-588466350771198577545571173502496660], [515370015872699101483353610676525064], [-1311688287858526732765585076790520528], [-1500405765630610702716635456310647078], [18284024893360704875902006467833716], [71454586079663427107251076410178688], [-907494802920681943907302699496637310], [-681343150744088021862583935173701494], [1479638282457721361868551782561400100], [-1344065520482300557942547247920178308], [-546101616415625488902135467528826888], [-708076006350060722125639323829300486], [-170204652128798772674844521614893280], [1070146293679910197419002854224249930], [-2237605748752226869245748317177918332], [-1127357961586570893889097215406000742], [-2065558170655041481327879768969787150], [-1247239859616414285729958884748547646], [-1581614454898590467905478018376981232], [1713659287254906619092720799580549178], [-1992343339969537241825309095396559190], [759059909692770085616167748219040392], [199246476974863995898216417916441602], [734387399596664265884524853000724402], [597893475890919349387681791157546396], [2339502390910191169021653853299355980], [-1024779078529570685989245217728808366], [688963637205205161189450779225285562], [-553313850498106497113557286341014444], [1683971540213884028940673069071922348], [-2541543330165511891749800972812511542], [2554704716174662835151353776614214338], [1773179030601356913880591379078306880], [-3040977064684060242999813635554607512], [-2720333359913934824099328394578798702], [-868729673480286127149935093387802696], [3817024958330065166777806966986113490], [-505932571448646827278793180107996118], [882432928480062978556113174781831728], [1423264867366157553293653682945043060], [91192543340341982741198528441424554], [-4189699485439872136274810197709814558], [2759891323674822671463984653174707836], [789487150963193879230475904168370170], [2746210819833443228437041357361039828], [947712943101595246950317109775330200]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_64_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_64_22_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_64_22_a_b(:prec:=1)
    chi := MakeCharacter_64_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 22));
    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_64_22_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_64_22_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_64_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,22,sign)));
    Vf := Kernel([<3,R![71604, 1]>],Snew);
    return Vf;
end function;