
// Make newform 38.5.d.a in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_38_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_38_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_38_5_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_38_5_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 := [23840536514409, -26834137576128, 32749209391860, -12141615583188, 6856327325898, -961846520868, 352870494000, -28081380444, 7565874847, -367923764, 77836288, -2337188, 404698, -7028, 1024, -8, 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, 0, 0], [4936421210961035464615317005065064115, -2035164351410158705525850713113042333, 2151960244126931007288971252385198642, -236162893736618777973663437518161963, 124535911670026178201426201806653003, -7820241141290547791540282450696826, 2731973206040444172522474313208367, -108178890299097578339598981590911, 28099991932973319797867258073373, -707468512288461449111129112942, 145454414660531514940941492395, -2166886231056927501390071603, 366562502493643356519312600, -2499137223456356748138769, 357019603350908106876967, 0], [-756917815206784790872572091930476567, 1061869985464232518387569383309351244, -1202549000450983678773376078212012681, 286038003187178128066548491997211368, -154779177471667179820242430736641176, 14281249147372562590463481634891458, -5043221924582717574186210404121831, 244558646233218309021618851323328, -63839063412907858713712049058992, 1810548264857104182334410434130, -373071580429948555418731061923, 5998195527429342777912565480, -1015501228098561436163031345, 7293218550925064543509430, -1041888364417866363358490, 0], [9179266112603347331888521177497904482624054, -5976156544140228274812920235785233092023274, 5081436177501356070654962248980099750206010, -1383749933624030955189903569268000873125355, 628547553845341535142492501172216030966269, -60564888625947320697773616488879628426345, 20012011185485581359447738186143668560591, -857213733184725080013421390511147959760, 247098396589253419110410502772404497715, -4625008995661256036409822405133528789, 1408795003104440948675952459682713145, -5768068703866168889864440482903204, 3743152769332712386586632217261699, 24627221372306875534002967313557, 3749780874768357001770044646891, 57634757851334750793507357539], [1247009452444923177980948420961, -3973973317925255425531675345005, 1293142901226763651089675719373, -930860479536463580670774478107, 104537445042719007494392512924, -44607825550312627268934621912, 2824634573178666372942040002, -852625159035523569374752289, 34499646194663013839191836, -8011548492751123260081748, 208300145301281929602388, -39078023355795006991701, 604672283552396906795, -94593775335736385855, 671687217355358325, -89558295647381110], [1071136015132784483009101218190135588766151, 2594034470770825287239389820950797772455291, -1214616712012484992325088684445431964769337, 833954441778953933665778381848464757647954, -108099826814932837828671012699213119784555, 39780983560158186362867936662595353199523, -2937642678462144615012626336880129737175, 755021353706119997471673813765491230895, -35486623264255223970824747751778713023, 7038834965607704869893032865617615397, -210941198478030653803572515428037947, 34066107890010468988833498796477927, -602536946985539168003443852812342, 81849315173394355467757368868826, -659260197498927977293586972048, 76947807775639914459790286205], [-1943852069712777767973662857191, -1762019439276733470220187759724, 1278409137609756088590617435616, -1136620982727226713862905418800, 421356934871191569491988004251, -63003935509730366374163131356, 15829980096601871549908321914, -1162339160223851720147779451, 209537948851476261642003955, -9560569455404862365575544, 1248963345253702665964456, -38063594769565574875409, 3438632507443563443716, -69850357078338851570, 3557767810173487540, -44779147823690555], [13036131316404757271795438083023, -18499195969218272608452529182648, 8776360253884581356059026952956, -6469222386322007236855236837492, 943503135521563095859564968114, -409646428338517485078786437748, 32679180503015279808207650256, -9959611324735244242914950468, 471748345893055123590281193, -110094471049799535917720548, 3178646619579926271310072, -597732711038634090679884, 9933710229127382704838, -1555362509924491208012, 11614027607591877840, -1548537014345583712], [-1382723867610856470567337599277772213915565, -4364661522827949838764226342912297202214654, 1426125149317417524087181494080568165970086, -1197703380287611955478195153858720820548294, 402041473519715687124714093114314477502909, -68728076611101472587086483398205087861901, 15400077648422363621382956485161578568693, -1486535349750326596593750471999676197299, 209938109910180656997273107468544646111, -14622627062911174607478951804445610825, 1291265732076404720170477485483448279, -71054408619777492432604679879771957, 3671017668332882813672278617436726, -166085063750910657597271309206251, 3923375547000902375899342893919, -148539588184500754431540318875], [-1247009452444923177980948420961, 2918229613317180443925693480843, -1293142901226763651089675719373, 930860479536463580670774478107, -104537445042719007494392512924, 44607825550312627268934621912, -2824634573178666372942040002, 852625159035523569374752289, -34499646194663013839191836, 8011548492751123260081748, -208300145301281929602388, 39078023355795006991701, -604672283552396906795, 94593775335736385855, -671687217355358325, 89558295647381110], [19683215107342353060071562868121869626483759855, 3474202434441238351966942576817204003460768978, 6307045809103611431406197816113226615517594468, 1560533443758878157715794966731487841623298656, 243492134067093564899442019349144641542630231, 67785446061205040258249711126771654265747756, 4287225132738598181231145275461543698098853, 1082414259444926622030095704685719120610348, 40757122503753330307379424860333273432407, 8455342579802893972195184715380344921476, 208115875634663504587262454214918013273, 35125354071851406720128863940373415348, 529662310115604619575715183773359292, 74927841069676565482847121462338306, 523908956807524984696319464711933, 64786656635785836162700145330172], [31341693470478055240659366577120166839468031352, -22116495031051256794483958793471277234454062362, 13215949411562698022511432103108123394879326545, -3339008997775310420393009031269446577343551964, 688586224254931582857616410691582242111508665, -119656458613587699737567489067151191926469990, 13776125284831731702341354834820259336525338, -1749979127950290370808947489758007078003576, 132376708723091358178235313572666873696377, -12639868047639598921431146152321504632102, 651600832634227978504449040746899202338, -47604810043259221023491067603246943112, 1580877887860167299914121400197771433, -89065165411739428065679109227973428, 1495708806344312527136821644664513, -64786656635785836162700145330172], [-40739036446204062426135671173372257820643025, -359990376865837615236899552895287865074043774, -33551928848584959999261392971011323151565794, -293573433542072418079192857987684137074570416, -22120807504119224202375882729766075906906743, -18618175646349528961558698643188615156954180, -710061000769710808416007416493926574821027, -474490786494840601811135060273587031332984, -6293736707458887998625107022887047392619, -5533558249185805215628790305025002706428, -14939916016978761610508538196420686583, -31529449612726991904200819852686556344, 28063682879345702749461156351461906, -85610519993775376152116046453775414, 106288241421730537233985616777555, -88550687278053028691758474283728], [-1165502086140128955496253337354614589132288549, 4105729230364112786721079848413369646982806528, -3082338208492740819353442524968758975312623922, 1214063954861341367053656180170357939770993596, -149697078724116717142893510293148773472581439, 65258545537871527565873602172906660825403846, -2970244140368786658869623912842994140379395, 1457298676718144448746279552101315781318122, -34461295736237815489679228400907159023559, 15585939304242256822073251251037491905958, -225984428998814786919859374591752429423, 83883804449787615299236214100942350018, -736843673543116771778423271320945214, 218841358978614269217083801821009558, -914272678986509383884301151879053, 219686329657532441651207100009774], [985982393966935101638226207675487307273646846, -1302991956609076608567979934236574302726326102, 299896839452937139527316784380208378483171967, -1258827675508112998998350624008788858705514434, 182578994239658886776085536834953173345072321, -78055851837376852239110734343499836937312036, 7566139847352844396363588236414733306964268, -1743055877249793527165632134802882879497152, 109399265762488770517994624623426138078745, -17933339378659256265115538999912697804372, 710438897259183029459459401400538189508, -92078382952433569403947683459359119192, 2124852459385273635061493978035632387, -229108606086844044216080331195729086, 2381022265876477240883805348267557, -219686329657532441651207100009774], [-880046944329653512973706097511249351383244142, -2704604391186130863490298411786545721808885087, -17805912701038484167185005053013679440955378, -663017632782712787106116495608875658349204547, 56823552339186828259399562201859857041158567, -45302096578862695486946936573659844190536328, 2928625349250759215385077265183974114107980, -1177844656042450352606447131726606770862283, 49073251217324823255914556535586803386125, -13542528113181127392874375594667910497352, 355911152104131415009147953575894464570, -75307204548142184110426752828619557211, 1160579120575592066183299771839306963, -199059915766925840403951578498414081, 1394331075967146928818865078987904, -200387189272590843033309889961784]];
    Rf_basisdens := [1, 32189377566806651054014877154337722, 64378755133613302108029754308675444, 1814173953519172002518583821467908157472622, 1055743704608074981605981864162, 907086976759586001259291910733954078736311, 527871852304037490802990932081, 10437145050692306707364199310803, 907086976759586001259291910733954078736311, 527871852304037490802990932081, 68938610233728536095706185215780509983959636, 68938610233728536095706185215780509983959636, 68938610233728536095706185215780509983959636, 68938610233728536095706185215780509983959636, 68938610233728536095706185215780509983959636, 34469305116864268047853092607890254991979818];
    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_d();"
