
// Make newform 9.9.d.a in Magma, downloaded from the LMFDB on 20 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_9_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_9_d_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_9_9_d_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_9_9_d_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 := [872385888256, 1078377512960, 1254910111744, 183604924416, 61638378240, -1434930432, 1757083840, -29352736, 18261508, -371244, 135762, -1362, 427, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-8669628126778214704913602579186622464, 11673431310210505523707812991412566016, 962102681229186015894305741252662272, -371785821517531872040637539606808832, 37304937996215854140380362605307776, -3036725485917744621466950043094736, 408260669537384694699705658647872, -27246232517001751558799077332700, 3101563233324860607105549277932, -57543855647402141458544986806, 9110652565048392910003247466, -50640806940675695590816011, 23628808584322386004267421, 442054787914350989925983], [-8669628126778214704913602579186622464, -20848898132329312254552493742295294976, 962102681229186015894305741252662272, -371785821517531872040637539606808832, 37304937996215854140380362605307776, -3036725485917744621466950043094736, 408260669537384694699705658647872, -27246232517001751558799077332700, 3101563233324860607105549277932, -57543855647402141458544986806, 9110652565048392910003247466, -50640806940675695590816011, 23628808584322386004267421, 442054787914350989925983], [168551855986815744004322907834624149915648, 196044031959700393824151577817052840957952, 21202890809458548094065700461157085511168, 9484013776742416003418973822552212995584, -252429925144135634046637048554323365536, 260792914802948921470878874536684998208, -4654740496607351186304919512341476696, 2693781533695482096272215740291999596, -54682345376047584754739459890536648, 19822901496036596466175682969162286, -198273701849340482468433881909616, 62273837006331442020069557795121, -138581435033730282774152005159, 145032782608552321121131801061], [-1097334123596226025798889218350896037213514547200, -112438252040330746976358461574353000651227820032, -126525048680195888073897211066115193922711277568, 4316281541675506777275547398394949734883534592, -2940144872535532207993214126613560787429264384, -77826100878917252880146681597828564124257568, -28452163471791025409385394468814191862042176, -1089054949145763567930806506642865543257852, -190466878030875033816553157108323419611628, -13892749351530426745949202540439581206622, -553875360063299560943273770264318812834, -52163081192717354840072878079497938105, -1651347715617371633882813389888159645, -139639472755771394004703346897898163], [6640254071166053073650418747641531648789935292416, 2468937038751871723102790510442567878517895641088, 378992105089215002691579425225835888108968653824, -2689976243680754288623847473814325039345792000, 11971297141894330569162326331353323969882902912, -41620726913509165412829824941313189613854976, 125632491624298742054899386393835447972392688, -1680441719460668869166071024647681553596044, 981442974852475471211300284130326692776796, 1584482614334123029227076920787555984986, 3053315490452160193638443575091186570634, 31562672200844173168257981713651866215, 7794765266003632410914021053048918867, 121020898832920498568020179835244689], [-954435376594349458248285135587821231512485888, -29148657615175068777224864252565868577461105664, -2965604814786809341435765222380420497962475520, -1990173083306338673255906531229750995686250368, 120039635465629123422111974969859239509940352, -53452732500966797781165711947178293180041648, 1670339948068048082197491577752292938266704, -555421071484762278516913204472440743084876, 16873284782433987024830897437444189675236, -3990941724150229990318932094022968814078, 58066434885724341977182871338496940558, -12361977423284939843553656071627539923, 74791026251459281385377709254214053, -28474626636003832080350794340012605], [5998158364515852042841240668655720233691263746048, 1352790111958550417855176210039378018171688499200, 284881315572889718549119005221739531387389644800, 77867878929458637360448746402607510873069827072, -829284062628537188089678052951337856158415104, 2199401856372202455248870185126386953352357888, -29795012592160515219536559181159598384669152, 23014785316780494655466368481711469232601204, -404631399332349387879314749537291989366012, 169897156718475911761178738732783012399754, -1500976738661515023866099127419102353386, 536235267054628345029160507809063692055, -732663739411981230284723257046339125, 1245753391460891301725904243581812661], [-64907273492075006754119421398554999974972772352, 13440229855695699115429284803906875097351099392, -9798459547901247418095598095425635803153725952, 3221371626383635466054804595889027355993421696, -798379271477558552931648679586010624471990336, 107501116203811438084112713377547863538839408, -9771027460501436970291384585563488118791016, 1166354338283292272852591592809427229433764, -82698440278664126901688138964266435934592, 8295718066708853544319061610132445831506, -274672744822866756886389852044474658912, 24635928544028063252706115351898967765, -517328685121655365858575934937337503, 57554282479705348525621187745129961], [-674161187073638013898977507670621438932804706304, -913406837194982903553113003476884436655854000640, -238934545803677092263584528245104106692593163264, -46989629443100824984135382357842828395751617600, -265750705058750613253727694401866587404090496, -1273545857559023689036531612341918576877660776, 8364341381955732244172179633064388399924928, -13467525785178735808580832962478767860405496, 233152428156181234674079193815212195960780, -100514884422800495485177036218261892601232, 890346319935830977239520532819964097974, -317194667916701762110962258664287023229, 739394025595389313074708755068264861, -739341615556772282401596553066880867], [-257776722830204913303858655824398671054120435712, 1962749397135100678836053344990007929997034106880, 172970167076022484420644675910056128900694913024, 98916051683291716023206984368559493697898626304, -4041632009938046790650519075978684932897339904, 2668247005929001906103938675443211877030514848, -61522141538145285192911245085727260784310336, 27499763779358310119207912786088228554569900, -662619196507085207176518743807839217536612, 200548271138919383997238614836786310004918, -2343403843896754518575111643801906081814, 626468642806429300489586843072583009421, -2257187917321624067789811153203462463, 1454498346165372423435195143116845807], [7764337866706966782677557311869704692463592390656, -6397885298915243572682478011331656808636410937344, -169047415608854104899836234466698955855268638720, -492223019852819049869106256126052044606436252928, 47785850476595606940564543908936361954207863040, -13766489846233737068736744556544405475463461024, 619594127230092252531903772903630198229728864, -143868808859572812678202555643370827973593348, 5765454065258108034460824517373433792673980, -1046508471144161634866327123465533931891298, 19754729155641759381915020015055483706650, -3222051824345705067121071399901768377519, 29406881986103917600325358275713965973, -7552954302372084834107286511644675437], [-14599674669577903075320659201139977662267615313920, -10475006440372537432217432367595737630775570511872, -2268760601995976403817768322836348913073274275840, -467667355804286607616091374597590127231255988736, -4818428454251431079639007434639595657296479488, -13864248207343793278531121034673334652169357248, 69291911085442095842331358412405268461323424, -144146475481347024056630363156147059625863468, 1962669781775801033961460443567757468926084, -1086354904640261719132360994389969806728742, 7861220716076060768427643788071622417078, -3433777979518870196814558422499038907945, 1905362172599095557045888987751727963, -8068888828885307328423444297333694219], [-126334566712740529062226927859099624112553193472, -198855922757848326035028073459030665843652088832, -33724754142780728826216770412880004606997177344, -8492387576279583662826635611232523026176945536, 43116591540530423526355585271085104444598400, -262224973978520785072934344675313258411489136, 2525340727992361866450336090075783198142024, -2744869424230974730497397225199385113412084, 42276353029430659347132935928880480112000, -21014880992867897579367557497924379721306, 165140470144235468192202453672315625640, -66781924325843458404620343788449471761, 32961590601548826125463595190452259, -158626479702701669541205110267758733]];
    Rf_basisdens := [1, 10840776480846605926086768911235953664, 10840776480846605926086768911235953664, 158210291961475366885310305490577507772416, 13161830608859058721922734934372124026602831872, 6580915304429529360961367467186062013301415936, 313376919258549017188636546056479143490543616, 13161830608859058721922734934372124026602831872, 470065378887823525782954819084718715235815424, 3290457652214764680480683733593031006650707968, 4387276869619686240640911644790708008867610624, 13161830608859058721922734934372124026602831872, 13161830608859058721922734934372124026602831872, 156688459629274508594318273028239571745271808];
    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_9_d();"
