
// Make newform 144.10.a.q in Magma, downloaded from the LMFDB on 01 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_144_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_144_10_a_q();".
// 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_144_10_a_q();".
// 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 := [-886, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 48]];
    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_144_a();"
function MakeCharacter_144_a()
    N := 144;
    order := 1;
    char_gens := [127, 37, 65];
    v := [1, 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_144_a_Hecke( : Kf := Kf)
    return MakeCharacter_144_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 := 10;
    raw_aps := [[0, 0], [0, 0], [368, 1], [1476, 4], [-3392, -12], [-29726, -80], [-115616, -214], [-125960, -328], [26752, -968], [-2547312, -1201], [857668, 3076], [-2201898, -2864], [-17226336, 9142], [-7033096, -9032], [46297728, 4760], [-78528112, 3407], [127537792, 19608], [-71555666, -63856], [-56706032, 95632], [68337152, -227040], [-85088330, 203232], [-309082300, -133756], [113496128, 435292], [353754816, 178932], [-1018022386, -487616], [1127702736, 392571], [-796849876, 795500], [-1184039040, 468296], [-1007624990, 1160624], [1469543616, -521068], [-2621107540, -1246996], [-1293941248, -1064800], [87865440, 1465706], [-2113203696, 2046608], [-2925623504, 688133], [-1495215932, -925052], [530469550, 4350288], [-1784201736, -1791816], [10095218304, 6391512], [-7507306896, 7597361], [4186680960, -13742888], [2803253946, -8367568], [10288137600, 9728488], [12884644610, 4535584], [-7872845040, -18800009], [23129376860, 7803804], [3158769680, -22375280], [32037118940, -16371556], [-10484759616, 33892452], [32924458762, 18923312], [39125314880, 17825356], [-52447305088, -3885160], [25405946766, -2300192], [-20525890624, 18944100], [34614875008, -32064632], [-82002944, -31023552], [-4548399920, 9948859], [23076773596, -81226852], [9894483898, 57114672], [-64541277056, 31808248], [-103931126816, -32373280], [-49003474032, -70294225], [-192105422832, -19271792], [40849197312, 25937136], [-97665667926, -821088], [-152176428528, 121730311], [-305880302624, 23280352], [-139727904930, 35358176], [-183074160576, -23086756], [-135880090962, 39610512], [-202081250624, -217229900], [15320193024, 220314240], [153884555588, -89825788], [-217001466490, -202867440], [-333012152072, 258996408], [-552480289920, 62844552], [-111100558288, -422601035], [59772285950, -49479216], [663464711712, -145976850], [234587916390, 528758080], [-669363699264, 300104068], [241293981962, 166395696], [243619608704, 478992184], [268623747202, -481061184], [1007117631324, -276115044], [855292841024, 248851100], [-278640253984, 104421234], [67815476918, -1046017216], [-1090256522704, 285304533], [1445200202668, 305905644], [819255879360, 171553460], [1243933182464, -516188576], [1824120041108, -244530220], [-38980383744, 661666112], [-467876202528, 1092645856], [1013943724800, -155640368], [825650693328, -64033989], [-659640865760, 139490190], [-989706419464, -1100187208], [-224405466318, -1972675344], [-1225417367000, 1204588904], [505153913840, -312729063], [-2044113025856, 1388923348], [691543587872, 938115726], [-2975259447792, -567593584], [933026727890, 2653577632], [228670825984, 1005023904], [977449287488, 270470700], [-4626591703680, -853107608], [-2005012492070, 184013344], [-1739162836820, 113758188], [-582050540842, 461228048], [2461129288320, -1728186472], [-2583395738656, 618757344], [501375056276, 1158271188], [-1801272371104, 796676970], [-2765262012888, 1459936872], [2456253775232, 3215030888], [-993766152912, -1479358683], [2068288460544, 1340619024], [-3436509144442, 651458960], [-1410699197390, -1803237440], [-2961602795344, 3485684141], [3557085257920, -3055435244], [-586792138760, -3255958344], [-4548661788336, -329281357], [-65937268726, 1304902960], [1588459977472, 1983213776], [147652730772, 5171264340], [2456892281234, 4845555824], [10994183734288, 661553040], [2142050037376, -4904437544], [-4105930164108, 1901763508], [4981490991290, -6018235856], [-3256372276256, -4237654926], [2071898909954, 621427872], [853894364112, 4370147147], [3642795971528, -8946562040], [2551153869488, 1242808589], [11611772932960, -5350759622], [20188042844360, 1074519816], [7909317684240, -819280153], [-6504504295436, 10703120436], [-6662779693696, 2676206824], [13816294857778, -2334870352], [-18946148269056, 305280448], [-1232118779866, 2981809680], [10078993548192, 5120826582], [8965072732872, 10594553864], [6893186829952, 9894934232], [-5907512492802, -408170096], [1686541590400, 12025310408], [18701586978808, -10648358984], [10878069224192, -9421871792], [697116524840, -11315670168], [2339628092032, 1986581784], [-12227181772300, -12478907340], [3476880241696, -26698965234], [-3299773571238, -2181396864], [-34572769274832, 3655679413], [-2583101719680, -16688954488], [-16686039998304, 13771608966], [-39025847368916, 3809963756], [7305639687360, -22914520364], [-30219454969440, -3776258186], [19397748497664, 14624013744], [-1801868017900, 16933095764], [-25830162616106, 3115938384], [24269134384574, 12191725888], [-44193272667856, -13290686107], [-50559313953024, -6045223280], [-13691542908498, 9030333264], [20300802202496, -11451500152], [-14792682886778, 17679074688], [-35040174123404, -4882470732], [34811510510848, 19615204144], [-4267123027904, 3655118144], [-1424492936400, -43702185403], [18243142608476, -14931308388], [3161872922462, -27068297200], [4460263970884, 5878585476], [-20110051844032, 19882879836], [-36229057624566, -27398552720], [6332640096384, -33829487048], [2912901767040, -58515390648], [65150009583408, -6831753211], [63830822029618, 1181545712], [21787537252320, 34978176480], [-4327473818138, 62734986976], [26082733158144, -9681681520], [82492832387134, -20109226240], [41970667608960, 22806491528], [6645181597760, -56890733760], [-28331321706640, 22500684193], [9804519187200, -29742936496], [-92416400452352, 20480961328], [-5405539543166, -90439055968], [54597027204754, -40412778896], [-58124970796928, -51714190408], [96940343376384, -2443048096], [33363481143664, -27543102079], [37762219653244, -26718101060], [-53384032757926, 1453041264], [46123545169678, -12603348512], [-55394044232640, -17932871780], [-53982969492336, 17667064863], [82431677773276, -5081178980], [53884587050688, -71276174156], [62639361328960, -42385673812], [-78553729999672, 65988704520], [78358045490514, 30219798688], [12824174451888, 36576403565], [51468654293756, -43130835908], [9848316692864, -84008485976], [-100421584367872, 60231970192], [-131022784254934, -49815333696], [-4304832637628, -10568627964], [-26807452866592, 124076606770], [1215441604992, 40128584488], [53152376735088, -5441648191], [-181908481587862, -13202539280], [-8223613700868, 11014840764], [221490319034016, -30067164122], [73492740170668, 2137403756], [-163222017749184, -68645540116], [-128685825142234, 73001688592], [-178764502680768, -68263704468], [-195975745158912, -14183532176], [31020695352204, 29297212492], [138228953156608, 10172258624], [99142280596194, -10582884944], [-150853790191672, -93472449528], [-36564582324980, -56725713588], [-16548552777856, -196630547256], [3098147209512, 144213312616], [181592745282560, -97364428480], [110172129644126, -4495841472], [-196092275682640, 87851234317], [-240210912282688, 40193141540], [72939492135040, -134788222536], [272963926892736, -20681848300], [-59290384969664, 62647667008], [71893146639092, -168689649996], [112777457022046, -142210065328], [-7886231283456, 232128061680], [69771519692288, 98282099744], [-79324936955116, -228439899308], [200979111315840, 60708180904], [33005483668448, -263663066144], [200788836718592, -20075345280], [269679347442834, -65013257040], [-168797752401984, 18877604196], [-32408802707584, 177742107080], [-161572612586618, -184462698624], [-384549082652592, 33133207107], [-103056448465536, -9794520856], [-163327376249926, 166054286832], [97836949146032, -8698261200], [15507020664912, 45398346563], [-123612491602310, 280862091968], [226808461398908, 132815399612], [-115197718558080, 4063830296], [-97505515791254, -92894531856], [371039571251790, 127662990672], [-71297745278560, -304783102602], [30633670563904, -408064796864], [455830687174192, -58418316011], [207001077300160, 178808486308], [448157921145640, -167130030488], [163194921396400, 63058441645], [319539041326078, 90397075344], [-8155942809680, 59823840048], [-24294039408842, 185584956288], [-8539365209740, 369938923828], [337002697359502, 138974233984], [-308467604908196, -148570321380], [117246541579584, -10276757364], [171686486840654, -152182981424], [-709106836722038, 6395447072], [84218850911872, -107423250088], [616466931084544, 182964963504], [-573204990981124, -169915002052], [88292036908672, 190245969496], [-649286545627594, 215063147024], [298368467526856, -11110490360], [443183591878144, 120047420960], [119236520519726, -35953929504], [-290986138376208, -311449769511], [-498999703719740, -252646153212], [-121097154132416, -612283927748], [60470242674608, 220418637629], [598393864562304, -243860905640], [-601647460169536, 208746940756], [309794804608128, -109260621320], [551311567052382, 1089274384], [-781037894866384, 138050400085], [-397925033335028, 383647346892], [-3341932775088, -605751636685], [237246372283200, 507833794988], [-74589121024472, -20198571672], [12987067018490, -303003192032], [-55646596290704, 123612627617], [-546495748791692, 338262133684], [208451174719744, 260236629872], [232027944411480, -431128735208], [76684691764190, 189149584096], [-593030366777664, 422799908404], [586345171190498, -6720378896], [444544875577088, -1817186672], [-95729898692650, 374364592656], [-375133864009344, 241366488616], [645382746767184, 315550340051], [345200927273440, -295689090670], [1208731056352856, -102573291240], [-844049366376704, 204186972304], [-548665399083802, 256149690112], [-1070434960762368, -211217848992], [89594916966912, 805944889824], [1131565104798638, -206409446944], [-26454517165632, -1017239037116], [-43925449398304, 483925390304], [-222047608158710, -615047119584], [703708947018256, -238975760505], [497415562558436, -432832423772], [1264944116044448, -277205690010], [18964135727550, -185177810624], [-484466923615656, -1039295149288], [621550507377912, -98154295112], [-166346419143680, -332377609664], [765799126625904, -499974045775], [679925169852034, 933693975088], [137993140348656, 323069057897], [669010279449468, -68872447940], [570359278940544, -707822054104], [-1021431460527600, 277318664848], [-287143610479296, -613553983476], [726397267409998, 928909042000], [-957095456809152, 69855143980], [-708229781960938, 540181682016], [102017887523244, -88382303892], [-74776946072282, -1492140439536], [197961262016544, -380663597618], [-1120049571482160, -18733372757], [443931567937932, 293953979212], [-784340463265072, -447002934053], [285283019801536, -1097234814876], [-1683384831424662, -21691449104], [-1602465677422528, -461855832256], [-656339658893568, -648347591408], [69678508682320, 893262369667], [-1265655900895800, -262688924664], [-1367802680096074, 3536817472], [374374345221776, -454196375681], [1761066106227420, 219832655004], [144170599612550, 1835830386064], [420085936384768, -1214549595952], [696064632294784, -941746289304], [54572747721728, -1506582740672], [-810569195127712, -1110591655126], [-2146262259570432, 610155561712], [-1165961073616330, 606287721040], [-159200111864256, -356702792132], [-920761867895424, 113967771240], [1552460128321856, 560030465740], [-1998468506688592, 409956266800], [889440209084202, 1173219392928], [1327828685467920, -1316515286249], [2028046940238884, 627608987492], [-1534246679674406, -389003074112], [-1681715701172416, 1325210041452], [-1038343014463752, 878172515512], [-1869907096168960, -1610023082080], [121235163700496, 1355538868311], [-1391820649750540, 698665071540], [-245892962070478, -473258977552], [2648950577193408, 270267100036], [-2214958671579264, 451367434696], [2061804352018786, 1014438440064], [-2851394121645024, -897147199986], [-1003537899592810, -29760319776], [-2440155472003344, -177128762391], [2961082310994784, -349324228166], [2012532332621604, 1495580392164], [452570338867584, 2795421819944], [158053911210440, 1326881580808], [3355975576745088, 1087998692728], [769326201141780, 992435279700], [342289592201306, 1302890958384], [2960385071452592, 1122970917168], [-1024184733879936, 1170013585704], [559985747443774, 260936355584], [-237004951769296, 968065588101], [186805152630528, -3092602529264], [-574341725006952, 1754938035032], [3058905257868672, -1151735804312], [1610760173707366, -1283543336128], [1621030136687580, -1177260794340], [-3637993753560288, 562526297118], [-303679717827944, -987043600808], [1740805857500144, -2144998035815], [-540413695976530, -1283188681520], [742717992517920, 2293523707582], [-837241532770804, 1473572070604], [749727011841568, -42131546898], [-5138828917415920, 157841211815], [-578877217640092, -3905324045020], [-603387287285630, 1343231852976], [1194419989739040, -1606254482450], [2934003442864216, -1658775931880], [4702585897509312, 93644032900], [2077892966633186, -866285510880], [-1731522984181648, 2452030608785], [-3300842504877376, 1219531889268], [-538412448510568, 2510167836760], [-1165560910834602, -3450307131296], [1321555376582672, 2314880999591], [3678970947511680, -575152412696], [582624322943428, 2614476556548], [2174746140026400, -1767876254482], [-2488947432957952, 1938341185152], [-817826202892496, -4287911423995], [2045204813567606, 1534469967632], [-1410419819545600, -1070388856256], [-3383311839415360, 1470411712868], [3395306048862970, -981677403232], [194513494311184, 2488385420823], [-1973733366198080, 320857651988], [2697391060960704, 2724431015428], [-113547437374776, 3828026632], [5471562989852032, 217177128168]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_144_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_144_10_a_q();".
// 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_144_10_a_q(:prec:=2)
    chi := MakeCharacter_144_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_144_10_a_q();".
// 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_144_10_a_q( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_144_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<5,R![-1905920, -736, 1]>],Snew);
    return Vf;
end function;