
// Make newform 38.9.b.a in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_38_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_38_b_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_38_9_b_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_38_9_b_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 := [9218779084612644462864, 0, 24830681474333400768, 0, 17370647163698184, 0, 5214446299656, 0, 738386961, 0, 46118, 0, 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], [-1373838894169787985475717944, 0, -3384671207395419974567700, 0, -1793134315636569559098, 0, -353286216457517619, 0, -26324430503956, 0, -627859595, 0], [-55983272825769961557419137351953576, 0, -137813144295779199390399764575500, 0, -71508680718346538969766820686, 0, -13814942804320117626042957, 0, -1017763065922454486260, 0, -24121866715514597, 0], [70177834995932192859188014024824264, 0, 172623436452128678415220175093820, 0, 94663934306522838531873005094, 0, 19223880793457955507632673, 0, 1456040578930597931300, 0, 35029922688763993, 0], [-1425882270081404839137844752911455992, 0, -3483662457189746493031161575476260, 0, -1815096393742013789389000746282, 0, -352601062796314536167993319, 0, -26065639628469526607900, 0, -618986366251557679, 0], [205627696128311115390625622010929256, 0, 495107109128898936934582066759980, 0, 256209719211152744199099271326, 0, 49517157755370789665038917, 0, 3649971332118746402900, 0, 86539462063981597, 0], [0, 41025489550497873181827514943784, 0, 74464449231549988985860204380, 0, 39664871910263669791484574, 0, 7834806036614273926833, 0, 584451732924588668, 0, 13946998708921], [0, -29571354492593489110032440914728, 0, -74464449231549988985860204380, 0, -39664871910263669791484574, 0, -7834806036614273926833, 0, -584451732924588668, 0, -13946998708921], [0, -165069551945580035325154407503925815304, 0, -324807244519316701149246211086354012, 0, -115344541421528164908248156011542, 0, -13043198936030284433391396729, 0, -569265796886210505271396, 0, -8367191740264433969], [0, 39852758935436971475106252934886352276936, 0, 107053061910302206543189523066577769500, 0, 56906307870372630615163382493453126, 0, 11140647613003328885517461706297, 0, 826158121195012989052943380, 0, 19647103015700413779857], [0, -99733967972159372895159102619708304862312, 0, -240201662798490922205337951714577332780, 0, -125006671730092999818511359218758302, 0, -24289830659965640898513821643909, 0, -1796051477157354058847378900, 0, -42657931362165516833629], [0, 150825559923347746278629395173856721714136, 0, 370777562231676662913796090387390289580, 0, 192145367348700068223448117559922906, 0, 37110870611229586637650549596777, 0, 2734016466856695724028659400, 0, 64801682891250922204057]];
    Rf_basisdens := [1, 30599403830793906815808, 507617182077499815436256808960, 211507159198958256431773670400, 2538085910387499077181284044800, 282009545598611008575698227200, 11454135057904384071795074029056, 1431766882238048008974384253632, 131954181230404705481317429497842688, 5937938155368211746659284327402920960, 5937938155368211746659284327402920960, 3711211347105132341662052704626825600];
    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_38_b();"
function MakeCharacter_38_b()
    N := 38;
    order := 2;
    char_gens := [21];
    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_38_b_Hecke();"