function MakeCharacter_9_d()
    N := 9;
    order := 6;
    char_gens := [2];
    v := [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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_9_d_Hecke();"
function MakeCharacter_9_d_Hecke(Kf)
    N := 9;
    order := 6;
    char_gens := [2];
    char_values := [[1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 9;
    raw_aps := [[0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-5, 0, 0, -3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [20, 1, 1, 21, -2, 0, -2, 0, 0, 0, 0, 0, 1, 0], [-2, -13, -31, 140, -2, -1, 2, 0, -1, 2, 0, 1, 2, 0], [-2737, 2, -1, 1372, -53, 10, 27, 11, 3, 0, -23, -1, 0, 8], [39, 459, -290, -77, -212, -21, -129, 21, -2, 1, 14, -16, -8, 4], [1488, -120, -482, -2732, 504, 78, 569, -33, -45, 45, 87, -10, -10, 75], [-18483, -3228, -1668, -62, 787, -95, 27, 200, -31, -31, 117, -77, 77, 22], [-47519, -268, 115, -47820, -76, 101, -772, 247, 0, 48, 176, 0, 8, 103], [363696, -6665, -116, -181977, 1554, -325, -810, -74, 267, 0, 491, -18, 0, -233], [-30829, 17530, -21177, 31800, 4296, 315, 2064, -315, -244, 122, -528, -296, -148, -193], [-121638, 5700, 447, 1939, -5546, 682, 3645, 791, -583, -583, -1089, -443, 443, -407], [-480348, -47654, -43983, -482031, 6234, -949, 795, -10169, 0, 1011, -4636, 0, -1761, -26], [414, -18872, -39471, 121987, -2619, -483, 3293, -1795, 522, -1044, -2698, -1800, -3600, -903], [2959636, 21321, 7461, -1482946, -20050, 1827, -7992, 3168, 135, 0, -3600, 2071, 0, 3222], [-2128860, -3020, 100175, 4272321, 35640, 5878, 66645, -1987, 2823, -2823, 9397, 3033, 3033, 7493], [-3974167, 45277, 81250, -4004151, 16606, 7299, -59399, 3501, 0, -2376, 9027, 0, 2794, 10926], [-20778, 33943, -18888, -726287, -38814, -11217, 56336, 13544, -75, 150, 8405, 4422, 8844, -5139], [-1245958, 141691, -182955, 1248669, 30210, -7482, -38706, 7482, 8606, -4303, -11181, -15158, -7579, -10096], [80742, 47390, -32101, -151481, -56088, -5356, 110201, 14911, 471, -471, 28151, -26071, -26071, 3685], [-2357722, -1241514, -680778, 28824, 49956, -3036, 134433, 20163, 2613, 2613, -11979, -1830, 1830, -15015], [-19339, 961377, 1880317, -5075193, -138238, -398, -124042, 68932, -6812, 13624, 53275, 3284, 6568, -15657], [-18813510, -486861, -21847, 9417888, 7044, -16133, -39960, 38816, 13701, 0, -12836, -51807, 0, -6286], [14830008, 58880, 772917, -29727709, -53640, -7114, 48283, -9449, 5205, -5205, -12721, 46351, 46351, 13291], [-61797, 1207924, 2320494, 17674018, -58188, -36183, 81080, -175228, 13359, -26718, -184645, 16197, 32394, -9417], [-39231767, 516781, 332444, 19550276, -665698, 49696, -250668, -203692, -20472, 0, 159868, 113599, 0, 55568], [-27078168, 1532502, -1318688, 27032434, -422582, -43962, -167403, 43962, -17474, 8737, -230020, -133330, -66665, 24475], [29141469, -326572, -2317556, -58131534, 586305, 59819, -23301, -207710, -50523, 50523, -315463, 28053, 28053, 40138], [38198016, -71700, 136383, -24977, -99980, -30788, -348705, -354037, -21169, -21169, 35469, -15173, 15173, 4681], [55647734, -3657879, -3601057, 55690995, -229544, 11504, -256268, 22648, 0, 42222, 4154, 0, 39007, -1418], [-19893354, 217218, 417894, -4256, -1682294, 177412, -916866, 75278, 7970, 7970, -80568, -12020, 12020, 96844], [53470246, 5677630, 4985870, 54244554, -1009684, -112616, 633269, -86902, 0, 16899, -222428, 0, 68453, -235285], [-118329711, -6067704, -670648, 59143920, 2574390, -227417, 145152, 333584, -153591, 0, -82613, -28791, 0, -203863], [121976567, 1464295, -1720878, -121428813, 51540, 279549, 2313867, -279549, -2992, 1496, 526239, -232448, -116224, 127568], [-34326033, 1652669, 684398, -33778575, 666816, -193659, 1950459, 486537, 0, 40221, 199560, 0, 125844, -140538], [113165, 5928015, 13063057, 16103325, 1533788, 107350, -164248, -701462, -14018, 28036, -427541, 268106, 536212, 273921], [-37819160, 3206153, -3582355, 37637519, 468014, -35826, -326322, 35826, 300732, -150366, -76106, 324174, 162087, -52098], [65948280, -16397466, -6257946, -1243040, 674224, -89390, -3643164, -646534, 106724, 106724, 521046, 290338, -290338, 431656], [-14194366, -21311926, -19375242, -14876844, -4344470, 658534, -6010331, -692776, 0, -474537, -466406, 0, -54731, 209249], [-193777795, 16201089, -317240, 96862090, -691256, 138086, 312282, 1061962, 180276, 0, -1106338, -227515, 0, 231796], [119103618, -30892, -23170978, -238202222, 1415142, 336374, 370142, 751912, 43590, -43590, 2027762, 1004108, 1004108, 187564], [-116981094, 16914432, 7299915, 698035, 1397518, -224102, 2580795, -285319, 20495, 20495, -153171, -167591, 167591, -377273], [-353028216, -60952701, -449947, 176265354, 2685042, 260713, 1894968, -567952, -246507, 0, -626, 1421103, 0, -47152], [-60255074, -21871702, 14542643, 61391099, 7671770, -39357, -26001, 39357, -285282, 142641, -3286880, -1166346, -583173, -631566], [255446304, 4481740, 47101732, -512960284, -7765812, -1100000, 2009824, 57848, -846156, 846156, -976340, -1232324, -1232324, 7964], [334844250, 77760228, 39416199, -878477, 314998, 379474, 490833, -1128709, -429667, -429667, -264789, 1028581, -1028581, 114685], [83329681, -22569130, 28415627, -83001844, -7237054, 160113, 2098746, -160113, -755412, 377706, 2420464, -1160652, -580326, 572715], [740086, -25719727, -56404075, 364564472, 10155094, -608923, 17333750, 441540, -480403, 960806, 1662966, -127583, -255166, 1221426], [-1274116975, 48262050, 3768763, 638528608, -17182067, 1809158, 2157597, -3997187, -665643, 0, 1418681, -632197, 0, 1039810], [-610255380, -5463669, -594899, 608862715, 11423230, -1758468, -16792824, 1758468, -813344, 406672, 1461026, 1030622, 515311, -2639582], [1404619824, 3213996, -77910113, -2808317801, 1639620, 577212, 14502320, 839874, 124668, -124668, 3817950, 809789, 809789, 1560990], [1292770411, 91323176, 100306825, 1288889880, -5888260, 1434995, -18726034, -2341451, 0, 1535790, -543400, 0, 153938, 1344823], [-2936086, 28524048, 47251180, 800661597, -9158794, -2023832, 4791794, -3392954, 317854, -635708, -5005616, -700408, -1400816, -1612662], [804210675, -16520360, 154875724, -1596213610, 28546083, 3477745, 3446131, -4998112, 205269, -205269, -5722235, -1774505, -1774505, 796244], [855947355, 70017964, 71786670, 846666225, 24179292, 89546, 12573978, 85690, 0, -2418594, 2001212, 0, -3271710, 2003140], [-1939640231, 102165949, -13420861, 975576203, 10569236, 3310720, 32084964, -28804, 779862, 0, -7296137, 530488, 0, -703501], [728985600, 24495408, -27023133, -1478104167, -39903624, -5106798, 501825, 4199949, 629667, -629667, 3249189, 4812573, 4812573, -43911], [-404952916, -130834098, -54135288, -6555606, -10931244, 1590474, -24456276, 2942142, 1136724, 1136724, 1728414, 1508304, -1508304, 3318888], [-3440567, -18073831, -25939030, 1977980954, -27041510, 1574810, -48120496, 3800412, -225118, 450236, 1265274, 2480239, 4960478, -2535138], [1000814270, 16109187, -1523852, -500760695, 18229528, -4114351, -9250038, -2462870, 1713795, 0, 7425617, -1838068, 0, -3265955], [-901000806, 8622918, 20537314, 899854744, -30895340, 3897510, 26594439, -3897510, -1768214, 884107, 7415942, 5240666, 2620333, 6320749], [-85578746, 164488281, 149729709, -67156761, -14807146, -3642924, 15443348, -7903500, 0, -491904, -6685842, 0, 4755323, -4555554], [3431201921, 227832372, 130669902, -6155436, -41274345, 3807753, -50763537, 12317088, -450051, -450051, 2867193, -3386703, 3386703, 6674946], [-2026317345, -49406298, -35052047, -2033081028, -47952540, 5485717, -40428312, -6630289, 0, 1687632, -8239412, 0, -13307910, -2181409], [-2799870, -40311068, -67835052, -3933442553, 6195036, 92322, -14522248, -14232592, 43530, -87060, -12227890, 4896894, 9793788, 2004702], [2879881372, 166396869, -6186720, -1441961419, 28845788, -1577373, 2559708, 3819084, -1447083, 0, -2084289, 3569200, 0, -1419951], [11010361, 198143075, 388771505, 3444763511, 84426196, 1537472, 95659418, 8651400, -842236, 1684472, 19961421, 1837132, 3674264, 11310021], [-5115491013, 135649734, -114066530, 5116927867, -31114712, -2258760, -9196860, 2258760, -7269152, 3634576, -211948, -13225324, -6612662, 658288], [-3092123420, -49318543, -34504073, -3085740255, -69209572, 6033212, -72712258, 8169694, 0, 3514431, 1219169, 0, 6835949, 150928], [-14666491, 168358089, 314065714, 1542251100, -91919044, -1375352, -82645798, 25185634, -569426, 1138852, 14161852, 2267357, 4534714, -11023782], [377699937, 24538472, -2989992, -190102956, 1040646, 5490435, 23153580, -1333668, 864549, 0, -7217673, 11688693, 0, 2429529], [-3529983342, 7780680, -323073106, 7048004606, -34729686, -6957054, -17170304, -10930770, -312768, 312768, -31857516, -8909084, -8909084, -3038922], [13126871, 16024065, 106906873, -6585108375, 30906686, 1726492, -25257310, -65961008, 844894, -1689788, -64463087, -9902458, -19804916, 1497921], [-6640916123, 160041839, -191179384, 6652611191, 24764420, 9375609, 75032721, -9375609, 4479930, -2239965, -17060858, 1421748, 710874, 6345276], [3367081851, -176622666, -123012759, 45278941, -96126167, 2418037, 50455332, -33745015, -3139306, -3139306, -16256502, -15183974, 15183974, -13838465], [926803664, 296969622, 315739256, 931896120, -83952470, 6625976, -78700037, -29552102, 0, -8263311, -20243062, 0, -1369613, -2154023], [-4296404419, -89021987, 69016980, 2116189414, -40665140, -21717894, -185484222, 9266322, -6791076, 0, 36795390, -9005863, 0, 2625924], [-13909824090, 134458896, 48306741, 7745389, 47595178, -4251158, 66792303, -18842935, 5738003, 5738003, -5486607, 7478983, -7478983, -9737765], [265398226, -110063816, -131751343, 263440059, -17296798, 6186997, 16254323, 50600873, 0, -12058743, 22309018, 0, -1651927, 102080], [18787768511, -351873290, 256101930, -18799392849, 133587372, -18279432, -156270696, 18279432, 5158592, -2579296, -8403252, 5692492, 2846246, -27780772], [-3273190239, 583082162, 572965721, -3303396396, 181375014, -6661521, 97898898, 16700337, 0, -17220276, 27734832, 0, 17955552, 16053903], [4710660, -184481111, -372469404, -19758954107, 63854124, -7192911, 99935018, -52093258, -123063, 246126, -46597069, -6407382, -12814764, 5496189], [-6984580626, -44586448, 366487954, 14005787946, 132733134, 15732950, 114947892, -43076402, -4918812, 4918812, -49945936, 10572156, 10572156, 20473918], [-1708095306, 1121148822, 620348388, -39919514, 81938824, -15738104, -147651525, 21601169, 6031415, 6031415, 34179003, -12700388, 12700388, 18440899], [-77778483, -383093933, -1028578659, 13853308351, -287756214, -27897564, -27562702, 93995288, 4960662, -9921324, 57186521, 13072152, 26144304, -36808767], [17916211220, -804060078, -24492407, -8914710899, -109648763, 22757891, 131205015, -31986521, -6341070, 0, -11170312, -25592596, 0, 2358949], [-858590988, 61848940, 643168674, 1696731760, -33039288, -3746762, 118747979, -13213015, -26807799, 26807799, -10147823, 9209930, 9209930, 20024969], [38203013, -736712580, -1469389670, 7006972218, 199906562, 4091389, 233648078, 1400518, 313417, -626834, 23977399, -11534743, -23069486, 22576881], [8868205848, 1570135405, -46997516, -4416583611, 91651860, 11161055, 127734516, -28038524, -6709575, 0, -2594161, 23376264, 0, -8310575], [20865482105, -98551136, 57301677, -20861486088, 296544, 1976427, 42721896, -1976427, -13326724, 6663362, -134351304, -28171196, -14085598, 14042435], [-12148062483, 84111304, -1749859532, 24286495118, -83768355, -5461613, 153077347, 37173170, 6646821, -6646821, 77248621, -6754991, -6754991, 8363894], [30657297421, -184453283, 137541563, -15412402453, -25203652, -47989736, -398905128, 42119120, -5684010, 0, 60998647, 2123392, 0, 7138295], [-7763099802, 1434790542, 673793970, -24510608, 116723866, 16839076, 192248424, 17132996, -7604932, -7604932, -24676182, 57023896, -57023896, -7837106], [-12997716487, 18726719, -63487890, -12874890687, -43318862, -37625231, 142718395, -102642277, 0, 32156574, -68323145, 0, 15381934, -35814622], [-13132660561, -544811081, 145389174, 13256026731, 464799912, 41499141, 296041971, -41499141, 13092752, -6546376, 62107251, -21882080, -10941040, -29426848], [-16275590898, -1706374, 2026749191, 32530964827, -120905820, -13525000, -252278209, 67249417, 18208641, -18208641, 79955237, -20358031, -20358031, -41018597], [8041256119, -1475977115, -1523454544, 8133097731, 15661928, -32548829, 93009299, -166021705, 0, -11129169, -85729958, 0, 34861052, -18993520], [1657617594, -124875640, -3313090101, -3220521085, 254210706, 38012906, -52690778, 4231462, -28370922, 28370922, 54124004, 19324615, 19324615, 7648174], [39643234748, -469803132, -255469167, 12932241, 33879264, -7038444, 31434291, 29183043, 10265331, 10265331, 2398041, -10689879, 10689879, -4640403], [-4835771040, -1949087580, -693530544, -86417456, -702062714, 61082530, -778842540, 59240906, -4879744, -4879744, 29064168, -32793410, 32793410, 90146698], [76348773, -1399092722, -2764143759, 29328209506, 168652161, 13225104, 242123009, 22568441, 14560335, -29120670, 29413373, -56278737, -112557474, 6844932], [3832797432, -285131428, 992200019, -7523736959, 410147028, 41547830, -123434761, -119498273, 660981, -660981, -197262661, -17214415, -17214415, 186055], [-20297801162, 842287321, 792956267, -20347000113, 162426632, 21254500, 49917716, 347174606, 0, -10619589, 203829847, 0, 73410431, 40869794], [-47158530012, -516474552, -197942128, 23765680305, -53028228, 38055670, 532065996, -155967412, 28997994, 0, 31907566, -114818070, 0, -47948506], [33031951844, 997861399, -1207003113, -33052695531, 239070882, -25114068, -201837084, 25114068, 2006378, -1003189, -155790537, -959642, -479821, -29004628], [50553662948, 1735949394, 965881746, -49473876, 247244154, -56203842, -242711343, -18761919, 25777281, 25777281, 74132073, -42586428, 42586428, 17928231], [-10597089134, 1832898164, -134707727, 5298271469, 417240803, -40855975, 21536685, 105427597, -5371266, 0, -54085258, -30912896, 0, -30369611], [57020668488, -200825756, 2315423387, -113922753519, 467469252, 66126994, 126078693, -38711551, 24599859, -24599859, 22835149, 79797525, 79797525, 34131257], [4453591514, -790182526, -1086941046, 4427495328, 903242842, -69708470, 977668597, 277703180, 0, -16802085, 190288990, 0, 23653309, 16583165], [148771591, 2623359200, 5367761978, 11497316882, 588735808, 51944777, 494546456, 149845212, 9938267, -19876534, 222693327, -23978699, -47957398, 72848115], [-23765701446, -1686625170, 1072345252, 23870117332, 621911170, -24727998, -106198833, 24727998, 56922598, -28461299, -39391786, -109230958, -54615479, -99256403], [-12015323434, -1112292432, -412977501, 22740171, -613309098, 44105838, -326416419, -240468189, -4158519, -4158519, -36364941, 5883873, -5883873, 7740897], [69871559170, 650960240, 918132841, 69771252975, -388586770, 43858073, -549268165, -372419051, 0, -21172083, -211893574, 0, -111571231, -3755012], [-61751381, 1480932416, 2749383029, 9513112232, -666661235, -26272936, -359926831, 118090113, 7714919, -15429838, 13141413, -69470255, -138940510, -104948700], [-6104698416, -4922675934, -2733324114, 111856804, -39056804, 38201410, 496973016, 266219870, -41917168, -41917168, -65903994, -18250226, 18250226, -27702584], [-128256744806, 5101701922, 324710672, 64047895349, -779073694, 67308736, -259541010, -74346850, -23878734, 0, 30187384, 91506298, 0, 90458006], [-40518379902, 1996554969, -2163616019, 40428174121, 476167630, 9194484, -227704584, -9194484, -51338102, 25669051, -82640329, 232881746, 116440873, -7846124], [-11848593654, 283272128, 559976638, 23756600502, -85686390, -3348502, 1078323648, -41568746, -30264864, 30264864, 17329628, -69458700, -69458700, 103815622], [53693466194, -7462479783, -7983650959, 54116903595, -415775390, -50751484, 560558008, 477503788, 0, 67125504, 152794598, 0, 89438287, -111333038], [3682367567, -4229914063, 297819779, -1961438099, -454283954, 26240278, -313100208, -132404248, 72938298, 0, 128750965, 172747646, 0, 48827273], [9196765802, 6426982627, -6434204631, -9234210171, 17667210, -81771852, -572240994, 81771852, 25100384, -12550192, 161350272, -67440614, -33720307, -92379028], [-179870806, -150951273, -1308414920, 14184625197, 44402192, -154765133, 1246262936, 49460848, -63424985, 126849970, 50006413, 25651238, 51302476, 545565], [-114225432141, -3104180089, 363083916, 56922978288, -741053868, 43159650, -591843510, 248366874, -72118872, 0, -186500226, 64396671, 0, 148185948], [-46384441581, -31731820, 720077124, 92775452966, 505711575, 50419805, 1061983513, -314133110, 51156975, -51156975, -416486245, 144689611, 144689611, 161360170], [-194683056, 3886719133, 7308266121, 33803110804, -582233370, -134798247, 156463640, -416828710, 20703705, -41407410, -519822994, -43109475, -86218950, -102994284], [64021772718, 287689696, -191931001, -127980247875, -592523802, -62715488, 95541669, 211859207, -49241433, 49241433, 302659105, -251444025, -251444025, -58343821], [318701065, -1320726751, -1305822682, -2099225896, 1021348660, 196422032, -602182618, -158373570, 19360838, -38721676, 601728, 36696265, 73392530, 158975298], [5659148496, 446616092, -2125851124, -11440421804, -33898428, 65002028, 577027958, 380056834, -96161478, 96161478, 933971486, 317130896, 317130896, 108855790], [88699723, -3698252041, -7495609195, -71151387421, 339867880, 103734860, 210760964, 607588182, 75662972, -151325944, 673923189, 81370144, 162740288, 66335007], [5050847555, -4742963339, 3525340188, -4708037631, 1521299256, 24915987, 113749185, -24915987, 7673558, -3836779, 462391308, -149761112, -74880556, -218097394], [-41520317409, 10130269746, 5272905327, 65278879, -603862199, -20943971, -646856712, -234678847, 34561178, 34561178, 36906786, -118148480, 118148480, 15962815], [-57104761584, 7027713998, 6338661974, -56203240626, -644864334, -132965910, 355300635, 44863884, 0, -103387401, -26494056, 0, 555294099, -115408953], [46522528792, -501441052, -390320422, -46042199188, 950393882, 344994834, 2537540559, -344994834, 50539734, -25269867, 56977462, 91748718, 45874359, 163785705], [55802543558, 12611246688, 6347892384, 339170664, -2570468532, 241977324, -319305024, -192797724, 86988120, 86988120, -282296736, -16554516, 16554516, -40319412], [73122218483, -14736691409, -14428634810, 72755741955, 1336156006, -62119611, 308332345, -510988383, 0, -30349701, -105328818, 0, -9159824, 119105568], [61331761860, -2407669887, 3352525039, -61456870109, -1064262656, 61652454, 393256122, -61652454, -199597784, 99798892, -320626114, 58084286, 29042143, 219371014], [65469487242, 1124875960, 2142288627, -131921001143, -2191099014, -305822228, -10773379, 124721603, 215792295, -215792295, -130757207, 64559975, 64559975, -74378185], [-148023027734, -2328690274, 2860481762, 147607686908, -377844304, -111994614, -1035172881, 111994614, 175686258, -87843129, 50785438, 412165626, 206082813, -14731215], [7650450039, 9000983175, 7893192994, 8517277269, -89618472, -231289745, 1909070229, -5359429, 0, 9145671, -157730444, 0, 54740424, -270695602], [125379083574, -1420598340, 2187619002, -249457011696, 3096426042, 382188312, 1927398951, -685739241, 19915821, -19915821, -724658787, -154590516, -154590516, 264631383], [43077542349, 961886136, 1414332906, -219262652, -2891686109, 255557965, -2733114447, 41784122, -138010729, -138010729, 56525643, -149346599, 149346599, 312083608], [-241389158626, -8590260461, -835369356, 120542299249, 4450670122, -355448499, 272831598, -122793042, -96850179, 0, 428788461, 452919368, 0, -404901579], [234320329713, -2551444596, 3823343269, -234495490244, -1387537700, -78076605, -531089724, 78076605, -12886580, 6443290, 642184376, -6217180, -3108590, 22115911], [-153392459802, -1590770816, -3733663944, 308007417244, 2407698990, 287172358, -86047096, -375198034, 38653332, -38653332, -485518160, -360980566, -360980566, -22294450], [170667323352, -6769843152, -3503996733, -84166769, 590119300, -13784012, 258654465, 266141921, -79835959, -79835959, 40593087, 16764607, -16764607, 26809075], [41073604332, -11628313511, -1398647447, -19745158848, 1068572544, 427492241, 4010524326, -674522066, -61527333, 0, -338600974, 173605761, 0, -158138558], [165817142, -5049821121, -7906035800, 215087522763, -1906222024, 260525077, -4631745202, -26387894, -54997907, 109995814, -259935089, -138839260, -277678520, -233547195], [-27539121578, 17436879755, 2279021752, 12995356421, -4487007640, 250115921, -2690626518, -259062230, -48471213, 0, 312891845, 636572128, 0, 554061457], [3437660764, 4369552373, -1701661711, -4077376357, -3167385394, -129727788, -834536250, 129727788, -54547734, 27273867, -211210679, 168102678, 84051339, 296208678], [-3204551124, -971981596, 8023163146, 6610784934, -71559288, -43616428, -3125454396, 222590092, 253366572, -253366572, -54782044, -332531970, -332531970, -456345800], [145875794739, 2298337899, -6165968192, -144807278375, 4588502020, 643848189, 4246038915, -643848189, -374162990, 187081495, -1478746744, 70610288, 35305144, 183874870], [128367103224, 1200897552, 4528635985, -257624184665, -1887690024, -223304154, -150470317, 333000951, -91121931, 91121931, 434257743, 220065755, 220065755, -8440005], [255018230703, 7828707360, 3837982452, 103507738, -958041323, 144155935, 149950035, 529783106, 230567309, 230567309, -156169359, 64675045, -64675045, -12013424], [-171262241903, -1382161158, -848682939, -171064050978, -627403228, -23884707, -1377730726, -393855225, 0, 328630428, -151169286, 0, 299638844, 33815973], [128508228, -5034012020, -12593907915, -32964311537, 472820967, 12448209, 3162987323, 2572007783, -642528, 1285056, 2614306394, -73761408, -147522816, 42298611], [298610339119, 6773290407, -968267373, -148972648357, 2822610374, -255348786, 866825874, -224523654, -120904362, 0, 343453749, -255786332, 0, -391767477], [-106497310378, 9343971126, 6045582510, -942235764, -2642102970, 454534140, -3886141806, 2024295162, -48822978, -48822978, 241056576, 5588472, -5588472, 695590716], [-159356851654, -16285635929, 2248599456, 79646650261, -6949773992, 489602709, -1448864658, -970276338, -227277441, 0, 540497169, -115919488, 0, 549426249], [385315993764, 19584822648, 9216389733, -195918095, 4156936372, -388098476, 1857601971, -97646557, -133570117, -133570117, 247734261, 88548049, -88548049, -140364215], [-67945581194, -3344292713, -5105642971, -68869971777, 8238333014, -569423330, 8058038762, 812463086, 0, -252679530, 851502778, 0, -442711873, 160559570], [857375479965, 19941406514, -838250745, -428214006930, 432260115, 213582120, 2100180555, -125860965, -49070295, 0, -365976345, -112700535, 0, -64673070], [136154048550, 528391068, -18139535044, -271489544086, 1429206858, 289165056, 5917558327, 49897155, 402098373, -402098373, 934010745, 48942154, 48942154, 545051379], [55816337037, 2203147056, 2134012579, -56912902610, -4700701196, -473491923, -3543889116, 473491923, -288768080, 144384040, 515357006, 60172868, 30086434, 119495293], [-334660511412, 128134690, 14715978173, 669777586713, 1212045282, 144642874, 3805605273, -652670839, 13195851, -13195851, -707573129, -22635267, -22635267, 453125675], [-250285558453, -8052831674, -4157607824, -252188733669, -1519629068, 701121798, -8358980492, -988007922, 0, -90133074, 24709374, 0, 704647486, 869274234], [284104686599, -30995101835, 1468406079, -142691446193, -4486759394, 335553156, -1945469718, 1116316818, 132253128, 0, -1069146657, 130035836, 0, 718276473], [419484579116, -9616523382, -6407181198, 359034384, 5455627860, -576245202, 3935275974, 854117340, 250364814, 250364814, 169895016, -122579214, 122579214, -406350186], [-983338271, 16216762049, 31939653866, 266878919816, -4420753352, -496132468, -3539605294, -1869949446, -246561034, 493122068, -2485934976, -128779727, -257559454, -615985530]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_9_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_9_9_d_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_9_9_d_a(:prec:=14)
    chi := MakeCharacter_9_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 9));
    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_9_9_d_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_9_9_d_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_9_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,9,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;