
// Make newform 2.44.a.a in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_2_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_2_44_a_a();".
// 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_2_44_a_a();".
// 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
        poly := [-24394519512, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-21120, 42240]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_2_a();"
function MakeCharacter_2_a()
    N := 2;
    order := 1;
    char_gens := [];
    v := [];
    // 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_2_a_Hecke(Kf)
    return MakeCharacter_2_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+1)]];
    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 := 44;
    raw_aps := [[-2097152, 0], [-6490815492, -1], [-199331355641250, 283500], [587435016771620504, -190730538], [-5808903936010398703788, 4407651659061], [-829439551393159183136842, -59681996510292], [171580704983012252952909234, 26766690090947208], [-263267806549174075809279700, -403392382384796181], [114727990861989599086385316168, 16797585459534273954], [17068075245553471427686159675110, -1976829131548273028292], [81154928223519412349413657984352, 4968280242640404746712], [-2195803715934317556161449819436866, -833090368510760425478532], [36637236741408330035293993005091962, -788670075973152985039152], [117218292949497051503299353563641268, 12301171524928386911221677], [-19557299274236966415628401363450096, 190954357558026292479787812], [10720900064483588257865104517457751278, 1836583387369068780784734588], [33990893211788122595985056477168078820, -14135369480649289542271797639], [5275434614905378277891132118025791302, 23120535392203217539605508044], [-648004348498219942349671953845743524676, 279894462034250269406124440271], [5289168200138904008327499989307702412632, 349144511456237982020818091334], [-541857480409739611711405890594928615462, -139274248728763165591537722072], [-33391347038843772504151318987640297910160, 888344988089995425193512118524], [274824100352152947810763260563361515944428, -4959588771707265663302646060165], [149054224330507981040336236010590991772810, -107705914297774293831717945665880], [-1137672461139522118300059131627093376419806, 692407305675057640880002254817320], [967523305079500593622718853139514741058942, 307322603996220395111957051012508], [5851783237487545095795064929996178821397688, -92314371599109054282660464654370], [-29638447958763551528200753808197404421371276, -1098871187524251284132629741519299], [-37358956795027757354909597132574645974641450, -442008814953114429143806579992228], [19480392693809290409649222441352649432349138, -24263743861626737739907763188305216], [-148122460763631818759244268126060176877173376, -325702193941704139426024339533506784], [-3735648037381026080868490032191345239424641668, 166708338924164894783215129656697023], [11846273066158291030196610800206897502154560154, -563727077127600875617592389068260208], [5418102364287953364478674707360971866323171540, 911622923314688338305121340995066101], [21104240166146568320253471271977790545162382350, -650269791609760664578575122279064660], [12695151658506253311636230535803061136103972552, -8157094620180373863747661848284110590], [-24093443460825250320292057120228657263103694746, -11470707065526870614817171584370708], [-43401012974205777485196640139818246472475997732, 55494624383389130285460358326568405815], [462503904897553848868889945067837987285208130424, -65812361284652563177222461735199477554], [1162434216040542649562801247719170521490268245398, 52874778200816504866027979569287038220], [-651198120415055110826837744653564403795701093620, 569308018708157464967576478574530753027], [-3997128863402356840954370724983680962274117943698, 735441856730419492725684546781671372], [2012237026581163281221033946122040829493312227392, -532613463035042498255634030924895513776], [9289512569726223981174373797953006814253574331458, -217917046558222824247891665638727697560], [-22493121555868672719622575494525777377335787587426, -99389797159873067513816302765201152564], [29358814285475576277266054121503614500206006465240, -886132178246289885033698786607000449562], [81554144078298462368753929821478518139150601825132, -10907477226441238510926306697027867552485], [289002566108594649851139492486186153607832684762528, 34407316187999740354774647871171455601896], [-139215231019004384520786672704445370329209495311716, -83775218414818766655023550538997319520857], [-257889719244388493971551527757550406573339625890050, -56019728302885551750966114433567016897844], [-33307089800047589737380302420702721948167303297862, 126678606875481693705972016260893168167272], [109769171037964559121686681720976693635661818156880, 64845282211767266383388796231545583908724], [1197417997563679711309330083946680775368897143683922, -162426621455028843811653212375179272397560], [-4848295474383810866512277243749399868849515829021148, 251394894271891120015939581766615023968265], [-305488698265339350729712395494447851803856806925566, -468491310642527143652602069586981073856512], [-810358304522577929958281004916825295449029258638952, -1091642343154385489506767487399677193118634], [3477217506120286740012388038660930217890478320337590, -2933126408925329117656958244462487683792708], [-2018131088129019103584577037531411826704709580468048, -3159988418545030116539421471460516562405172], [12900967258753204157067296784481250588626372709293454, -5044020602068874867920745195800072483061508], [55353626992495697175142360065475765132727015981988042, 15654418145078685182162151935714144538120], [-34183090404164976040179890294082179439372227816679292, -5866259507696664210249024899830849056231999], [10163503063848012099758714086704248001955157597082558, -1695314466212346777034234406309425908483060], [211754669418272868446537290994618651561819069883362444, 27126320907960681792460392297627006623022915], [217335256961153052996936900369037838046255697761249192, 60902050134773169328782999344745434038237242], [-228429508785352663187037660377277251674287698605656022, -29683929109266881810288935895777691954410928], [173618081326982092196191375615167888726746684234453574, -13243647297626369020654371756021373767821124], [-862626602907454255609489891710347886855722841574357228, -101484275801402419082765598175250230508211099], [1202306180174081922885088666875366320559689422671169394, -220207270603787880206336697886747247814996960], [4218473849378905925156582833761720722075100994034672964, 143616832953719470178413395964792365998417169], [-2669665406133363392380077680477611956992240700020942170, -772306508185947858317043856720710941953567524], [-1898173877262013287201115084476728977553841431693875422, 602973817333290265808861030467853400334976928], [2644057734968994581787469171907108895519868390618109880, -1454811810928281970908461495643684278670805602], [6679882216921212631131107037225940394034490610726603984, 4353388776284224738028797754396983826412948], [12869180184495163078144807495100398976240740116679629998, -615015028724181000117231220081533148131716580], [-14575251976982593930724557075684961937044904294070120540, 4029606944028178739359328241998333168379918633], [-36580092007314454804236222560224248325867455897428234112, 621009509311539816372584947423548359416341792], [-105834485676072440157902004359707494116651995841720610, 5980840017313894856408752162061122621598981436], [104350354356678729486508731524704416777948569713995945014, 453020494659082622071205920302444723134703324], [67124665942740819247053868928676798551317253708894029362, 11145970720897172866116488483755375055315662152], [-123523334458189149362930144476625758369916698577828703670, -16470865163130784452333816192321915061687205232], [315034113871142792181873881859713579050681721190921559260, -5127561121618554970648369695491845870652363049], [-163095077479929962252942783982973339368408733976851138, -50309764028136062234784462611309570722789316820], [398798706006367213899386832164288971526353353137688930192, 7370572622659832641158940814548259786053794180], [-292775087496528643800529710971851898401063362533575703662, 49512149666516125644437339317013050688195831112], [69575953253265452538473203245558702517375345701927036200, -139000681875849346258003530069771761853706752102], [561156003808230014964085491402702445848754753670064770148, 23192411641087583309909530871068138424566936953], [336850454530478390501136419847510273773816200398624655170, -58932957970696486979741179381678207327424293656], [-920426221659226391056987923742595107630669030528382749606, -215862438268520224139123679751509459472159981680], [-202180235402081716943538883630054697625146021785444875018, -145388604577973212905831154252161475957517858820], [-365849113439410206226186379280964020344147044416219614992, -160713620947497014731205670442252433676361269732], [-717846815881860535977536687925932401409506727200554729876, 402785933943337059291035123121693785914087175931], [1834347105067465822786640282648460529575413449360044892320, -173039074701238277245638153220575275015318849880], [-879872226263491542942288193309913557031222108524563094216, 819350214250834856416971590051662293166552496958], [-705968928057368996666705760684214148978730517420565965068, -971332588103268206089924078998659108400429207363], [-10344626210238346798230616740910517165503012291454759217460, -423114608861917140794527167819659079642563802957], [2500779706054570615737175867398782080167858845348887606248, 224719009845529765563230447703206010194352847242], [-3302816113887403843748060357920198469296820693442876468090, 1948065878249722108679892457987925245362021431724], [27112038468111079630026538744874763976647103436563317127962, -241022738488211620914643466672133181656046603440], [16626705717064564977903617690541749492226495808527453857108, -2855011472164696077940030114008907558409905670283], [-30131112453798127393107834690007579738580380676972053336858, 5470606636393449740879920342391031981563554160844], [9506034310594546615429448938999562949497777715136390037084, 8881329798616614435292168827955922123744799147063], [97452273648220872790276687307309787420072669012456071086614, 10932697621763242350047337209851372712404334919084], [146609091243410745107496182024623662627015935724238831161228, -11997487611658623722779196850324082861267896112893], [-93521269731857259145838891456684875716124627087119428504790, 21043539515257646260849094088607633192497539662416], [13035731586746866861191748972416235582185693638080859850212, 3183145364507432594176993549344301001618539250265], [21311218985633211850388349592359775474108573839495159152834, -28059110944007080891743777905277853899716263658592], [-238743359757492957424479541150163690155082686566170229802476, -3070520070607713472826858277965080993329602625819], [82283324283528496450677607989447679506837463906450756944498, 12446888452874007275668476146168255318774983338048], [-578721089534653495143393312383384163874189729528467565480440, 38302812544334284757199464653674372507362085606162], [127917183528674996493194297057263473961292469921734471443082, 13897550748149870183880248326755024886320169218216], [-744339138824254267035908063983094097898414966413592421595616, 10501780901127897216932805935284138948280835050568], [1491621742746475254177723924311674735658104608697227300768638, 5267003403995904713372166866556834253938048181164], [103601838876248190428536450367186236740004129836144753556794, 152030746511918360540510906807051463070687771458120], [438246761517478855746755787789489834854752884254877350744180, 220399121981610378243114776973941225611574555493885], [3798587379060838414163979203966891982276268742664779067752, 219632884504876414572106713429362818022589266708202], [227137553259807765655608498140440421527985364948643306395522, 51737509129011165554599936336932855338536659545640], [1184997150376482156549220089414475808534704381743955136691068, 198183422818933359287916888230418296220044111771007], [323829787576035982524565696990648661060942929123958700372504, -260696564873628673102308997865248007378086556743818], [2528587524194154192033320846253900224946733098219222696724278, 479032629842864435828673904116490541580716562086268], [-5250911030963515055012948963086878994877325498313322290972500, 154227639511746779915063583420359152408659025122987], [4381397992205477280695707258156474122052429353583274055664142, -79067470353907489562213630106489361298104708180788], [-1920520569929759314575819735058774348350856868969159978927902, -1247040879322869861965202234769835162333297628038040], [-784900929898210926483143813232354318270811190539660933081026, -1497111258192506354595404816385757100284059873711684], [6270732698135242339545408140419028372172339311155147819033908, -466444788662586982580133646434441300731920136285619], [1507557273663542280690511150313688584573103137532907318472972, -2654459044281648059405726597612616024583305661684605], [-4802644947632303708810468438980581609398055015796894823317818, 2598148201677010161679830142983863512699481712643596], [-30301220445948014660832012992392327936902300781747120123304290, 152236420930092565535592087752553683540133928063164], [-29156353903247885721222919996082606356738122867070549762171920, 1770246250820625366541344995417462345565009101214300], [22866107612843355668163621521879742030032127583552906263040904, -1503954245483749869631123525211777713636968485394318], [34837019516503181665883948114693792889731179802544525561020198, 3933264171430952247518758484553322326240013544088444], [-65322777397697848322210526422011060327685159962936555614785380, -2807864051868245063525353779853730271780819652910553], [16791881999111150862023429359563287000207122173709363414270008, -9215222001802153481136167794139650708704376874587650], [20740158018213711431834050201817715093547040771658514510048592, -9175518012576290750959254377045829366516391260608652], [13007335530193835264118522764980601471103097063049385137529134, -6846523474600503287166542124110941571158025868504852], [-25641809319929192652828087845019992757795510178983577400844438, 8246208945573709457576899598101524633954928758067536], [86627628665681818639709592844420576673402369851607930652757250, -11072597979037125230878598260875795802349385213589656], [13074170308091267658199506721107184029768941651104677905525598, -6686525570638673323529700562904424548868713809584900], [-106273526542352825954911331418896882097777716334334981538403796, 28800812412522186829725905387933018368194530008910667], [-164204325945424610589895608922892228073855171564656845946429466, -1889098362663661374288171522250944579900326541426132], [91671514037481921980874546218755673329663504165251956900601210, 58422534171706153486646860045227490968885938404186704], [-78428082933287741927910486001897516924848237709095588613677388, -67531505530042585995245792177045488129229626530844659], [-463652325285717712710671427168928999772329962082298381937461778, 50677554313179768468702907999229631828570067267960092], [-68726074116718622590782561609138036688497446833348917310186072, 86070604448750784514854084448092232155789164625700026], [-215358013192111876643440558237332602149806461211788670522353436, 18321926403161163529699813500704095314007814999783769], [-145662330769944746739277923115720111037705309454837081824337850, -108090842513466371140534541995017575153997826564003284], [991361183650721593584157144858910855908146370582938525136942680, 23331266212823123719087160517622230327247394908945734], [-425436259458015571481541291893432158292857068387569729502699442, 115614944822910773272577344824210374658408988486044924], [500090277928703486377281111903608103268140266218633849508219274, 35181976601158865493841469577628576244008840762631376], [342819508922335874799087683043107865255513535647050350984710980, 107411594054248622411456287455507090584854813662896913], [-988473163187151333053042363623042054723146708385748538725928672, -134813072565770448728489198309666917545085427945951928], [313302182623894140175924014895896229419003635018611509931675094, -233581572431825464994103804990370990753588515180498180], [-1477648260071965679397535167078741028489906537162705206872544558, -93800385845977225006841366045453449790042461556310240], [-3459583681274293548599001098037696275650856457179354651165934772, -78221777731662859866262972778695905430861766844251085], [884530258033332004686616594071820747879196920692065907888163944, 174158423346482446140109143822717897976578612778298730], [-1195695971549860208057994487345215444798098647124635873537797676, -742864795802492158174759677191993087252410662731291019], [688350220582045351691611500443609576720974606306700809087786032, 589717178241132951953093196042142327829395431631215660], [3412170501199548318671987569244159639289003840844933932256792520, 93487183054711519329289886642110545935872103707754178], [3582686902989892112145235082493601628318782424199564249637708770, 615286370231547906047145969106490692988964976684836840], [-1875403410356536471117933660057732368305149596134101556942905606, 1021238751448991742790311775904244609422179122684912360], [225397254672961799813484034122926460826219279285898039617900182, -489391535603770401277520014326837402080870011647559908], [-3674993722411842221511137978041188472501182772082599479933754356, -1082298683343837096903846189774458186767512047935249245], [-8919092342115583095936173710398552722256132687025738129196348502, -209821867601998064287544712920521523044098674876218608], [5945252476438004968656311132616949344657578503119093985158595544, -570054668254168100909051877802825218627503910672668250], [-7453617282051105251857753227814222773830202173708482957504231788, -122999944465107344309099880371945435782658022289871835], [384799190190114828551841516672268872191398917106360682208128754, -2290706873390895467725389847199066262991790597584532088], [34827012202540235398074924685597957029399688219383021321008778888, -729243127073217323993598987104241393994468921206259278], [-17200469806784810781217570661345015043399611120357599664120703328, -2181997021592691443179812403417732659972358153189337880], [-13829844333318240220260259146944344672288377448185875107540803586, 323149036108815638019740327351942085983104058884349244]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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