
// Make newform 14.9.d.a in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_14_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_14_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_14_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_14_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 := [3600954063202500, -240706289358000, 55526550982200, 1285719886320, 370996492174, 6901058684, 1175865280, 26522276, 2442597, 26038, 1771, -2, 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], [100577541142725735099229462157412458045331927000, 9752897271144501115378783140540022894025772300, 1155801182140862748139978075585720247425691610, 83195425529662130594620284172473556520625116, 3431321599519171490777749116011582452833751, 284512405463777430352832268454748628032240, 11131778344973963974751938311173829249679, 622041487093150864202690645978361783318, 10336572935328367533679520460308503877, 407836869298474437455340301140187004, 1758499405810309934504783994922142, 249242624836958096947291049205614], [150034933393435109178188851023054000, -2348955365028536232136922784228000, 216994393067807114987978096647200, -78770721438988807079781895174936, -210613223065982349309540476456, -177379614919651411062138004000, -4647099311970982545404004644, -492429624969135883257007488, -8227695102102134864192572, -255656756837032256753104, -1989997430335076733412, -202090052997757213384], [11048918485871635720300924597905528453681638174380776000, 2609163799660988726206299505343982055052819191399183200, 125259619206429743630981741652544433292642123735802680, 9559307238130164790593403222159884577147488085189808, 533309023488774125337998971963209286841493095593888, 34189804034808176908885236138447656435084129832920, 1290973311556908475057672630467631408439113945252, 73459172959773528557928505036741541190581453484, 1382489401609375767735252142925667919161845876, 64657565555049528396993084926195892268746452, -218430194229633744914529509073840115789804, 41466642982043738305273750221571278377732], [17656872738224806868685989645541870952246500333106158000, -24101229407841138985904149994241803467059961916824406100, 11194347562900742482531966839561089404070058662810315010, 100459380576449475811943110413541399869124245062317112, 47519376018943913728261455324996976673842923796102642, 469124529312721785403062613745097575736127941947990, 152258660470792224705189335185372111479933938682913, 1635418641096863313961322782299085271264352279711, 152257971561328579190512743840277120436094414269, -724187265147914038683840864063323587849202977, 83419531780039032690201645845364424620478649, 416361346654130880490374626655268745479463], [-241165496374865603682926620869774394120961475218712270000, -10620664366312992936205870366931172955784750735702290800, -944306698004242772508106072943219014629670701209248870, -212669163719908120905897579968838538908869996968681118, -4966677370268843341891938394400027416193285712050608, -763632065475278324706574888801816554973217288388080, -5516353569162915939788143763380145333041507995102, -1995634045352548589813886520628978686507054310299, -11091152800635802453515284628446051652545273926, -1973509215187391789277433433456942878359815137, 19502745668349376651497211228924857245523704, -1145815889892341699137506425515298722909587], [7732860726877153011364611627147521104563087324812870163000, -979968191817695509239492207936169183358452728883785357600, 128842459025450677687818931662652646100632027294619773910, -1532039130442328265040293269889121047614004544441094158, 516785049796433054129812292352610145171750033265810697, -1675355283358245033326151936374671965118414621317910, 1383011116657344977720792301045192622547699914245808, 8087516130343865274904836888925115218723457299026, 1455828114681429701562349062907184157030139628654, -7138296395107475206202095340752014623812725682, 667667631244759922773804775436299609568695609, 5495579581113250517855571253762177392755858], [57450872122232736507102845719679340982960753799545368300, -9303624552797197342776939363338318114866087999414470780, 1645580859499540273443210994415355824399204605423190598, -45353551571053906716007926535316700054871243375345060, 5561902985858601673847701158887338078764558680244667, -161193743020770106471834012893585008602281854743468, 15051521805736275037135623479454776067684072596317, -285224642046864275284555934231655258584311144428, 13975392894405534406740603693860221579479146711, -448077610113858922692708164723484054305969626, 11076708877696649476314858471113280223584626, -158440055710593771333573434464031055843352], [6241302018424916716520352415283216078282149054799324236500, -1316468971886965146315172757264016106366242735917074758300, 57833979934933172253527736519353753090046302595382834830, -2215738864388531059188072659191979657590260092994673324, 230593287079152895123730399697447048161785154945899141, -5579362554887008376032350420863168736961959573896080, 616340150342139452979141988507529233907786787919549, 21856784456137120302835150455639479287244201870178, 1041010639949359875858898386360490248227222513087, 18628088359048013988524427791913060656119219604, 33978356650661927731565069037399504966592202, 21671260854372082334445416501533519534807274], [-534528175808492850354764003581439147036279100520540295250, 33024100585113029835809052248057884232818750010765524800, -8411631621313678813968248805324051895562520580259616780, -257682816869338843592581437613229422847850523955116796, -31514773104726540947794778926507061180298612386904286, -1036336096058502228735947786172208544368415887999820, -88632334668640075862200031091723168892175144267404, -3946633716907299003685585400876117111542551665388, -103180832176926762060496335060190233717535385102, -2721438576095324317780324293542810456680861784, -13279530129478590296525171412296447756375492, -2173528904131441458009971836639308358950104], [-728787492912071612260228686639291617467029975510027620850, 82646400383990342945079830424303830081096093192653317660, -7051154941912441456986641623207954638663478977119909486, 511653233930519368041071822323296417612389909010145708, -22424563855579382709901561606945884739972047153673381, 1949009128820245569732888224165670526005872906510896, -49546918059578041624117727486400800041601472147677, 3823941870258771558390566199783811253313706130590, -51415982349225028601291759334193657185765221151, 4105290422855365149774744126081495911796380844, -59942027641509745703892998072578072380937866, 1743817570254302948751899750688953557252406], [2357812857253037522183584622936627511935928895166157005250, -548709828327028422741922046636267966424858941439630031200, 57819415461716020862064805141090404382558402152833581920, -7086191659000070842978264887256629193273286369363733988, 189843226779528551800210148878169030515482098888981857, -22668310921592135750551964440607954495292318308728270, 565489030353014112712334827056384631204157767801678, -59047044070849096656387266542233977458933691840649, 372486256700861382307871249236873238856256146464, -64729743614074697773183182877419963618735975547, 917531769222276360804838742722040326696532069, -33579506044971888441366079471221253936768177]];
    Rf_basisdens := [1, 127562314326329112726185736550948605192663192750, 14896903529326271843615438766774375, 2237235385617246536586335951817401866224361341488799375, 4474470771234493073172671903634803732448722682977598750, 1491490257078164357724223967878267910816240894325866250, 4474470771234493073172671903634803732448722682977598750, 89489415424689861463453438072696074648974453659551975, 4474470771234493073172671903634803732448722682977598750, 447447077123449307317267190363480373244872268297759875, 298298051415632871544844793575653582163248178865173250, 4474470771234493073172671903634803732448722682977598750];
    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_14_d();"