function MakeCharacter_38_b_Hecke(Kf)
    N := 38;
    order := 2;
    char_gens := [21];
    char_values := [[-1, 0, 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, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], [47, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-452, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [-1046, -2, 3, -2, -1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -57, 269, -1, 3, -4, 0], [22569, -16, 4, -9, -28, 1, 0, 0, 0, 0, 0, 0], [3430, 78, -11, 11, -31, 0, -169, -683, -3, 5, 1, 6], [-68761, 201, 59, -11, 10, 41, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1224, 3357, -30, 63, -9, -36], [0, 0, 0, 0, 0, 0, -1553, -21294, -59, -2, -57, 0], [0, 0, 0, 0, 0, 0, 123, 1294, -5, 132, -119, 120], [0, 0, 0, 0, 0, 0, -8933, 30906, 217, -14, 315, 126], [634410, -1102, -3403, -32, 723, 63, 0, 0, 0, 0, 0, 0], [-1688259, -2650, 1933, 169, 1593, 45, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 21848, 60699, 716, 383, 417, -360], [0, 0, 0, 0, 0, 0, -109858, 13197, 521, -976, -939, -18], [-3451227, 1778, 7603, -688, -848, -108, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 21781, 416315, -870, 514, 5000, 900], [0, 0, 0, 0, 0, 0, 55658, -570954, -1282, -58, 5160, -516], [7341843, -40438, -6790, -1247, -2352, 3579, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -260753, -578942, 611, 2260, 4735, -2484], [-4656328, -32862, 8162, 3148, 3154, 3584, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 304979, 1283328, -1915, 2228, -6495, -5454], [0, 0, 0, 0, 0, 0, -294998, 1610242, 3200, -44, -22376, -1260], [4229474, 90624, -51076, 12376, -23324, -3304, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 418012, -4142080, 6018, 1942, -21544, 2340], [0, 0, 0, 0, 0, 0, -158956, 7947021, 6131, 3272, 6807, -1830], [0, 0, 0, 0, 0, 0, 494134, -407679, 10744, 1615, 25365, -192], [0, 0, 0, 0, 0, 0, -308631, -3873258, 7911, -15606, -2019, -5970], [0, 0, 0, 0, 0, 0, -224977, 7221264, 9311, -5650, -4275, 18540], [40776060, 642098, 101029, -21350, 31227, 1071, 0, 0, 0, 0, 0, 0], [-62746887, 834926, 323290, 1951, -60012, 15231, 0, 0, 0, 0, 0, 0], [128962052, 126318, -122629, -33020, -17525, 22965, 0, 0, 0, 0, 0, 0], [305706283, -1014596, 128349, 14950, -64336, 47902, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2694530, -4350254, 13092, 40568, -3452, 14784], [-208602934, 695934, -371452, 622, -116168, -32748, 0, 0, 0, 0, 0, 0], [28178966, -894498, -191236, -31964, 113806, -20970, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -4738163, 21236670, -2663, 55132, -73095, 40200], [0, 0, 0, 0, 0, 0, 2219344, 2262318, 9976, -8858, 170820, -14400], [0, 0, 0, 0, 0, 0, -5937261, -3790062, -6873, -35256, 186669, 69198], [0, 0, 0, 0, 0, 0, 1940704, -34340666, 54080, -35090, -207584, 59412], [-544054694, 210979, -1028430, -69814, 63237, -84306, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 5269573, 21106162, 117137, -105644, -99611, -46350], [-498097474, -1057254, 759620, 88090, -285308, -87736, 0, 0, 0, 0, 0, 0], [237881754, -347893, -1905016, 111892, 294561, -77256, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1159036, -76342817, 115395, -92374, 359221, 41562], [0, 0, 0, 0, 0, 0, 9607643, 11397684, 129737, 104456, -29859, -58740], [0, 0, 0, 0, 0, 0, -7214092, 60176223, -265315, 37268, -147195, 81210], [-1558954691, -780074, -2524221, 226464, -185852, 130656, 0, 0, 0, 0, 0, 0], [-1230219548, -359972, 48795, -46145, -1305250, -28286, 0, 0, 0, 0, 0, 0], [298006312, 486625, -774882, -178006, 456969, 375894, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 35835967, 34588742, 45, -81890, -69769, 101322], [-503573992, -1991832, 1607987, -93694, 1201031, 232441, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -28148694, -207039276, -62040, 290238, 144834, -316020], [1053338447, 4193286, -750859, -100597, -808207, 399301, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 23985393, 35137986, -132387, -141240, 685923, -41796], [-2608681831, -7434441, -3348675, 37527, 479454, -150057, 0, 0, 0, 0, 0, 0], [863221921, 5955274, 676629, -284214, 789604, -679518, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -8218850, 269026824, 81178, -296288, 1047702, 325056], [3636298990, -8457734, -2901431, 223268, -1014849, -725097, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -40065133, -201397233, 80813, -496225, -793050, -6600], [0, 0, 0, 0, 0, 0, 53041583, -133647534, -129865, 181868, 542313, 331410], [-1215889228, 10516647, -3930268, -415038, -2304963, -599568, 0, 0, 0, 0, 0, 0], [-1308512329, 1122342, -2939689, -306872, 1016146, 1312329, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6708245, 628593261, -191209, 257225, -996666, -155880], [0, 0, 0, 0, 0, 0, -127958893, -113269231, 132706, -302578, 170060, 501420], [0, 0, 0, 0, 0, 0, -11920036, -647093680, -403538, 882770, -5140, -874500], [7119548204, -15468456, 3884321, 1637376, -3192621, 914043, 0, 0, 0, 0, 0, 0], [-724230627, 10844732, 18407765, -934292, 2551908, 1029738, 0, 0, 0, 0, 0, 0], [-1622308639, 12965232, 11258621, 215902, -7722878, -480337, 0, 0, 0, 0, 0, 0], [3146630690, 5749113, 9307064, 1470918, -2972703, -2729520, 0, 0, 0, 0, 0, 0], [-4583519854, -6011268, 15201072, -311574, -2457342, 2909838, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -21115711, 2177411251, -299061, 644999, -24428, 359580], [0, 0, 0, 0, 0, 0, 76662812, -35076527, -1568703, -776854, 585499, 114150], [0, 0, 0, 0, 0, 0, 75412961, -427068300, 496571, 3656, -2739561, -1623360], [-4635063019, -17823366, 20679881, -1711726, -3380668, -247322, 0, 0, 0, 0, 0, 0], [-11244415729, 8801574, -25098183, -2433336, 7540668, 3761718, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 59358957, -1036015416, 2925729, -693990, 3922539, 854646], [0, 0, 0, 0, 0, 0, -137857297, -1670897162, -300861, 1158164, -5411045, -533406], [-322281352, 33620718, 19712690, 2971048, 1879594, -2879224, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -13209774, -154492825, 1341230, -561561, -2205805, 1193064], [0, 0, 0, 0, 0, 0, 185757136, 2325733656, 571012, -3858164, 2376528, 2220720], [0, 0, 0, 0, 0, 0, 3530775, 1804249452, -1229475, 526068, -5003307, -1657050], [0, 0, 0, 0, 0, 0, -126475253, -2297223144, -1799573, 1816390, 4810269, -1156344], [-18990824074, 9820806, -951949, 665910, -10310997, 1306485, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -148388668, 2735769270, -1466188, -10618, -5267646, -1371276], [-149380567, 19952238, 24683130, -3819021, 7019232, 7385331, 0, 0, 0, 0, 0, 0], [22959301623, 41100530, -23751605, -167994, 12827252, -1132016, 0, 0, 0, 0, 0, 0], [32406883195, -43958390, -20677031, -2031985, -2141703, 4790529, 0, 0, 0, 0, 0, 0], [-2378750100, -21449020, -21583349, -267858, 9940043, 5779693, 0, 0, 0, 0, 0, 0], [2658247574, 60222576, 19704740, -183626, 7448890, 3166442, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -197195270, 3687021400, -4472140, -355970, 1980442, 984540], [-26247260764, -73900284, -13320250, -1265042, -14349482, -6122872, 0, 0, 0, 0, 0, 0], [36694933656, 37976774, 15989977, -6689206, -15150473, 5928903, 0, 0, 0, 0, 0, 0], [-13041722581, -19385349, -4740625, 825127, -185354, -6267655, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 465201270, 3099695430, -984270, -1807770, 12617022, 5229804], [0, 0, 0, 0, 0, 0, 128806973, 892600818, 7263767, -5414086, -5910999, -2205450], [0, 0, 0, 0, 0, 0, -317146112, -3832956031, 6113577, 5247214, 1933079, -2409630], [-24593524423, -48894804, -60909177, 6752622, 1822152, -4579368, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 194446372, 4953616994, -2420676, 610666, 802340, -2923860], [15975944413, 30660556, -56963877, -209794, 3690912, -5278716, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 616209979, 2217255714, -3539429, 3647404, -21607683, 1650], [0, 0, 0, 0, 0, 0, -439320318, 5437889706, 409512, 1927596, -1279812, -6762708], [-440639734, -25368756, -51640128, -79518, -11307870, -11985954, 0, 0, 0, 0, 0, 0], [45787940191, -1693796, 81964212, 5872593, -49022444, 3705897, 0, 0, 0, 0, 0, 0], [28293842630, 41619912, 98128709, -1276846, -20012401, 8965195, 0, 0, 0, 0, 0, 0], [-3641851726, -7061244, -20754484, 3551572, -34437740, -7838104, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -168357931, -5427613008, -7951903, 1383326, 24436947, 1748352], [0, 0, 0, 0, 0, 0, 769651410, 6888318810, 6478278, -3446958, 10476828, -5191824], [0, 0, 0, 0, 0, 0, 404389554, -1889001338, -10877666, -5889618, -8735204, 4847220], [33589392807, -38983984, -57985949, -11467228, 26606200, 844140, 0, 0, 0, 0, 0, 0], [-11342396990, 137710864, -60319521, 7972193, -69092454, 17778546, 0, 0, 0, 0, 0, 0], [76182303404, -6112200, -117516826, -7100846, 4830166, -2839560, 0, 0, 0, 0, 0, 0], [-83373605067, -165851254, 179861257, 13164869, 62746333, 3482421, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -695245530, -2675149308, -3047100, 946158, -40916274, -5935608], [6184157334, 93028664, -106030717, 5780800, 37411143, 14747169, 0, 0, 0, 0, 0, 0], [-72991410950, -30097841, -10644576, -2626508, -64009291, 10711180, 0, 0, 0, 0, 0, 0], [-14838842513, 159721354, 72460221, -17649652, 17786664, 25871934, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1648510480, 5650650783, -9490057, 4227218, 6531009, -4859370], [0, 0, 0, 0, 0, 0, 819583877, 4353034547, 18169723, -8609557, -604528, 3899412], [0, 0, 0, 0, 0, 0, 1131566930, -7092154, -2227196, -6980476, 29292212, 10011300], [0, 0, 0, 0, 0, 0, -189826832, 2470947411, -5824682, -1671167, -33026103, 11439900], [0, 0, 0, 0, 0, 0, -253900374, -3109316706, 1810362, 3225258, 46120710, 10604100], [7299533558, 241883580, -82586967, 10059966, 103690515, -44012997, 0, 0, 0, 0, 0, 0], [160570869524, -246927684, -187568686, 5499928, 62903032, -3082750, 0, 0, 0, 0, 0, 0], [105503324732, -444500940, -154410966, -24058992, 41453256, 11196042, 0, 0, 0, 0, 0, 0], [26099645762, 270886179, -219873094, -6699394, 18746993, -3323318, 0, 0, 0, 0, 0, 0], [-11776929880, -291588453, 274926840, -2675766, -18496839, -4111224, 0, 0, 0, 0, 0, 0], [50604666668, -72526950, 202264938, 18194526, 99504828, 5581278, 0, 0, 0, 0, 0, 0], [61214268782, -192462648, 155115737, 4847638, 102489751, 37124727, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2312021837, 12942522042, -10657079, 5732638, 19146495, -12318840], [0, 0, 0, 0, 0, 0, -646956054, 18798066442, 21472582, -3161958, -46424120, -6888240], [26952376685, 582133266, 242970287, -36360080, -23015372, 14382348, 0, 0, 0, 0, 0, 0], [-201378409507, -33919242, -60360466, -2696173, -91242256, -5792537, 0, 0, 0, 0, 0, 0], [-27639552941, 141569686, 213102948, 47379219, -59648204, -29001375, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 460921905, -6560160237, -7208253, 21214335, -9419412, 6334980], [0, 0, 0, 0, 0, 0, -1022629914, 19577357771, -10230193, 7856940, 22109975, -38017410], [0, 0, 0, 0, 0, 0, -3026125192, -4399120995, -5747950, 9930983, 55005423, 14279760], [21435701351, -377829756, 438238814, -38406229, 23418236, 46644571, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2001745022, -24080382987, 24899287, -44809694, 60629169, 10414482], [-318294755285, -138543470, -132455667, -58450276, 147797868, -9965094, 0, 0, 0, 0, 0, 0], [192448919294, -15377991, -131148088, 27989374, -107821691, -9292788, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -2460546529, 14232815553, -16194220, -10841092, 53209728, -19331460], [0, 0, 0, 0, 0, 0, -186734295, -26514277583, -6184013, 38869077, 8425582, -3596868], [0, 0, 0, 0, 0, 0, 229027686, 16092699504, 9649692, -22757310, 79437486, 39838992], [160756265756, 194748474, -164530854, -26686434, -9922500, -60596466, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 2864557988, 19410764556, -4545184, 20376032, -136526196, -10039560], [-143850860346, 275205290, 250639969, 26308700, -152256761, -69057273, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -1926092415, 10253645640, 25986201, -35033358, -80056725, 35662500], [0, 0, 0, 0, 0, 0, 3492714175, 1080715961, 38410011, -15761165, 94926800, -25159560], [354490328832, -276848584, 487935679, -8327021, 170488686, -90956970, 0, 0, 0, 0, 0, 0], [-39059199566, -97085408, 732342189, 4044354, -114498197, -40048473, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -3347465688, -22197948828, 33549360, 34572468, -55238160, -25073580], [0, 0, 0, 0, 0, 0, 4842020625, 15566932805, -21960694, 49145352, 62043170, -20064540], [0, 0, 0, 0, 0, 0, 4316192956, -7637231628, -35900090, 32353846, 16998168, 10799472], [374396287559, -414267273, -629918605, -47287397, -20514842, 47520813, 0, 0, 0, 0, 0, 0], [-52053697219, 883453566, -189989887, -89520500, 60798862, -27274849, 0, 0, 0, 0, 0, 0], [-233482598947, 283460088, -558166782, -8138571, -75210168, 36625659, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, -214501717, 30211476861, -41565193, 64641647, 93698904, 52124064], [-479541078100, 74064870, -369817366, 34191208, 281829646, -31051348, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 6593177863, -2303038260, -33346571, 58658668, -39452799, -10190850], [-8948985718, 1814594424, 191737916, -5895026, -203155658, 76513110, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 122532256, 24475079958, -9870668, -24136286, -103079280, 54026484], [0, 0, 0, 0, 0, 0, -3744851981, -7446175914, -28206857, -75896708, -44105301, 6382170], [0, 0, 0, 0, 0, 0, 6078377858, 24637534200, -20874106, -26298976, -104853462, -47879640], [0, 0, 0, 0, 0, 0, -4538113761, -19207995788, -66136991, 60317340, -116295599, -23200512], [-622622174035, -173222358, 226663493, -59554658, 51349900, 138341082, 0, 0, 0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_38_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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