
// Make newform 162.8.a.i in Magma, downloaded from the LMFDB on 13 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_162_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_162_8_a_i();".
// 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_162_8_a_i();".
// 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 := [107446, -525, -728, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-3224, 923, 11, -2], [-23051, 179, 59, 4], [-9828, -135, 27, 0]];
    Rf_basisdens := [1, 15, 15, 5];
    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_162_a();"
function MakeCharacter_162_a()
    N := 162;
    order := 1;
    char_gens := [83];
    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;

function MakeCharacter_162_a_Hecke(Kf)
    return MakeCharacter_162_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 8;
    raw_aps := [[8, 0, 0, 0], [0, 0, 0, 0], [14, 1, 0, 0], [12, 2, 0, 1], [546, 6, 1, -3], [1600, 1, 0, 4], [6509, 25, -8, -6], [11310, -58, -1, 16], [-492, 30, 20, 21], [70700, -149, 0, -168], [144, -118, 70, -17], [55120, -182, -56, 112], [152523, -306, 64, 324], [20974, -242, 125, 199], [214340, 826, 56, -21], [231368, 2086, 0, -216], [97082, 3766, -125, -33], [789066, 2567, 520, 180], [2490074, -642, -57, 825], [-1121104, 388, 148, 1764], [3654661, 589, 8, 258], [4329528, 4358, -22, -455], [-2882464, -4832, 110, -3819], [-3267190, -17864, -1400, -6420], [5495605, -10346, -1884, -968], [-6940186, 3001, 1120, -4428], [2031636, -39658, 2464, -4065], [-2561362, 19054, 57, 10032], [-216148, -3666, 2280, 3808], [-13760, 9077, -1940, -8562], [4213084, -71276, 626, 9088], [6484904, -27236, -1218, -21861], [-6946505, -42502, 1688, 20988], [-2903218, 12066, -4309, 20041], [-10770536, -27565, -14880, 7440], [-20246748, -80434, 8452, 7197], [-1278778, -125289, -8736, -33572], [-32849108, -115424, -13400, -17984], [-17020768, 4198, 20834, 177], [-2524248, 122235, 11256, -18588], [-40319308, 75208, -22008, 19272], [-54921394, 44916, -1768, 57724], [-45415684, 75922, -19340, -98901], [-55100003, 173086, 9452, 26232], [-53097936, 113850, -21520, 58380], [-3068572, 71040, -24218, 52804], [10072920, -317968, 21758, 40825], [-30900964, -70602, 40584, -106667], [20894638, -334354, -9731, -102999], [7612116, -221803, -73232, -29468], [-33765357, 75375, 19528, -174726], [45821724, -415038, -15240, -15687], [116649489, -429010, 26244, 151996], [-36031602, -198018, 69019, 157656], [77425205, -353084, -66184, -290688], [43948820, -173894, -69920, -24141], [72541180, 236114, 70952, -135480], [-100816360, 816048, -34188, 117576], [20624396, -275451, -73560, -65816], [247687600, 187301, 7388, -90186], [-76770304, 74136, 129246, 159481], [308990508, -753165, 16352, 139668], [332551590, -1168138, 15469, -29232], [-7664348, -114394, 130280, 326349], [179128745, 793506, 10856, -289256], [350266980, -1428357, 21488, 39360], [-269940152, 195448, -52230, 146659], [-69247145, -1662104, 3112, -47216], [-22842702, -538422, -17847, -178677], [537054730, -1576709, 18400, 472960], [-140694235, -560432, 23640, -891420], [-211807132, -12596, 175370, -516888], [-277865728, 356694, 188298, -17391], [115192100, 928161, 158272, 832264], [-974175238, -828858, 172283, -324236], [-285064104, -882726, -30170, 52341], [459788640, 2132679, -122296, 594648], [-1984296, -520462, -134312, -1103624], [799637083, -2120566, 99260, -889608], [-570105819, -106522, -191976, -42920], [-67751672, -1864816, -184574, 680295], [-1118648354, 848335, -194936, -625448], [-1229510924, -2363404, -83682, -262536], [-1011972977, 1201075, -530704, 1086214], [-813708768, 1656050, -220010, 988941], [-32970910, -2139086, 408167, -222039], [2572280513, -720659, -199360, 502746], [1343585021, 4629594, -430656, -170252], [320413416, -232041, -940640, 750984], [-177898288, 3506442, 637006, -780977], [-576483766, -1772990, 195771, 398088], [320577892, 4260854, 62932, 617727], [-497862796, 5011644, 440914, 545080], [-880351446, 1513854, -348463, -1898433], [265062962, -4952526, -373503, -2795019], [1268231144, -4209740, 166376, -3245748], [3231775558, 3252449, 24248, 46248], [-575643879, 2649009, 111068, 457014], [1477003324, -2340356, -403648, -2550996], [243575864, -2865594, 751856, -581516], [193399130, -2318574, -76143, 4458615], [261698846, -4700768, 789952, 2286324], [731922190, -4387726, -128027, 2400879], [-3706014801, -4106634, -114400, 2292072], [1296477302, -156570, -1377979, 534469], [2792314881, 5100017, 98284, 178962], [-2596192038, 3938922, -1088221, 105033], [517663626, -6840120, -1829464, -5289852], [-3682090424, 1413398, 808098, 3090537], [142653807, -8708128, -251516, 2415064], [3313735184, 8589894, 793646, 920803], [1539694396, -5266298, -2334136, 1220208], [4229911633, 23512400, 614588, 2932800], [2737356486, -8673214, 486433, -5685237], [-1037488136, 12140008, 1124848, -3488600], [2725541171, 10930150, 1329852, -3066732], [-3705088822, 9000750, 1598901, -1475631], [-6966653012, 9302852, -1253786, 6947304], [2547522824, -10280333, -1276448, 2154672], [5085721096, 11612876, -1168458, 2155041], [1481232702, -6083725, -833336, -3487320], [-4449561820, -6121653, 749692, 3152518], [-3981556166, -26426539, -1132272, -1786980], [-42691522, 2880910, -862531, -11449872], [-3633404456, 5501248, 1445966, 3590803], [-2785087398, 14085468, 4394560, -597132], [-2646359138, -15181349, -2051904, -6299252], [4832646952, 203192, 1597780, 10210128], [-6338538988, -5064474, -2276736, 158469], [-1301960764, -24986163, 1626384, -915956], [-6052553218, -35249550, -2260929, -5671436], [-9061300276, 24413146, -1676008, -1395471], [-5847121536, -2852650, -1309206, -13277069], [1337922898, -4940036, 3311072, 2128776], [2942897444, 3894193, -3612724, 7306230], [1564685012, -13316265, -2008844, -9175286], [14811416014, 2926160, -686528, -6456516], [4934379888, 8103572, 1634782, 3651261], [-6243856382, -6027211, 1587232, -3723648], [1401131069, 56247481, -3791972, -1149054], [6156785698, 25916122, 2074433, 4153216], [9881241228, 14489559, -2227864, 8686548], [221867800, -13826762, 3447834, 16456171], [5632323420, 21500136, 165128, 6186312], [-6753956818, 21832500, 237568, 15939748], [-3808936640, -33392518, -3273650, -17277801], [9106858600, 24302293, -7124680, -8932860], [10520769040, -657907, 648076, 6455214], [-9757405714, -25745082, 4032821, 4415005], [-13500189816, -44466048, -2540128, -7165080], [2505028794, 45870503, 2968944, -4788272], [25864555050, -18144336, -2158952, 4774620], [-4511723698, -14119434, -2991455, 3756424], [1133866984, -47294686, 542102, -10006563], [72327190, -800138, 6591651, -12143297], [11295233560, 51855362, -195830, -2709441], [16202459388, -20121532, -147074, 1634232], [15567355452, 49126917, 4292820, -7270518], [-4741518514, -4558104, 2625176, -17863940], [19722281058, 55828833, 1433024, -4363692], [-17664617138, 50058374, -1829237, 27440505], [15447053101, 36339929, -4516172, 3226722], [-4444872524, -42730262, -2879068, -23893653], [-6745584780, -45619668, -236136, -4903332], [-7792207277, 70310678, -5430564, 18170916], [764192728, 42904694, -932742, 6904131], [2672425064, -59316480, 257880, -18022680], [23732942958, 15911507, -10836776, -17337372], [-12978432054, 92615684, -518312, 16658388], [-14237511698, -39370243, 87536, -17250300], [18706951242, -2152878, 7657993, 28242393], [-5079365574, -75411409, 9719008, 5693352], [-8585727656, -76628854, -687046, 6828117], [-22148937177, 11824040, 2044860, -25975880], [-19358280388, 87423474, 3510256, -27841349], [-2816422064, -28070695, 7355844, -14000118], [14002285998, 132064118, -8595347, 1540495], [-17533341158, 21814172, -1639928, -3920052], [-10655983008, -28908376, 7267580, 31378672], [-15718758542, -26255093, -8022688, -18501176], [-31260084116, -73687370, 980572, 500629], [10672711702, -52088278, 8009895, 9846381], [-26298992136, 58681361, 9935344, 509052], [-28445839333, -52225637, -2079064, -17343306], [8790703716, -56977986, -11404352, 21652149], [4184318750, -17227403, -6345752, -18716928], [-11760494996, 95070610, -12744136, 10405164], [3041754408, 108302360, -8937810, 22859131], [-24005499639, 21246626, -5607736, 49931728], [-1002410800, 132530272, -3072452, -3157344], [4426811253, 34605029, -10262140, -56799326], [22437509122, 6473942, -4745579, -19218339], [28505007398, 11391654, -4252933, -39555944], [-32663854470, -20699007, -1001584, 41142840], [9707956514, -19968326, 18320371, -19812840], [13638584777, 41111476, 18235708, -45831468], [-33092847961, 47469780, -12593192, 65283220], [60708573830, -103520337, 10686280, -33202856], [-842958279, -35408736, -15163072, -38120712], [-980508260, -72600868, 13689690, 4925232], [27935262472, -168557749, -13649768, 30720312], [3243232012, -6565322, 31452, -11540507], [2622400738, 139942351, 14133288, 39153568], [-46522219917, -101212348, -11237720, 8680416], [45458419382, -86934434, -18195597, 14805264], [-8859825750, 24222300, -3661648, 40887108], [16833777320, -50943792, -7944824, -35815496], [43899382518, 230049894, 18819769, 22146435], [-40630425855, -173005212, 7298444, -32115324], [51041065598, 261033714, 5760695, 12186841], [4378005251, 59724951, -17617096, 17996614], [-8388718868, 138253943, 22321200, 114596784], [-7181809980, 12418010, -15779924, 32910177], [40780280, -99837680, 10325998, -40584795], [7276554816, -25640058, 9571926, -37109823], [82371852389, -122975850, 10414416, -15091008], [29117673504, 80138690, 17071822, 69621127], [-61615337181, 166976130, 9181620, -56005032], [-101873714068, -44983436, -116778, 11664168], [-77490869554, 220321921, -4484816, -1596144], [75916127708, -113424855, -4412072, 58708312], [-20671112400, 33193706, 12713434, -67364673], [-6865937749, -85137086, -25506852, -62878416], [58737204444, 63699644, 4226206, -37312520], [10466616838, 45464294, 19880791, 379755], [35241695288, -24682503, -22206008, 81325360], [57131165836, -233227387, -10692956, 111832386], [52422743392, 182060408, 14197052, 14296344], [37506684932, 412700502, -10922692, 34696165], [-19296271632, 240419976, 22560442, -11807547], [79502054312, 252501, -44902960, -35001032], [-42792839204, 88230352, 23330024, 71165968], [-6348054268, -228093402, -15815052, 88471759], [-21003827715, 37223208, -55070324, 84687300], [83367327376, -302129624, 18976750, -2519285], [134500898652, -172088310, -7863776, 106936563], [12046159476, 341857643, -646084, -2952458], [-12965800150, 157880068, -8980864, 48915300], [113469129146, -241426730, 22438247, -10926513], [102837270972, -17712852, -35135798, -19570656], [27017914078, 88792346, -25876869, 111768837], [-32170420268, -412357160, -46679992, 20220648], [59508387632, -172467726, 9389862, -186579897], [-103434199658, -378580340, -29743720, -90714684], [159305627089, -255869524, 22091184, -73957788], [17225725776, 321824490, -1200014, -73136553], [28765693440, -255040576, -24062260, 66055312], [73845185766, 34454586, 22382113, 149328015], [-174575962952, 22313836, 33943358, 59383213], [-45401008300, -71623868, 8508230, 156818280], [43047463488, -14365015, 14533288, 77706588], [59315433399, -220292289, -7323492, -68991114], [163246946448, 271996554, -33761446, -21653619], [-49310523644, -420995357, -24086740, -174789162], [-7996570388, -107922601, -20394560, -90128196], [148743681562, -244070194, -7763997, 86051484], [58016163868, 355050406, -37158520, -54679776], [-35366586680, -11198144, -44073262, -9099317], [25144467348, -82154442, -46319736, -58523292], [96867464655, -103670269, -1914812, 102989998], [49456287696, -5037034, 44219534, 170992033], [48949845902, -295201094, 9321257, 98450685], [-210612208394, -186896525, -43406752, 17795712], [-64740478338, -624369844, 47292744, -35131940], [-168102856752, -449151519, -1764188, -84568686], [-35942962286, 392158330, 27777551, -76624769], [-146030955560, -246384778, -8655144, -175438992], [-21369788495, 333280484, -19105604, 1135044], [61929363534, -210919426, -63328145, -118377683], [-2863910080, -338936957, -63541408, -33555960], [76592685974, -200012757, -60819640, 68997208], [2012614828, -241705544, -6824288, -271102760], [67762808487, 82514108, -24430700, 23960692], [1944844180, 5852218, 7760492, -13506981], [4229850079, -4948964, 72560216, -113893340], [206110222768, 732373576, 37031036, 64736688], [-46396661584, 495317368, 1082874, -107527161], [-69154608684, -44329819, 14665648, 179811448], [-147471332735, -501656975, -54050320, 2956426], [128306922006, 328241454, 12212837, 61273377], [-86898736940, 20993678, -22127704, 110220405], [-99265616652, 588667934, 12631240, 59882167], [-58132151540, 527803682, -49235992, -23137485], [141206660448, -165183295, 1206688, 54453504], [177511027438, -529581086, 3036905, -64898943], [-229889573108, 237003824, -26449598, -361270188], [128135900402, -510153228, -44245736, -9004532], [69765140822, -406717751, 34826968, 31837344], [-16172971272, 143283422, -5659502, -85701159], [156279752187, -136667265, 6260796, 341937834], [13326380974, 311756921, 112059664, -141379500], [36528080618, 173624158, 18299601, -6396588], [-140832506847, 275962860, 32425004, -71088396], [186231897338, -358521062, 21400883, -182201013], [167242606418, 31739667, 18760728, 65314848], [-14113071920, -166314949, -48008640, 93798576], [186477340940, 433188042, 57541648, -141681791], [295939293020, 190587535, 46639888, -133063860], [-318005108, 980906960, -40813568, 123568272], [283467790928, -173188176, -76654166, -113753861], [5273106405, 268959302, 58126832, 322065976], [100307251130, -385592372, 33621968, -62534892], [-23160837480, 78698360, -40079864, -200577296], [247954270512, 197392308, -102718142, -70286085], [-23157423720, -643782112, -72693270, 312312409], [-41897624710, 844739484, 31140840, 64907164], [127522812168, -27420792, 42369814, 99247053], [-196382996022, -527523613, 14769760, 148939428], [-312061465964, -290449798, -63930684, -46738167], [243545482156, 641699758, -28270344, 184688344], [-106082048664, 1382352798, -31357910, 38986179], [27803623092, 721788114, 35733792, -93452712], [-59910041220, 100617465, -121400676, 245553942], [223010835184, -556441472, 16170810, 104468209], [-160060352120, -586067944, 81355548, -94493160], [-563147428011, -64983355, 3459160, 59343418], [7618179190, 342585830, 44224673, 413161593], [-220042328104, 1006214062, 32652850, -83201727], [59419613059, 1233402964, 34149296, -107945888], [107030797288, -622753327, -49676540, 91203834], [-393955775174, 186626338, -7170499, 321971271], [-189357166471, -695047422, 9147016, -251454080], [138171523376, 297859942, -60088752, 371484072], [340922743524, -140908540, -183359078, -45090728], [217262446412, -619334279, 99661468, -532235010], [187845923423, 37390575, -12766912, 9852922], [-562564020114, 104840474, 65551735, -97800420], [245825617646, -34067118, 37471125, -445392765], [-167546557192, 411199990, -82273858, -255323973], [101513052394, -559873708, -130266736, -743031612], [19975119538, -998426717, -95357176, -200253168], [472406951450, -659627207, 67235248, -275720844], [-194236982552, 217367794, -9545306, -129671219], [72429923422, -22470526, 36246301, -227980491], [9898162482, -2872870, 159284155, 384480888], [312946683532, 1808249600, -950920, -2606688], [-290980873846, -922520868, 192951672, 196573416], [94433174569, -165660748, 240334040, -319048812], [243000111427, -88878092, -2560252, -8454080], [180482814752, -671847924, -36668148, 251032644], [159721098562, 651536947, -136237128, -129705320], [-28923629592, 1809284865, -23495420, 397585554], [114121334474, 1910072701, -140309272, -37542288], [509285416080, -214293346, -85109574, 43247137], [153840195612, 923757291, 126858056, 654705192], [259440152546, 67859398, 98517873, -109524780], [-95292109584, 1007515850, -54567368, -222959664], [178832409454, 161148982, 75595403, -101070377], [-361755679560, -1903851966, -96161902, -337501473], [213686489134, -1095291100, 35797232, -181117224], [427367537336, -527748744, -16410130, -774995855], [-238974415821, -600906625, 29714924, -264162506], [-62767227624, 524623575, -118811608, -98674308], [97267383936, -40926922, 91801162, -239973039], [-372323922114, -412985545, -96477200, -591672444], [1012051227970, -363794860, 14809376, 67867368], [-186169667688, 582885318, 54369906, -155643831], [49351672204, -1989358192, 110286528, -574009056], [308315793796, 244275113, -169537332, -97815858], [-102943235228, -876913054, 55667444, 325412667], [412983594192, -1012588411, 80705360, 703333228], [195526934813, -875334872, -221727036, -121508916], [240178782240, -52135452, -152266584, 487450428], [-313320162790, -426030842, -110746823, -111449307], [578549200374, 2091451862, -20996335, 234222784], [285066454851, -561896788, 170277732, -392120288], [509210318366, -1383414671, 43173904, 577025676], [408085650956, 1008791376, 46157146, 716160556], [289737769919, 2094432699, 67112428, 142922662], [475649828088, 441875076, -362157434, -262300215], [239184006930, 282236210, -291946785, -145376432], [-1044370034808, -436089486, 72207466, -49732995], [-127144236446, -608537239, 136088304, 267404736], [17834726556, 556527182, 177202640, 177785743], [177629085610, -1467844832, 189413400, 546776164], [-276647400162, 347331522, 149946627, -388168761], [-1197302618812, 828001792, -76856986, 95542332], [-303589719946, -2548927944, -93946040, -987263156], [-1820613875, 28034993, -158490384, -151618878], [-116410123460, -17092073, 108684020, 352340778], [-526464383544, 1680150387, 62552200, 160331772], [-430453685749, 235849570, -191122616, 660047472], [-446992559328, 319810592, 372636696, 123587896], [102334507221, -1404565680, 33858944, -877277196], [-838366333662, 126560906, -110821789, 21184021], [304283515640, -918240800, -68028140, -680344128], [118378871172, -1883966362, 55300420, 149984877], [-1078775480646, 400959263, -210415752, 359159176], [-602639406884, 1906978912, -43673388, -364220552], [-629887750544, -2564828686, 169834114, -29641851], [-867045809889, 57900260, 50379280, -65257316], [-14230656966, 1516523457, -115117984, 236941392], [109633847398, 2265856082, -133417377, -300108756], [160597535818, 2617751542, 101913601, 487372963], [-442122119852, -2887903498, -294351296, -299681961], [-194382027424, -12420813, -94737852, -726475686], [222802154160, -1117131244, -133532448, -1332590996], [-672167792969, 348920018, 199574920, 475954500], [374972743686, 912779258, -92841593, 459672313], [-519211196898, 313500309, 27033736, -322537860], [486858067996, 830620033, 98391032, 246327280], [-530869184103, -2684276571, -209978104, -480957702], [871598312, -427550070, 56805606, 282309703], [-142414537148, 574537865, 166299724, -326069826], [-22310111698, 47466292, 374747984, 188952408], [140127417888, 331646156, 314987356, -33437636], [-312915885904, 2929715133, -308147192, 873890332], [-200068637445, 1627896342, -80924276, 841993884], [725077546, 2767032094, -70452223, -377871183], [719868420928, -1567553632, -70297530, -852644475], [639526349359, -455557100, 24164984, 141781036], [-398793365816, 371448119, -140799544, -562901088], [373258936902, 3955680210, 153345037, 765934932], [-257205141510, 1331202050, -258696593, -740549313], [207993198648, 2012853851, -225668460, 392347978], [-543483208974, 1996833948, 108269840, 1147967676], [51527665564, -2447879812, -289858906, -719021688], [-765674012988, -892493434, -303706420, 398210197], [-88887806883, -972631335, -318939344, -1501290870], [-429662060920, 76918966, -58324986, -383308071], [682360465890, -369258399, -563286656, -967004448], [-308721842168, 29011162, -129545224, 945729016], [-45293354744, 1564790102, 507662694, 269854683], [718774036698, -939378906, 92818899, 1521707727], [474846293810, 2354058684, 93645336, 552356764], [-961358793742, -1494350339, -350255264, 453752328], [114628637654, -1986428078, 333695241, 539389149], [18498051790, -4056365020, -149074664, -341871180], [-74651599756, 1626299904, -76946160, 138797376], [-821919748216, 451327942, -262157846, 473272131]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_162_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_162_8_a_i();".
// 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_162_8_a_i(:prec:=4)
    chi := MakeCharacter_162_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_162_8_a_i();".
// 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_162_8_a_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_162_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<5,R![4199040000, 23036400, -241515, -54, 1]>],Snew);
    return Vf;
end function;