function MakeCharacter_14_d()
    N := 14;
    order := 6;
    char_gens := [3];
    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_14_d_Hecke();"
function MakeCharacter_14_d_Hecke(Kf)
    N := 14;
    order := 6;
    char_gens := [3];
    char_values := [[1, -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, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [18, -9, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [93, 93, -7, -7, 0, -2, 0, 1, 0, 1, 0, 0], [38, -295, 51, -66, -8, -1, 0, 0, 0, 2, 0, 1], [4, 1714, -24, 585, -26, 49, 5, 5, 12, 13, 6, -4], [1471, -2932, 826, -1719, -36, 41, -15, 5, 0, 20, 0, 5], [19224, -9648, -2387, 1163, -61, 9, -9, -1, 0, 9, 90, -18], [22534, 22602, -801, -822, -7, 759, 14, -70, -54, -63, -54, -21], [26600, -26506, 2060, -4065, -2039, 1045, -68, 89, 60, -38, -60, -17], [-362999, 10, -12070, 183, 2310, 2127, -61, 399, -132, 108, -264, 305], [502162, -251147, 1797, -1311, -825, -66, 66, 81, 0, -66, 0, 132], [21790, -22296, 73208, -79941, -6587, 3184, 292, 515, -360, -734, 360, 73], [263301, -526518, -30768, 91291, 14564, -13937, -1881, 627, -1170, -2090, 0, 627], [-1079876, -876, 20284, -846, 5254, 6100, 282, -2578, 1440, -866, 2880, -1410], [1021449, 1021089, 184493, 185033, 180, 23377, -360, 1951, 0, 1771, 0, 540], [678, -2757588, -781, 311616, -463, 1403, -795, 1078, 720, 1679, 360, 636], [3461670, -1732701, -708091, 370810, 33529, 384, -384, -6566, 0, 384, 4500, -768], [-4744216, -4742414, 596898, 594357, -847, -58506, 1694, 9665, -108, 10512, -108, -2541], [4792, -6295585, -52333, -66342, -54201, 105600, 4670, -2370, 13320, -1938, 6660, -3736], [3794318, 11012, -461056, -6348, -80078, -73730, 2116, -30136, -6780, -11894, -13560, -10580], [1039454, -529157, -1391300, 688938, -13424, -520, 520, 16938, 0, -520, 17820, 1040], [9941786, -9950148, 1463548, -1534479, -61129, 23213, 19604, 12247, 1440, -26950, -1440, 4901], [-10582284, 21164100, 1806, -408776, -202060, 201016, 3132, -1044, 1620, 45670, 0, -1044], [17951043, 17921463, 401988, 438582, 12198, 31116, -24396, 13254, 5184, 1056, 5184, 36594], [16623857, -33253410, -903596, 1483143, -156888, 146615, 30819, -10273, 14850, -83302, 0, -10273], [73065114, -36501699, 415854, -219093, -22332, 10662, -10662, 1929, 0, 10662, -40392, -21324], [22915782, 22930988, -3717414, -3771813, -18133, -500265, 36266, 8945, 21060, 27078, 21060, -54399], [-43818200, 43824652, -4587421, 4192350, -429213, 240213, -68284, 19074, -27690, 32139, 27690, -17071], [-9708, -60652405, 83620, -4874181, 88816, -169838, -12990, 3569, -29808, -656, -14904, 10392], [-23497911, 64980, 160450, -53865, 313258, 367123, 17955, 70367, -29070, 62116, -58140, -89775], [66774512, 84192, 12290828, 19782, -176158, -195940, -6594, -35534, -97380, -27658, -194760, 32970], [-49753533, -49791225, -10806324, -10659498, 48942, -209775, -97884, 127518, -60192, 78576, -60192, 146826], [14656, -184132382, 685477, -739389, 667403, -1361917, 45185, 61555, 65460, 150221, 32730, -36148], [-208763314, 417673060, -4516726, 11331894, 1142016, -1127606, -43230, 14410, 117612, -127622, 0, 14410], [-145833375, 145803363, -777299, 1557783, 686980, -273362, -187008, 131123, -123516, 9133, 123516, -46752], [-92516, -92935695, -2220827, 386499, -2101483, 4381982, -298360, -94145, -423720, -367306, -211860, 238688], [-78796662, 39554166, -13975995, 4862394, -4251207, 1665, -1665, -506568, 0, 1665, -308340, -3330], [-46506777, 46308073, 560222, -3559170, -3029024, 1537069, -60152, 132818, -228780, -87704, 228780, -15038], [167240601, -334100028, 2282004, -1910737, 1321162, -1310215, -32841, 10947, 359280, 110504, 0, 10947], [-93237666, -93201036, 11040696, 10618281, -140805, 4145178, 281610, 687297, 244980, 828102, 244980, -422415], [-143752, -139696654, -367660, -20895849, -401318, 752149, 84145, 595643, -220188, 1241773, -110094, -67316], [-56685150, 114026824, -33935726, 60394410, -3802320, 3929918, -382794, 127598, 401328, 919262, 0, 127598], [-462649117, 462618269, 79804525, -72099441, 7774656, -3939507, 139144, -652803, 38724, 548445, -38724, 34786], [62720, 114558484, 3853223, 11184567, 3841513, -7700591, 29275, -1354825, 148860, -2692085, 74430, -23420], [-659907065, 531766, -57880498, 95061, 4926354, 4831293, -31687, -400515, -595140, -247788, -1190280, 158435], [-517717374, 258395521, -18876991, 11843991, 4810991, 42490, -42490, -2085693, 0, 42490, 1011312, -84980], [-104364268, 576148, -57718956, 385770, -6873110, -7258880, -128590, 370310, -833328, -7730, -1666656, 642950], [433541454, -866955048, -10743696, 23391546, 1120992, -1458822, 1013490, -337830, 803520, -1583616, 0, -337830], [1496437512, -748223970, -120495906, 62715555, 4935204, -364269, 364269, -34293, 0, -364269, -718110, 728538], [32223937, 31032361, 54823017, 55126461, 101148, 12678666, -202296, 1766289, 989280, 1665141, 989280, 303444], [-732081626, 731272822, -63970113, 48551598, -14983901, 7165990, 869228, 1017614, -374190, -1669535, 374190, 217307], [2398895213, 240410, 19644138, -399909, 4933202, 5333111, 133303, 719491, 26196, 559700, 52392, -666515], [-3125445762, 1563168317, 117873022, -58889778, 93466, -416890, 416890, -1073058, 0, -416890, -1724652, 833780], [-188242959, 377279178, 35956506, -91565257, -10174742, 10871981, -2091717, 697239, -601218, 2797970, 0, 697239], [-1294137426, -1292300922, -80389509, -80450070, -20187, 5292468, 40374, -4342986, -1796130, -4322799, -1796130, -60561], [-928678, 1367174840, -8145808, -178131462, -7731266, 16084345, -1036355, -559330, -2686440, -1740473, -1343220, 829084], [-426890322, 213865344, 67873463, -27943532, 11986399, 207891, -207891, 1567642, 0, 207891, -424584, -415782], [-317983562, -318719968, -87264276, -87270663, -2129, 2034831, 4258, 3205531, 740664, 3207660, 740664, -6387], [2243874, 2009326558, -8365543, -184771218, -8197429, 16647029, -420285, 1546708, 4151520, 2841245, 2075760, 336228], [-634406749, 55304, 193218078, 1966929, -19773586, -21740515, -655643, -5042807, -1366590, -3504868, -2733180, 3278215], [-401441452, 199055630, 602632626, -305782083, -8931540, -346281, 346281, 4936617, 0, -346281, 2637630, 692562], [3381291282, -6762973776, 154526250, -303200846, 3018860, -3204926, 558198, -186066, -19080, -4291178, 0, -186066], [1110724774, -2219322740, 123477198, -215104050, 15310716, -14081802, -3686742, 1228914, -331020, 2813214, 0, 1228914], [6528909210, -3266082642, -98290514, 37567910, -23154694, -773991, 773991, -1201222, 0, -773991, 1708092, 1547982], [3752993231, 3753911811, -33135156, -35917566, -927470, -35972448, 1854940, -4487522, 936360, -3560052, 936360, -2782410], [-2175643344, 2174021214, -24190768, -43607283, -68020741, 34177388, -445380, -4543391, -1844820, 4877426, 1844820, -111345], [-2000472637, 2001891001, -422510712, 505148292, 82082208, -40624575, -1110744, 4951392, 862992, -4118334, -862992, -277686], [3309047617, -4257636, 230642778, -154161, -24500730, -24346569, 51387, -4161849, 4360410, -2003844, 8720820, -256935], [14224, -5022203891, 44364401, 20462526, 43462905, -88278054, 2253740, 8523966, 1831440, 18400176, 915720, -1802992], [-5070390731, 10135147692, -424401958, 771255411, -39093864, 39733087, -1917669, 639223, -6912216, 10930840, 0, 639223], [-1153637424, 579358812, -81836843, 55269599, 28702355, -786795, 786795, -11014897, 0, -786795, -6653790, 1573590], [-10915947787, 10922003135, 1180618017, -1220986839, -41810638, 21986681, -2883632, 6931639, 4613532, -4768915, -4613532, -720908], [4825804402, -2410567786, 276037862, -172167372, -68296882, 398785, -398785, -12960156, 0, 398785, -3871260, -797570], [5076163162, -5069289304, -346893192, 159805107, -188124003, 94838940, -2071836, -68553, 5837940, 1622430, -5837940, -517959], [7138573365, 1215224, 63514994, -206157, 52318018, 52524175, 68719, -26658109, -1077786, -13225976, -2155572, -343595], [-5478555807, -5485932243, 159159937, 165531721, 2123928, 97333397, -4247856, 1262147, 3128580, -861781, 3128580, 6371784], [828340, -9166809593, 37955832, 1476345489, 38114620, -75991058, -396970, -9515377, 1339104, -19268936, 669552, 317576], [5506657253, 5530321349, 356667939, 351297315, -1790208, 72948294, 3580416, -5538465, -20083680, -3748257, -20083680, -5370624], [-286160068, 291112616, 657263175, -682930380, -26755147, 14193530, -2175884, 15440992, 3864606, -13809079, -3864606, -543971], [2066705104, -1038784710, -456324341, 209392683, -37538975, -3971161, 3971161, 8798211, 0, -3971161, 2921994, 7942322], [6928735674, -13866859308, 395902374, -796983670, -1107668, -1855918, 8890758, -2963586, -3460788, 7635542, 0, -2963586], [-14885968411, -2110014, 995243866, -1344141, 20956762, 22300903, 448047, -2244085, 3006108, -449972, 6012216, -2240235], [-349628, -26268805157, -3312553, 394097763, -5249373, 7593516, 4842050, -11441469, 3174384, -19977708, 1587192, -3873640], [5784045659, -11576434906, -900164364, 2185857285, 194857128, -199042827, 12557097, -4185699, 27810, 25671414, 0, -4185699], [763518939, 745069323, 772252641, 760484115, -3922842, 158457585, 7845684, 14116977, 26295300, 18039819, 26295300, -11768526], [-9303453174, 9313418238, -363893211, 325208898, -38153667, 18678849, 1061292, -31705278, 10495710, 30909309, -10495710, 265323], [-29671826407, -3737872, -915838006, 929319, 68547670, 67618351, -309773, -7238113, 3118326, -4083716, 6236652, 1548865], [29296565747, -29313099707, -1346973108, 1527321150, 175118742, -83637396, -10458600, 15758010, -21763260, -7914060, 21763260, -2614650], [-6760652703, 13509874800, 1527294162, -2416196705, 317185784, -313165733, -12060153, 4020051, -19470708, -5032424, 0, 4020051], [6710927702, -6757536, 1706386344, 1909404, -144696354, -146605758, -636468, 6212688, 5484600, 2151642, 10969200, 3182340], [-7015851309, -6972925665, -1622065284, -1655631090, -11188602, 193206549, 22377204, -24513198, -20548440, -13324596, -20548440, -33565806], [17591000046, -8786143122, -270564082, 311516920, 352469758, 402405, -402405, -49831844, 0, 402405, -17908992, -804810], [6355410, -21534877780, 15412964, -3432557946, 3230714, -24734803, 30455625, -17043734, 37075320, -15814093, 18537660, -24364500], [-1657695735, 3466512, -729771878, -7334361, -123638246, -116303885, 2444787, 39723623, 1423062, 23528992, 2846124, -12223935], [-44574718297, 44587382185, -2080412702, 2272492986, 199069696, -104776907, 13978824, -9435298, 19653300, -1048820, -19653300, 3494706], [6315021018, -12594784368, 2446988844, -5356041386, -236667016, 247937350, -33811002, 11270334, 12717000, 32479612, 0, 11270334], [21748308627, 21729879639, -191303183, -215390513, -8029110, 119050610, 16058220, -34470865, 34487208, -26441755, 34487208, -24087330], [-58535224530, 29246874621, -1069618522, 572224504, 74830486, 392574, -392574, 50972788, 0, 392574, 42260436, -785148], [-39811615314, -39859314410, -230569251, -185822292, 14915653, -157860705, -29831306, 16841968, 17867790, 1926315, 17867790, 44746959], [-5985037355, 5985497879, -1609447665, 585216225, -1026762936, 515280090, -5062992, -3220059, -2070972, 7017303, 2070972, -1265748], [-13421986103, -1945168, 531442922, 4726887, -312612350, -317339237, -1575629, -99538393, -1206090, -52132640, -2412180, 7878145], [14297044, 31426365937, 309665466, 585981009, 305646730, -617321564, 10046840, -45645553, 36631560, -85263002, 18315780, -8037472], [-65128182258, 32597724093, -5309050857, 2935823622, 562596387, 18326574, -18326574, 38051826, 0, 18326574, -30612780, -36653148], [86453258453, -86429967649, 3137804566, -2216255982, 918594456, -457081632, -5908256, -40630578, 20336676, 45061770, -20336676, -1477064], [-15299868, -8395968620, -358328826, -4452123933, -350092560, 712539519, -20590665, -23920809, -47072268, -60196017, -23536134, 16472532], [-8498002214, 4251586545, 7247993806, -3483702870, 280588066, 14089598, -14089598, -29249910, 0, 14089598, 23008320, -28179196], [32046962682, -64012258860, 115423194, -142584030, 41489508, -36206166, -15850026, 5283342, 71099820, 162257082, 0, 5283342], [31581680148, 31577386128, 185912161, 158997526, -8971545, -1310359576, 17943090, 78242822, 22237110, 87214367, 22237110, -26914635], [-66442790, 8768788576, -180733332, 2572067586, -193943990, 368071993, 33026645, 40611122, -106464264, 101038231, -53232132, -26421316], [705992533, -1306670162, -1688624040, 4126837803, 363809088, -341837541, -65914641, 21971547, 61371810, 65361942, 0, 21971547], [-36592835713, -36499445325, 4707114759, 4707842817, 242686, -671764383, -485372, -10500917, -93875760, -10743603, -93875760, 728058], [-54991024, 97464860721, 112551450, -3781233549, 95450786, -216552568, 42751660, -2565947, -75780720, 20519102, -37890360, -34201328], [-79182494913, -22623528, 2199438046, -9168723, 214861114, 224029837, 3056241, 84575285, 28736010, 46872004, 57472020, -15281205], [66843450098, -33419279295, 2594628275, -1239332280, 115963715, -10919354, 10919354, -25305756, 0, -10919354, -26730216, 21838708], [37531141360, 10003208, -6227435380, 41821062, 73545154, 31724092, -13940354, -115428238, -37883916, -78624650, -75767832, 69701770], [17599984, -47397017, -320526250, 12634532838, -311523846, 636551298, -22506010, -6328434, 17195160, -26160474, 8597580, 18004808], [13045356740, -26119172692, -3666866538, 5637372432, -860103624, 883950228, -71539812, 23846604, -76152420, -12406482, 0, 23846604], [36571943382, -18330108690, -4126870014, 1656937494, -812995026, 42789141, -42789141, 70956282, 0, 42789141, 173852280, -85578282], [59670321262, -59672934788, 7679186558, -9669959031, -2006621967, 1015198104, -31698988, 86718189, -18463020, -62943948, 18463020, -7924747], [6219120440, 61927136, -2553199620, 33017550, 390578138, 357560588, -11005850, -88856918, -83938836, -60937234, -167877672, 55029250], [19020121102, -9499603540, 15426782171, -7604670066, 217442039, 9780175, -9780175, -96754992, 0, 9780175, -1353672, -19560350], [47698009237, 51875244, -8628749950, -5065821, -127557754, -122491933, 1688607, 229926523, -48498030, 117496172, -96996060, -8443035], [96512954841, 96460246053, -2855994459, -2676966747, 59675904, 577775562, -119351808, 2851449, -66643020, -56824455, -66643020, 179027712], [-29987856, 407881710, 13457876, -3020146971, -62299390, 10962881, 189393165, -29448947, 91538820, 54738005, 45769410, -151514532], [3096640637, 3187081805, 2672482494, 2673926850, 481452, -789224667, -962904, 178441074, -91404072, 177959622, -91404072, 1444356], [-68251532322, 1421304, 6614201192, -6790212, -1073048440, -1066258228, 2263404, -173809796, 3105504, -83509792, 6211008, -11317020], [41452674768, -41431991686, -21230836250, 21106238979, -100815889, 32571908, 47562764, 42190867, 44464464, -77862940, -44464464, 11890691], [14499756690, 14330585052, -12489620816, -12498226031, -2868405, 141195167, 5736810, -23576581, 174908448, -20708176, 174908448, -8605215], [-61874875348, 123752879972, -2798199540, 5502325596, -35870076, 13536744, 66999996, -22333332, 47795940, -60776868, 0, -22333332], [-96980026366, -96977883436, -1134095148, -1360874403, -75593085, 351786066, 151186170, -66781755, 149043240, 8811330, 149043240, -226779255], [-76515804, -205574130098, 1234879872, 2667964311, 1199303574, -2451971595, 88940745, -271447161, -81879012, -489529875, -40939506, -71152596], [-132042806540, -20518412, -4145057372, -50975862, 92230346, 143206208, 16991954, -219708362, 54502320, -84366250, 109004640, -84959770], [-43519956589, 43480771105, 3163381661, -2034713157, 1130318948, -566397307, 3300888, -129976415, -37535040, 127500749, 37535040, 825222], [34868025395, -104328206, 2680753078, 71187969, -5544742, -76732711, -23729323, 106517929, 56869560, 17664980, 113739120, 118646615], [88521891612, 88399227612, 4733979679, 4782131416, 16050579, -2086488352, -32101158, -308596588, 90562842, -324647167, 90562842, 48151737], [-30632400279, 61027801322, 1891976612, -1745346369, 1041612444, -1086230477, 133854099, -44618033, -147763170, 242340850, 0, -44618033], [9632546226, -4893222945, 4341210460, -2294779747, -248349034, 24996948, -24996948, 269057675, 0, 24996948, 203893560, -49993896], [73808499522, -36883462019, -300439225, -174428562, -649296349, -66275918, 66275918, -127607994, 0, -66275918, -174127320, 132551836], [45745480239, -91294723248, -3244458750, 11187001113, 2336520024, -2311476459, -75130695, 25043565, 146150100, 161242572, 0, 25043565], [96405240, -771534771, -1614407252, 2133435906, -1589245580, 3216233668, -62904180, -128375758, 142487136, -294494024, 71243568, 50323344], [-44393867124, 88965383340, -6049141590, 12618367536, 281124264, -323288436, 126492516, -42164172, 261977436, -93841806, 0, -42164172], [-179970596277, 180032378565, -3866299601, 1716809907, -2057064074, 959212822, 184851240, -203889229, 154207908, 65250799, -154207908, 46212810], [136829162, 178174295196, -592339480, -11995853466, -574357298, 1175687869, -44955455, 125410574, 237693960, 223847875, 118846980, 35964364], [-109730015622, 68176764, -429626656, -84109536, 985786118, 1069895654, 28036512, 587527156, -12103740, 335818346, -24207480, -140182560], [78957043834, -39428166493, -2205618292, 433100751, -1339416790, 60100048, -60100048, 220362957, 0, 60100048, 19489248, -120200096], [47965066890, -96006466704, 5030846292, -7996121026, 994422748, -917696686, -230178186, 76726062, -229785048, 417122732, 0, 76726062], [52109207163, -104558204204, -430607546, 2649205893, 863282700, -801857299, -184276203, 61425401, -462640680, 187006088, 0, 61425401], [346886170374, -173284910367, -26051727458, 12721694684, -608338090, -33209550, 33209550, -493768228, 0, -33209550, -382768740, 66419100], [87850024972, 87893252000, -6138474393, -6258640932, -40055513, 350309631, 80111026, 434171980, 36883998, 474227493, 36883998, -120166539], [-165508239316, 165513274406, 2738843978, -3659145687, -927616799, 469294717, -14630180, 103947431, -2280000, -92974796, 2280000, -3657545], [-105617707749, 105838402549, 16066457813, -19748319915, -3812366642, 2004061726, -261009080, 126772001, 90190260, 68984809, -90190260, -65252270], [92712478464, -185616986268, 10302062088, -26733999744, -3015364116, 2916216780, 297442008, -99147336, 6265332, -299664912, 0, -99147336], [-4829630762, -226244052, 4808870352, 210528828, -1646112150, -1856640978, -70176276, -33289632, 85891500, -121909230, 171783000, 350881380], [-103703946459, -103650565635, 9755850215, 9466905359, -96314952, -32508455, 192629904, 432238873, 139249080, 528553825, 139249080, -288944856], [-164103256, -230700188393, -1671567649, 17906947944, -1565927405, 3290315176, -264100610, -251071168, -539487000, -660602702, -269743500, 211280488], [197485132192, -266024168, -19002922668, 140558646, -1736962946, -1877521592, -46852882, -362070766, 172318404, -251314706, 344636808, 234264410], [316084357253, -316140802217, 12454099285, -7433944707, 4970341834, -2447811359, -99625488, -254814373, -106257708, 329533489, 106257708, -24906372], [-158505692757, -158358391389, 8723252546, 8798335352, 25027602, -2801366180, -50055204, 159407308, -197356572, 134379706, -197356572, 75082806], [-46835995912, 93061187080, -8494386148, 16181857872, -414455136, 436450984, -65987544, 21995848, -654796440, -325372724, 0, 21995848], [649224000714, -324743835534, 12722718581, -5381472170, 1959774241, 12468069, -12468069, 223780408, 0, 12468069, 288606492, -24936138], [382001556047, -381834377551, -4780911674, 5792789238, 1012517808, -506739087, 1280488, 528917502, 167818740, -529877868, -167818740, 320122], [-382391162715, -116930892, 2330611114, -44734797, -1888850318, -1844115521, 14911599, 519699515, 146754090, 282217156, 293508180, -74557995], [93173661258, 311917780, 38737598456, -215994480, -1668024342, -1452029862, 71998160, -1340888172, -167921460, -562446846, -335842920, -359990800], [193925501061, 193869614529, 11585839492, 10964076724, -207254256, -680367067, 414508512, -394578448, 470395044, -187324192, 470395044, -621762768], [-5724376, -66932393992, 2498758427, -36649916505, 2527854661, -5012064971, -72740585, -237649297, -69641220, -518942945, -34820610, 58192468], [56424571338, -28125340827, 36010130489, -12350485949, 11309158591, -71845218, 71845218, 38146699, 0, -71845218, -317580120, 143690436], [11733218, -189268941026, -841511602, 48187560102, -1109073440, 1816804123, 668904595, -353186938, 558590112, -305031119, 279295056, -535123676], [242246655290, -121336948630, -37623713919, 19234062828, 844411737, 34742565, -34742565, 770716182, 0, 34742565, 496727100, -69485130]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_14_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_14_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_14_9_d_a(:prec:=12)
    chi := MakeCharacter_14_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_14_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_14_9_d_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_14_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,9,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;