function MakeCharacter_38_d()
    N := 38;
    order := 6;
    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_d_Hecke();"
function MakeCharacter_38_d_Hecke(Kf)
    N := 38;
    order := 6;
    char_gens := [21];
    char_values := [[0, 0, 0, 0, 0, 0, 0, 1, 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 := 5;
    raw_aps := [[0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-2, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, -1, 0, 0, 0], [6, 1, 0, -2, 1, -2, 0, -1, 0, 1, 0, 0, 0, 0, 0, 0], [-9, 1, -3, 4, -2, 17, 1, 2, 0, -8, 0, 0, 0, 0, 0, 0], [36, 0, 2, 3, -3, -13, -2, -18, -2, 0, 1, 0, -1, 1, 0, 0], [70, 0, -6, 2, -5, 8, 0, -73, -1, 8, -2, 1, 6, 0, 0, 1], [-14, -1, 7, 0, -9, 16, -1, -20, 2, -54, -1, 0, -5, 1, -4, 0], [1, 1, 0, -21, -19, 1, -8, -15, 8, 0, 1, -2, 5, -3, 6, 1], [-464, 0, -2, 54, -54, 0, 0, 232, 0, 0, 0, 0, 1, 0, 0, 0], [178, 1, -12, -2, 17, -4, 6, -339, -12, 105, 0, 0, 24, 12, -12, 2], [-246, 0, 22, 0, -9, -2, 2, 483, -4, 141, 1, -1, -44, 7, -7, 0], [-73, 2, -5, 5, 1, -121, 62, -69, -31, 153, 0, 0, -5, 0, 3, 1], [-950, 0, 21, 17, -34, -25, 0, 933, -42, 17, -2, 1, -21, -10, 5, 0], [-21, -21, 0, 73, 31, -283, -12, 459, 12, 524, -1, 2, 37, -3, 6, -21], [272, -20, 42, 49, -49, 193, 28, -146, 28, 0, -9, 0, -21, -15, 0, 20], [-730, -2, -30, -86, -1, -281, -62, -815, 31, 249, 0, -9, -30, 0, -3, -1], [20, 20, 0, 84, 124, 430, -18, -766, 18, -820, -8, 16, 45, 0, 0, 20], [-2417, -1, -4, -94, 94, 714, -17, 1208, -17, 0, 1, 0, 2, 7, 0, 1], [1566, 0, -27, -153, 0, 639, -72, 1413, 36, -675, 0, 9, -27, 0, -3, 0], [-869, 0, -27, -79, 179, -241, 0, 969, -63, -157, -16, 8, 27, 66, -33, -21], [-1266, 40, 49, -5, 20, -1455, 116, -1291, -58, 1533, 0, 1, 49, 0, -41, 20], [-515, -70, -35, 520, -260, -124, 38, 260, 0, 81, 1, 1, 0, -33, -33, 0], [1463, 19, -12, 226, -226, -719, -5, -722, -5, 0, 21, 0, 6, 66, 0, -19], [-263, -40, 4, -358, -20, -1492, 116, -601, -58, 1530, 0, 28, 4, 0, -104, -20], [70, 70, 0, -390, -250, 40, -110, -558, 110, 60, -20, 40, -49, 18, -36, 70], [310, 70, 2, -140, 482, 130, 10, -138, -20, 78, 26, -26, -4, -70, 70, 140], [688, -70, 24, 140, -218, -124, -16, -1594, 32, -2484, -18, 18, -48, 6, -6, -140], [1872, 0, 135, -297, 0, 1785, 108, 1575, -54, -1731, 0, -27, 135, 0, 21, 0], [2871, 20, 83, -40, 31, -58, 98, -5711, -196, 1113, 21, -21, -166, -63, 63, 40], [-3450, -90, -102, 1143, -1143, 1959, 204, 1680, 204, 0, -9, 0, 51, -123, 0, 90], [-509, 0, 238, 13, -152, 650, 0, 370, -72, 596, -16, 8, -238, 132, -66, 126], [36, 36, 0, -464, -392, 2474, 162, -4905, -162, -4876, 8, -16, -170, -96, 192, 36], [-55, -55, 0, 118, 8, 626, -249, -8708, 249, -1362, 1, -2, -78, -55, 110, -55], [-2690, 0, 339, -300, 566, 202, 0, 2956, 596, -428, 0, 0, -339, -132, 66, 34], [2008, -71, 130, 142, 293, -300, 158, -3723, -316, 4077, -8, 8, -260, 196, -196, -142], [3262, 0, 99, 575, -1040, -3425, 0, -3727, 288, -3603, 2, -1, -99, -186, 93, -110], [2169, 1, -573, 24, -12, 351, 255, 12, 0, -48, -12, -12, 0, 22, 22, 0], [7246, 126, -326, 441, -441, 1533, -294, -3560, -294, 0, -63, 0, 163, 357, 0, -126], [8212, -72, 67, 1035, -36, -3627, -120, 9283, 60, 3531, 0, -81, 67, 0, 273, -36], [-2685, 126, 573, -252, -258, 282, -30, 5112, 60, 1089, -111, 111, -1146, -351, 351, 252], [-3266, -126, 214, 0, 0, 8752, -34, 1570, -34, 0, -40, 0, -107, -58, 0, 126], [908, -72, 542, -1060, 530, 6826, 90, -530, 0, -3368, 70, 70, 0, 210, 210, 0], [-772, -290, -518, -1064, -145, -5628, 614, -1691, -307, 5790, 0, 49, -518, 0, -74, -145], [6508, 398, -302, -1754, 877, -8998, 200, -877, 0, 4599, -29, -29, 0, 63, 63, 0], [-252, -252, 0, 239, -265, -2035, -270, -3760, 270, 3566, 89, -178, -855, -69, 138, -252], [11657, 110, 367, 302, 55, -7552, -238, 11904, 119, 7488, 0, 178, 367, 0, -62, 55], [-8827, -182, -273, -1775, -91, -301, -876, -10511, 438, -228, 0, -75, -273, 0, -21, -91], [20663, -56, 441, 112, 818, -62, -50, -40508, 100, 4383, 57, -57, -882, -111, 111, -112], [11100, 16, -618, 388, -194, 5356, 660, 194, 0, -2348, -134, -134, 0, 160, 160, 0], [-2813, 0, 69, 87, 23, -4799, 0, 2923, -487, -4115, -72, 36, -69, 150, -75, -197], [-2950, 522, 680, 2864, -1432, 532, -252, 1432, 0, -392, 70, 70, 0, -186, -186, 0], [-8417, 433, -70, -1469, 1469, 8740, -287, 4425, -287, 0, -26, 0, 35, -419, 0, -433], [236, 236, 0, -1443, -971, 1010, 128, 10691, -128, -1548, 134, -268, 30, 234, -468, 236], [-23647, -433, 154, 1631, -1631, -1852, -301, 11607, -301, 0, 198, 0, -77, -153, 0, 433], [-9557, 0, -1287, 1819, -2955, 2175, 0, 8421, -694, 3552, 74, -37, 1287, 606, -303, -683], [9054, 68, 71, 869, 34, -1507, 1436, 9889, -718, 2259, 0, -57, 71, 0, 9, 34], [19213, 0, -189, -2577, 4737, 3327, 0, -17053, -648, 3558, -150, 75, 189, -474, 237, 417], [6594, -668, 516, 3202, -1601, -7232, 1038, 1601, 0, 4135, 7, 7, 0, 19, 19, 0], [3591, 577, -278, 487, -487, 4390, -449, -1507, -449, 0, -42, 0, 139, 717, 0, -577], [-20711, 0, -1686, 2623, -4742, -4160, 0, 18592, -372, -3284, 128, -64, 1686, 928, -464, -504], [-7828, 506, -452, -1012, -3737, 2288, -1276, 11919, 2552, -399, -153, 153, 904, -813, 813, 1012], [-1020, -650, 708, -2366, -325, 10901, 606, -3061, -303, -10923, 0, 261, 708, 0, 327, -325], [-48292, -327, 386, 2190, -1095, 20502, 1644, 1095, 0, -9429, -78, -78, 0, -318, -318, 0], [887, 887, 0, -677, 1097, 15638, -2151, 12805, 2151, -29502, 92, -184, 81, -315, 630, 887], [41994, -630, 66, -2925, 2925, -15873, 156, -21312, 156, 0, -63, 0, -33, 939, 0, 630], [-25869, -126, -115, 252, 4032, -514, 262, 55770, -524, 5463, -139, 139, 230, 959, -959, -252], [15397, 796, -1474, 3328, 398, 5632, 2512, 18327, -1256, -3978, 0, 380, -1474, 0, -280, 398], [-41456, 0, 148, -3366, 7653, 7191, 0, 45743, -231, 8343, 558, -279, -148, 654, -327, -921], [6584, 192, -654, -4948, 2474, 20252, 876, -2474, 0, -9688, 78, 78, 0, 124, 124, 0], [86137, 626, 1747, 982, -491, 7280, 770, 491, 0, -3255, -35, -35, 0, -495, -495, 0], [22795, 0, -1265, 555, -1485, 2961, 0, -23725, 588, 1998, 462, -231, 1265, -1566, 783, 375], [-357, -357, 0, 1905, 1191, -10887, -1410, 24313, 1410, 21060, 155, -310, -573, 1043, -2086, -357], [21790, -166, 562, 332, 2824, -766, 434, -40756, -868, 12408, -32, 32, -1124, 1156, -1156, -332], [3026, 73, 1390, -146, 7742, -201, 347, 1690, -694, -8223, -227, 227, -2780, 295, -295, 146], [-25631, 30, 757, -5949, 15, 30723, -996, -31595, 498, -31206, 0, -129, 757, 0, 1095, 15], [-226, -226, 0, 5847, 5395, 6269, -2710, 64994, 2710, -12990, 41, -82, 3225, -231, 462, -226], [52072, 0, 99, -4650, 9336, -14304, 0, -47386, -2052, -12216, -780, 390, -99, 168, -84, -36], [-24195, -1292, 694, 4516, -646, 15046, -152, -19033, 76, -15768, 0, 258, 694, 0, 1818, -646], [-90797, 93, 2530, -1959, 1959, -30536, -559, 45445, -559, 0, -34, 0, -1265, 449, 0, -93], [970, -106, -1844, -5444, 2722, -15538, -2482, -2722, 0, 6528, -488, -488, 0, 168, 168, 0], [15440, 788, -67, -4078, 394, 42036, -2216, 10968, 1108, -42750, 0, -304, -67, 0, -1084, 394], [93792, 252, -4758, 4911, -4911, 26775, 2100, -46770, 2100, 0, -39, 0, 2379, -1587, 0, -252], [-75553, 291, -6060, 4122, -4122, -30957, -1575, 37922, -1575, 0, -171, 0, 3030, -174, 0, -291], [-27719, 326, 3045, -6925, 163, 24037, 300, -34807, -150, -23724, 0, -531, 3045, 0, -1167, 163], [1788, 1788, 0, -4407, -831, 7284, -84, -93737, 84, -10992, -114, 228, -1586, -24, 48, 1788], [-29910, -1265, 1978, 2530, 599, -4733, 2203, 60419, -4406, 18114, 621, -621, -3956, 42, -42, -2530], [88526, 933, -2862, -2862, 1431, -4629, 927, -1431, 0, 2778, 237, 237, 0, 300, 300, 0], [-118196, 0, -1743, 5585, -9968, 15779, 0, 113813, -1048, 18029, -122, 61, 1743, 174, -87, -1202], [48350, 1044, 2556, 6028, -3014, -18242, 1602, 3014, 0, 9922, 316, 316, 0, 300, 300, 0], [36411, 805, -2115, 3132, -1566, 9921, 4261, 1566, 0, -2830, -92, -92, 0, -486, -486, 0], [1474, 1474, 0, -5229, -2281, -14375, 340, 199326, -340, 31698, -113, 226, -2383, 1113, -2226, 1474], [10864, 1151, 5554, -2302, -6137, 806, 1496, -27865, -2992, 8385, -824, 824, -11108, -1220, 1220, 2302], [159856, 0, 3179, -9493, 18930, -3471, 0, -150419, -2486, -1041, 598, -299, -3179, 2706, -1353, 56], [83371, 0, -2076, 4027, -6870, 25854, 0, -86214, -3462, 30500, -180, 90, 2076, 2732, -1366, -1184], [-1415, -1415, 0, -3399, -6229, 7069, -3602, 81525, 3602, -16968, 379, -758, -3127, 663, -1326, -1415], [-84238, -466, 3502, -12673, 12673, -35221, -1120, 41886, -1120, 0, -15, 0, -1751, 351, 0, 466], [12271, -772, 2235, 1544, -9863, 710, -2254, -34405, 4508, 6663, -345, 345, -4470, -57, 57, -1544], [84222, -1834, -934, 11639, -11639, 32103, 2020, -43028, 2020, 0, -287, 0, 467, -2213, 0, 1834], [-3450, -3450, 0, 6507, -393, 40485, 246, -103640, -246, -87870, 395, -790, -2841, 1085, -2170, -3450], [113688, -228, -2686, 1695, -1695, -9607, -998, -56958, -998, 0, -839, 0, 1343, 2275, 0, 228], [-144, -144, 0, -7633, -7921, -9509, 1062, 4532, -1062, 18730, 493, -986, 517, 1167, -2334, -144], [-136547, 878, -3693, -1756, -734, 392, 1364, 272360, -2728, -9633, 297, -297, 7386, 273, -273, 1756], [65649, 2107, 1789, -4214, 6830, 4375, -161, -124468, 322, -19245, -270, 270, -3578, -2691, 2691, 4214], [-86449, -72, -6249, 2496, -1248, 8778, 11004, 1248, 0, 1113, 473, 473, 0, -1009, -1009, 0], [106035, -3440, 9057, -4118, 2059, -41750, 3900, -2059, 0, 22825, -545, -545, 0, -215, -215, 0], [-7880, 0, -495, 4975, -7380, 11721, 0, 5475, -2848, 17139, -238, 119, 495, 6234, -3117, -2570], [-503, -503, 0, 11475, 10469, 4042, 1477, 152805, -1477, -9090, -362, 724, -4033, -771, 1542, -503], [-2077, 741, 5966, -20175, 20175, -18105, -3528, 1409, -3528, 0, -243, 0, -2983, 3765, 0, -741], [-4048, -2841, -3264, 5682, -2475, -8457, 2775, 5621, -5550, -34176, -1203, 1203, 6528, -1080, 1080, -5682], [-60358, -1337, 3424, 2674, -1651, -2442, -232, 119065, 464, 36009, 982, -982, -6848, 556, -556, -2674], [92860, 0, -51, 5803, -9012, -1545, 0, -96069, -3984, 5033, -78, 39, 51, -1738, 869, -2594], [2280, 2280, 0, 3536, 8096, -44594, -2400, 110591, 2400, 93748, -980, 1960, -806, -1146, 2292, 2280], [-14394, -2558, 8724, 1284, -642, -41544, -492, 642, 0, 20526, 444, 444, 0, -1064, -1064, 0], [-1891, -1891, 0, 16257, 12475, 67, -4770, 74837, 4770, -3916, 391, -782, 1233, -507, 1014, -1891], [-80003, 2302, -2005, 901, 1151, -67475, -3638, -80253, 1819, 66807, 0, -354, -2005, 0, 2709, 1151], [70657, 0, 516, -667, -3148, 7406, 0, -74472, 5178, -2254, 436, -218, -516, -6148, 3074, 4482], [-231966, -3068, 4812, 24484, -12242, 58628, 4780, 12242, 0, -26924, -144, -144, 0, -4032, -4032, 0], [-160966, 4032, -880, -8080, 4040, -4196, -2628, -4040, 0, 784, 502, 502, 0, 3276, 3276, 0], [74000, -112, 8518, -12391, 12391, 57041, 2996, -37056, 2996, 0, 597, 0, -4259, -3219, 0, 112], [-42640, -704, -2410, -1094, 1094, 69238, -530, 20968, -530, 0, 604, 0, 1205, -2636, 0, 704], [20053, -197, 6053, 394, -20146, 2905, -3299, -60252, 6598, 58785, 218, -218, -12106, 1589, -1589, -394], [-5216, 3478, 2480, -6956, 3554, 5992, 964, 13986, -1928, -1740, -102, 102, -4960, -3138, 3138, 6956], [97376, -2284, -380, 4568, -7064, -11944, 7376, -201816, -14752, 19734, -246, 246, 760, 3906, -3906, -4568], [-22258, -312, -6516, -13248, 6624, -175092, 180, -6624, 0, 87636, -192, -192, 0, 960, 960, 0], [83908, 0, -3685, 1352, -240, 8280, 0, -82796, 8566, 2178, -860, 430, 3685, -1704, 852, -2464], [1692, 1692, 0, -15768, -12384, 25344, -4620, -5558, 4620, -47304, -566, 1132, 9321, 1936, -3872, 1692], [337468, 0, 3999, 871, 930, -10629, 0, -335667, 6326, -14283, 1526, -763, -3999, -318, 159, -2672], [262162, 0, 9423, -4041, 5040, 10977, 0, -261163, 7974, -39, 1122, -561, -9423, -1530, 765, 3042], [-194590, -3504, -828, 24246, -12123, 88662, 3456, 12123, 0, -42603, -225, -225, 0, -1437, -1437, 0], [-409886, 0, 1062, 7334, -13931, -9461, 0, 403289, -1071, -7653, 686, -343, -1062, -2154, 1077, -737], [-218509, 290, 5125, 4409, 145, -119593, -9928, -214245, 4964, 114774, 0, 309, 5125, 0, -3273, 145], [-62256, 3276, -6110, 19017, -19017, 143035, -5362, 32766, -5362, 0, -1045, 0, 3055, 3359, 0, -3276], [-192218, 0, -11739, -2851, 5926, -45863, 0, 195293, 4560, -50199, 30, -15, 11739, 7138, -3569, -224], [-85365, 4258, 12753, -23662, 11831, 21502, -3968, -11831, 0, -12735, 185, 185, 0, 1839, 1839, 0], [4181, 4181, 0, 1790, 10152, -28611, -177, -28296, 177, 65584, 1037, -2074, -8124, 3278, -6556, 4181], [582504, 916, 6874, 17662, -17662, 3028, 2902, -290794, 2902, 0, 90, 0, -3437, -486, 0, -916], [-118269, -808, -919, 1616, -3620, -9684, 8068, 232918, -16136, 138159, 641, -641, 1838, -3253, 3253, -1616], [-53532, -960, -3648, 1920, 37815, 2340, -4260, 144879, 8520, 58185, 1503, -1503, 7296, 897, -897, -1920], [-114738, 2953, -78, 47954, -23977, -88373, 10279, 23977, 0, 49326, -169, -169, 0, 1068, 1068, 0], [-130062, -2338, 28566, -19933, 19933, -46373, -3096, 63862, -3096, 0, -33, 0, -14283, 2031, 0, 2338], [-4782, -4782, 0, 4613, -4951, -3257, -4098, 138752, 4098, -3050, -1325, 2650, 2671, 807, -1614, -4782], [-3454, -3454, 0, 15757, 8849, -2257, 8370, 370348, -8370, -2394, 377, -754, 5643, 117, -234, -3454], [84392, 718, -19848, 12247, -12247, 64606, -512, -41837, -512, 0, 192, 0, 9924, -546, 0, -718], [94010, 3668, -4202, -7336, -1994, 10532, -3196, -190014, 6392, -39372, 280, -280, 8404, -1064, 1064, 7336], [80921, 3962, 19, -1735, 1981, -81379, -9280, 77205, 4640, 78720, 0, 141, 19, 0, 2061, 1981], [-220388, 0, 789, -3189, 9744, -82011, 0, 226943, -9444, -69201, 3562, -1781, -789, 4570, -2285, -3366], [34015, -7456, -1362, -13858, -3728, -139198, 23528, 23885, -11764, 147234, 0, -438, -1362, 0, -4206, -3728], [2642, 2642, 0, -16779, -11495, 21388, -1278, 408305, 1278, -37492, -1010, 2020, 7506, -126, 252, 2642], [174564, 1257, 858, -2514, -15255, 5226, -2712, -364383, 5424, -135225, 282, -282, -1716, 4500, -4500, 2514], [-256512, -964, -4591, -36256, -482, -33210, 3040, -292286, -1520, 34248, 0, -220, -4591, 0, -598, -482], [-209908, 5853, -7516, 34702, -17351, 150773, 2505, 17351, 0, -74134, -319, -319, 0, -906, -906, 0], [-10990, -10990, 0, 12545, -9435, -32652, -4632, -106131, 4632, 43324, 236, -472, 15510, -160, 320, -10990], [28518, 1374, -3966, -15849, 15849, 43323, -78, -13572, -78, 0, -3183, 0, 1983, -7677, 0, -1374], [248138, -6718, -3100, 9074, -3359, 246105, -6770, 260571, 3385, -252849, 0, 719, -3100, 0, 2795, -3359], [17486, 4433, -13628, -8866, 31891, 21686, -12820, -3081, 25640, -182451, -1134, 1134, 27256, 2514, -2514, 8866], [73944, 148, 11646, 21636, -10818, -224862, -4050, 10818, 0, 110406, 242, 242, 0, 2136, 2136, 0], [-34109, 0, -2230, 17168, -29292, 20010, 0, 21985, -10076, 35130, -2780, 1390, 2230, 8100, -4050, -5044], [-1623, -1623, 0, 249, -2997, -111318, 201, 457, -201, 219390, -1882, 3764, 7851, 1265, -2530, -1623], [377918, 702, 12794, -58401, 58401, -34077, -11754, -188608, -11754, 0, 1269, 0, -6397, 5745, 0, -702], [133228, 0, 5345, 15035, -22284, -45783, 0, -140477, -14642, -23355, 3034, -1517, -5345, 4794, -2397, -7786], [173527, -3562, -11223, -41203, -1781, -13393, 3278, 134105, -1639, 13251, 0, -2202, -11223, 0, 1443, -1781], [-157724, 0, -2985, -24067, 42706, -21623, 0, 176363, 13800, -40851, -650, 325, 2985, -4690, 2345, 5428], [-264466, 5430, -6058, 22794, 2715, -27669, 7458, -244387, -3729, 34113, 0, 633, -6058, 0, -2679, 2715], [196261, -4738, -9795, 9476, 1693, -4708, -4768, -390829, 9536, -168489, 1299, -1299, 19590, -1581, 1581, -9476], [-212792, 8540, 8553, -6517, 4270, -148999, -14956, -223579, 7478, 145791, 0, -1713, 8553, 0, 4263, 4270], [233196, 6164, -9119, -36427, 3082, -85201, 2252, 193687, -1126, 89409, 0, 2287, -9119, 0, 6697, 3082], [7490, 7490, 0, -31208, -16228, 161276, 5364, -106862, -5364, -307572, 1898, -3796, -4509, 528, -1056, 7490]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_38_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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