
# q-expansion of newform 384.8.a.m, downloaded from the LMFDB on 07 May 2024.

# We generate the q-expansion using the Hecke eigenvalues a_p at the primes.
# Each a_p is given as a linear combination
# of the following basis for the coefficient ring.

def make_data():

    from sage.all import prod, floor, prime_powers, gcd, QQ, primes_first_n, next_prime, RR

    def discrete_log(elts, gens, mod):
        # algorithm 2.2, page 16 of https://arxiv.org/abs/0903.2785
        def table_gens(gens, mod):
            T = [1]
            n = len(gens)
            r = [None]*n
            s = [None]*n
            for i in range(n):
                beta = gens[i]
                r[i] = 1
                N = len(T)
                while beta not in T:
                    for Tj in T[:N]:
                        T.append((beta*Tj) % mod)
                    beta = (beta*gens[i]) % mod
                    r[i] += 1
                s[i] = T.index(beta)
            return T, r, s
        T, r, s = table_gens(gens, mod)
        n = len(gens)
        N = [ prod(r[:j]) for j in range(n) ]
        Z = lambda s: [ (floor(s/N[j]) % r[j]) for j in range(n)]
        return [Z(T.index(elt % mod)) for elt in elts]
    def extend_multiplicatively(an):
        for pp in prime_powers(len(an)-1):
            for k in range(1, (len(an) - 1)//pp + 1):
                if gcd(k, pp) == 1:
                    an[pp*k] = an[pp]*an[k]
    from sage.all import PolynomialRing, NumberField, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_data]
    convert_elt_to_field = lambda elt: sum(c*beta for c, beta in zip(elt, betas))
    # convert aps to K elements
    primes = primes_first_n(len(aps_data))
    good_primes = [p for p in primes if not p.divides(level)]
    aps = map(convert_elt_to_field, aps_data)
    if not hecke_ring_character_values:
        # trivial character
        char_values = dict(zip(good_primes, [1]*len(good_primes)))
    else:
        gens = [elt[0] for elt in hecke_ring_character_values]
        gens_values = [convert_elt_to_field(elt[1]) for elt in hecke_ring_character_values]
        char_values = dict([(
            p,prod(g**k for g, k in zip(gens_values, elt)))
            for p, elt in zip(good_primes, discrete_log(good_primes, gens, level))
            ])
    an_list_bound = next_prime(primes[-1])
    an = [0]*an_list_bound
    an[1] = 1
    
    from sage.all import PowerSeriesRing
    PS = PowerSeriesRing(K, "q")
    for p, ap in zip(primes, aps):
        if p.divides(level):
            euler_factor = [1, -ap]
        else:
            euler_factor = [1, -ap, p**(weight - 1) * char_values[p]]
        k = RR(an_list_bound).log(p).floor() + 1
        foo = (1/PS(euler_factor)).padded_list(k)
        for i in range(1, k):
            an[p**i] = foo[i]
    extend_multiplicatively(an)
    return PS(an)
level = 384
weight = 8
poly_data = [83625, -700, -620, 0, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0, 0, 0], 1], [[22600, 680, -100, 16], 25], [[59800, -5320, -220, 16], 25], [[291000, -14760, -1020, 48], 25]]

hecke_ring_character_values = None
aps_data = [[0, 0, 0, 0], [-27, 0, 0, 0], [-84, 0, 1, 0], [-170, 0, 0, -1], [-964, -1, 6, -1], [-2670, 2, 9, 1], [6558, 1, -20, 7], [3864, -3, -44, 19], [2828, 0, -76, -14], [464, 6, 61, 76], [-17938, 22, -84, -111], [45022, -66, 885, -65], [2806, -41, -8, -91], [-16672, -61, -544, -111], [333612, -4, -1432, -170], [216144, 218, 1297, 8], [-469612, 56, -2156, -1428], [475294, -54, -2807, -1133], [-1376372, -336, 1876, 1476], [241924, 516, 6740, 502], [811190, 446, 11002, 656], [-1617954, -168, 5756, 1051], [-4254900, 439, 2906, -541], [3389954, -610, 5680, 2450], [545130, -550, 13700, 6970], [-842416, -732, -14831, 8398], [3040306, -802, -17216, -1733], [6251628, -3142, -29236, 3690], [-2847670, 3470, -8575, 4289], [5342722, 1874, -55316, -4902], [-15785798, 2686, -38124, 16367], [-13957500, 616, -53800, -13344], [15797358, 2077, -79928, -2529], [-1725292, -3036, 32900, -8328], [-31203076, 3400, -60303, 11280], [-26868178, 1254, -86832, -5575], [-37550626, -7754, 98865, 20075], [-19374664, -2933, -149912, -7575], [-11825584, -2624, 40468, 19372], [-31339940, 9518, 4461, -32902], [-51412260, -7184, 142700, 53084], [-46199414, 1214, -204139, 39925], [-51413832, 12632, 19848, -38008], [23996686, 14034, 55998, 57624], [-24050616, -3946, -186519, 62640], [-37867974, 8774, -76528, -16369], [-98007300, 5856, 158140, -11372], [-54608854, -7772, 271932, -3331], [-98354644, 2317, -3138, 21873], [-154052174, 14430, 29685, -56031], [200751754, -14758, 273924, -104302], [22974368, 2372, -518992, 46512], [24314510, 3504, -387598, -50354], [-148307252, -38953, -358458, -53737], [93468370, -37912, -534048, 11344], [-87785608, -48340, -158980, -98224], [125999584, -41560, 287453, 27682], [-58825750, 22076, 393828, 204837], [-368733094, 27134, 207773, -18787], [163723138, 93332, 383916, 120952], [105117212, -20752, -414832, 341000], [-134391328, -706, 763273, 117676], [408023964, -68496, 487236, 152180], [-90794736, 98204, 241284, -327036], [70235302, -87262, 432310, 489888], [324876536, 110232, -208643, 313622], [238076444, 35498, 1562580, 60570], [-858745778, -74578, 218890, 33488], [282148980, -2937, -835350, -507469], [148891982, 89638, -341807, -168001], [-630502718, -82198, 653964, 390858], [122927252, 56616, 1546068, 484722], [-94843538, 23618, -134236, -236891], [-1210896610, -128082, 689885, -146221], [484311136, 41237, 295436, -694469], [108485912, 94852, 2386872, -419804], [310856796, 177442, -2012183, -1224978], [1047120854, 176714, 1423865, 165811], [-1045412826, 152507, -95468, 279613], [-292043806, 283110, -754612, -858954], [319150796, -139095, -5374746, 20573], [80140250, 106314, 504101, 1035385], [279896628, 377608, 2108184, 49494], [-1801846382, -130296, -1435276, 110756], [645290370, -96750, -1371144, -388801], [382667172, 269207, -1070606, 332747], [13311310, -333131, -3560308, -53], [-348462238, -363118, -304252, 677682], [2400073836, 188866, 480325, 115198], [-638115310, -585970, -1135172, -1265349], [-485558948, -404031, -2203146, -347835], [1008929708, -479240, 905352, 1482566], [-840088794, 679176, 3178400, -507705], [141910068, -11842, 3568392, 1555202], [373512468, -124400, 7598880, -1506712], [1800681636, 128104, -1816868, -729454], [1087762184, -63118, -2039243, -302572], [1239532382, 119111, 6769548, 2120833], [2461064464, 116341, -5320492, 53003], [-1492753406, -181798, -10360175, -1275419], [2382013904, -234355, 11334736, -660801], [2173559860, 557344, -5785603, -2188828], [-1418377692, 356955, -4404162, -1991685], [379173750, 41471, 9884048, -838299], [1694069428, -1042554, 2952, 1914850], [-2194766282, 61778, -5160322, 1214216], [672805876, 254674, 129312, 4731382], [654458274, -1618398, 8355372, -1051558], [-170108204, 448804, -6399548, -432990], [-3017466530, -11154, 12848966, 570100], [-667806166, -909694, -2290620, -1319821], [-2740078994, 233210, -6155579, 2476391], [1198800450, -417240, 12155780, -1689948], [-2799414196, 1167892, 272720, -3140564], [-8029520426, -734792, 2118024, -304697], [4694270070, 589397, 960424, 3373239], [858862192, 534657, 8614976, 2907891], [191190300, 458236, -2104324, 130958], [-504651196, -732802, 7996901, 7483214], [-6209130484, -460870, -5858008, -52122], [-5540961418, -746578, -6107451, 2883959], [813172482, -549316, 23522540, 1627592], [5493994500, 223716, -9644039, -501176], [-2852716524, -97991, -10268362, 7937997], [4917826456, -1558589, -9864128, -798455], [-5692663896, 1671632, 258629, -457266], [-455265534, 165434, 5854941, -6046531], [-3767926316, -1559480, 10397104, 6688722], [-3518177970, 704218, -14570656, -3287043], [-6870894470, 1619922, -9607879, 3934833], [288327548, -18818, 6340392, -11964230], [967727976, -709120, 10213524, -4200904], [-5981682626, 9784, 11332364, 2836715], [3162624226, -1885466, -23926683, 1609417], [-1660145594, -1432271, -2596116, -4872465], [3664550046, -2457418, 28714494, -5727372], [5345730984, -459732, -12141039, -7988542], [121830688, 2581727, -13235852, -3347775], [-557004732, -1438884, -15860067, 7311368], [-10065272610, 4278749, 16968952, -8809993], [3002169800, -2065937, 1263372, 1266649], [3916199368, 789888, -12078575, -12968650], [2278630510, 3067420, -45898024, 928319], [4585381724, 2133110, -8474988, -1098970], [-7592450102, -700898, -29990839, -7282519], [4305030028, 1268828, 32657748, 5843746], [-422989370, 1537382, 76954013, 7684879], [-2204592858, -3165961, -25575344, 6499605], [6105777160, -892531, 10037336, 3602719], [-33754296, 3055600, -36596568, -8117232], [-6891053938, 1770622, -9808687, -7269329], [-736547406, -4050372, -1507088, -738292], [11413517976, -698241, -19467328, 12540885], [26638380344, 660316, -36316092, -4196408], [-2337798024, 2047865, 60841904, -7319765], [-23272829728, 603488, -18604144, 6482076], [14578953758, 1448308, 28005912, 21956151], [-2112703914, -690193, -16075484, -2139663], [-8894151286, -2394616, -87078816, 7913720], [-10786370388, -272226, 17515061, -3586534], [-13643544420, -547536, 69970780, -2085764], [-18749792210, 2948743, 7644924, -9259311], [-10634866454, 2880300, 91943848, 2156077], [26389667044, -19947, 58666966, -643583], [-8692164378, 4553255, 39391252, -8635367], [24638174248, 2771740, 68373156, 9266192], [29125314814, 5060156, 32819204, 15623583], [20146494870, -4311174, -15928395, 4935015], [19897776874, -3450130, -40040260, -7197218], [22925712580, 7461362, -27557215, 5546226], [20610179684, -6316422, 46315264, -3000354], [23904677278, -4624526, -50831687, 18439983], [94112328, 919692, 38185684, -32202356], [13178584330, 5680944, -46906736, 13419024], [16534818086, 5019532, 7404044, 17435371], [-16868882542, 876652, -13696380, -6088904], [-15279721700, -7613600, 49111456, 12899768], [-15592780740, -202608, 28587289, 13124304], [767097570, -6273078, 58325104, -6290481], [18394551526, 1809010, 44561385, -5011873], [58722443918, -1547736, 59110500, -17293197], [-2399483172, 6550523, -18236990, -11713177], [1960675818, 2153894, -48769811, -21836815], [18057258674, 1167884, 41720908, 41142000], [-47700026968, 4625972, 40780208, -8158868], [23495146532, -8703410, 1167921, 18224638], [39294309674, 2188086, -41134527, 33117], [-7194409900, 1563060, 56715056, -7179148], [14868944934, -3139664, -84073878, -17274794], [9996360096, 803772, 24580576, 45750772], [-11680600398, 9862964, 13907528, -48773020], [13733848596, 4338732, 28803012, -38661560], [-6120924556, 2320952, 59608864, -41083984], [3130395108, 2419898, -56456443, -25715142], [-14584192268, -7948448, -153946576, -6534256], [1342104994, -14550256, 89999860, -1283812], [20006403174, -8220342, -107006914, 13087488], [23675236122, 7904554, 79913217, -1443015], [9573257162, -5175856, -148151652, -24373588], [-6392713648, 10040936, 19586060, 42902888], [-33396147060, -3486756, 5352685, -18626484], [-24916954942, -3525538, -168042756, 18330323], [-14819270238, 2494922, 104845685, -24102975], [13681940398, 564078, 87651522, 27009224], [28166921772, 2002021, -60467782, -33476755], [9762320808, 11788978, -154731619, -8781708], [67936477986, -703804, 189254124, -14125279], [-550535724, -1171729, -154759402, 21750367], [20106304554, 5489286, 160420756, -2590914], [-31893306488, -2753519, -82426944, 48040827], [31862620558, -5754970, -75575458, -43884364], [-68777004876, -4903348, -18606207, 3087512], [-15611847566, -9314506, 198213512, 36014019], [12857011940, 16702132, -21773036, 36990672], [-24064489668, -14295212, -8747836, -14207446], [13689777994, -1692592, 290717332, -11361796], [-58807606394, 5166694, 7589812, -13822675], [-80484925034, 22248349, 48361896, -24945161], [32498001696, -101212, 338495308, -36051808], [33198051948, -11216332, -217833995, 3542204], [-35818564126, 285434, -159012899, -52112383], [68055222858, -7378628, -188728576, 9936837], [31217792638, 5832139, -53459288, 50444713], [-43335599846, -11099412, 175635620, 56147661], [-73858381460, -8281041, -283760166, 16926267], [-6780618474, 12591866, -50230755, -2938893], [17561269010, -2220814, 130360104, -105092930], [37885282284, -12023420, -226218536, -40467718], [22662343202, 15920176, -285759640, -35882619], [61479561540, -3612922, -219725104, -61976766], [22444222186, 4613074, 265426401, -65761779], [-32687863376, -6783939, -328047576, -11608713], [38215278866, 22208654, 380779428, 66008443], [61390495634, 9974440, -172661500, -68693636], [-37374725048, 25856281, -214485280, 21380787], [-78735422244, -6939316, -411573856, 34241346], [11499198954, 22491902, -122527644, 79935462], [-8540580052, -22259316, -133188319, -79139524], [17164564436, -6848691, 244158742, 120954489], [-23490827060, 35273940, -268666564, 20948854], [-32643030492, 21158307, -104127570, 6577491], [-5470680676, 22102370, 120505620, -18773878], [40262799934, -27074822, -179684520, 84225917], [63049337662, 2735158, -108646399, -65722109], [-76756605638, -24998868, 32208460, 35154152], [79036179228, 5483896, 283616364, -104967146], [175478820246, -13883780, -203101020, -16626685], [-37992969932, 17513522, 201846324, 1663418], [-9594586196, -3044246, 56193828, 75903362], [-90702303496, 18567764, -261585496, 6005408], [77590364346, -37642642, -105003359, 145417457], [-58318674990, -10897054, 314618412, 41928874], [60799581900, -20368284, -263035652, 49972830], [-11756385094, 6571612, 68099848, -29936708], [10681439744, 30639354, 323750589, -24178784], [345296196, -27184886, 295936324, 40856258], [-61217855806, 13009638, 78046557, 65168765], [-11113764572, -39985274, 77543320, -96542534], [85098596680, 13922754, 394447889, -81954484], [-78660227974, 18135096, 151186012, -28013204], [164202547866, 887094, 278992228, -65430225], [-28613176084, 16791240, 791274684, -7346972], [112611496178, -30117054, 30654933, -20930111], [-62364920450, 18387990, -236068103, -82457173], [-55396686706, 18080687, 143756576, 87975237], [104363078804, 36672270, 83301844, 91812046], [20927459492, -7672296, -160593339, 12605108], [-147401819542, -5374410, 247675996, -55094938], [37573628728, -20673365, 361592868, -167989579], [95566503612, -4030304, 367706649, -99788352], [-42494142466, -8817918, -172364151, -107378125], [131137240396, 49077850, -530184376, -97189850], [-92095264486, -22384216, -547511160, -37304576], [204544024790, 2599922, 79835244, 95574017], [68774051554, 24262560, -508881376, 34246432], [43205621306, -8541924, -184132864, 142760269], [-39128122068, 10484585, 706773882, 78297353], [-122435966522, 1482914, 41794785, -99369621], [-149609915522, -36839506, 789881070, 83177436], [9767423076, -27418982, 238457396, -200526174], [286672573932, -19035740, 414333208, -103912230], [-141617391902, -30706074, -418171632, -102470637], [147320795236, 7897720, -190055660, -92107402], [-71426837122, 50908386, 777891029, -87590489], [38988067640, 35347207, 55924628, 56787465], [-15365993736, -75169880, -39456024, 34451732], [-151134098178, -39021468, 126959842, 38006122], [11739825556, -8445092, 471369721, -234643536], [31231569350, 54393516, -108148920, 93669795], [167362747650, 55181386, -786584084, -104885846], [-38601167596, -48062042, -146757643, 206847798], [-100871657412, 4165524, -306153996, -13413952], [-30685557854, -20085126, -28652032, 38512622], [70183197732, -48618772, -185156468, 244408704], [34341928086, -22743446, -933083919, 23484191], [78310322988, 30059642, 137818669, -67241218], [48651995026, -70838332, 191161388, 111035633], [136322845168, -15118576, 259937177, 198258218], [-295107036164, 28092173, -273017046, -12740267], [-157292925472, 43944651, -647744556, -106397595], [-103189120506, 14765094, 814236662, 134692316], [-149648613340, -27106558, 166553981, -256971158], [-219085555162, 2977608, -813335492, 208760535], [-51722935820, 60874668, 198012176, -122584540], [-59913130096, 71581859, 324262816, 73159937], [46917367630, 30559384, -94648406, -166501810], [-25590381972, -3118737, -559636322, 117419031], [-321985143238, -20363018, 789129361, 82653341], [-107063620164, -34987904, 77690924, -36537322], [80011150590, -23442566, 151721805, 99457647], [-103008159656, 20336724, 27474624, -237993644], [-2308707552, 10929364, -384613111, -50033706], [167796114134, -72752391, 769802080, -22741973], [201702532872, -31995627, -726192724, 1042235], [90260576640, -51853916, -1008260, 408442244], [-106223381398, -82940564, 624631416, 134081644], [-88643996916, 23232654, 502479920, -106647078], [18946012884, -102971948, 396610008, 150092342], [261374652926, -7042, -1408776262, -156860192], [-60807852022, -42611782, 603766152, -89475666], [-100942626556, 4218180, -231708208, 3354340], [-179970634122, -39842154, -372071914, -465752916], [-262243624256, 3677826, 1238039405, 1393728], [-298376622818, 96131514, 149992860, -113754531], [-129396313498, 60554143, -813156984, 87022661], [204047515322, 77033778, -418268196, 35184122], [-222834870024, -5350379, 404558804, -196943437], [325381125408, -45982769, -1408461456, 70176965], [5436094128, 13729212, -493852816, -19538604], [40339690956, 101661810, 977781425, -18293474], [-292004439142, -22773602, -566016983, 226241425], [-26278083444, -44888884, 528246757, 261976732], [-282219122182, -58194812, -430792196, -146180755], [9371328420, -107526442, 247261780, 344811862], [237644441316, 104695688, -719691756, -26672252], [-317783186180, 14914389, -448640662, -49026499], [-192272217986, -38337322, -804329143, -86078789], [42492238506, -11465918, -782695608, 330200638], [-289851863146, 14881634, 720717218, -77053948], [-337535600526, -115460852, -932533596, -351474439], [3637802358, -68678446, -182358907, 327951579], [40474778062, -13931613, 1341460236, 315090429], [-441537399920, -39780978, 1855303937, 246421724], [-403543143886, -91954180, 655689352, 23217257], [130990041064, -90614778, 1024820165, -33541592], [236633024484, 19560583, 599000494, -337530593], [-362832602262, 12155558, 319928829, 295473865], [-114831874372, 2183026, -344728788, -284033630], [-23822245164, -44777816, -542684944, 79995874], [-112316873352, 28991226, 1535778233, -301464220], [-321457036448, 124481099, -430588780, -67472107], [165171698370, -33486158, 1325621980, -394073414], [-293453064392, 26855862, -922042123, 394339104], [182394171234, 28702240, 764054900, 435748189], [-100540492538, 61565570, 705485045, -551997477], [-5368196790, -70715396, 841507632, 160147084], [57623051248, 111721932, 1661520824, -82740824], [-683232052796, 6236458, 746885368, 234577702], [-46870374714, 84568553, 1334763520, -334952117], [-167426420976, -82269240, 1312501620, 27494528], [-191701653154, -102137982, 29800517, 300012883], [319520850306, -110625146, 1706087384, -361557038], [277404716952, 119060196, 261647424, -139206748], [-532428788292, 16059597, -651729622, -90247851], [-273109543572, 89061862, -189307352, -182650022], [-134507715602, 185272158, -390992906, 232618372], [-303374643312, 128854728, -87441275, -277637286], [259298070750, 135904020, -679045888, -104328425], [-110964215094, -33181188, 2054058068, 110494352], [294974969908, 127203293, 2447502898, 162932717], [-351318210064, -57051763, 1823287036, -45362813], [959652799536, -39963364, 223586632, 74752116], [107117618576, 126642982, -889129407, 452834564], [281638517550, 58012514, 727758768, -132066379], [153675386154, 17530506, 2168219065, 231112985], [692563001812, 46354371, -2223941738, -291744629], [241254921944, 9623368, 1116573336, -1065565736], [-522355890846, -173574256, 1942186784, 381439936], [-263889456242, -201140781, -181241632, -449934623], [695718225206, -146569996, -2112343326, 279716458], [1001606301292, -82234558, 627978677, -59346266], [-437668892346, 62484737, -84740876, -442222681], [327155941966, -35227178, -2504597104, 39749241], [-557168499950, 57329392, -1679192984, 734870472], [152273503520, -14418659, 450519728, 4415831], [215335592640, -95390208, 2114282100, -47731292], [-30757899234, 89542232, 227273100, -498103349], [517707249914, 43017250, -106653395, 253563225], [421703700276, 119538028, 605430060, 675916008], [-503731942604, -117766496, -1119085264, -186066602], [-13261483118, -34331772, -1769355624, 597770724], [-312062880204, 188034982, 288740441, 39182558], [257298235532, -71795528, -3279127112, -39428256], [-734620675912, -145600431, -1122990660, -738107577], [-928753404216, 147249024, 1119722204, 1682240], [-68479916942, -66518534, -694871068, 281350026], [118242894106, -46878350, 2640175428, 75638283], [-432114246786, -50740341, 460880060, 166277589], [-9988462048, -77736507, -245654372, -212243469], [-610079303060, -203920606, -250792695, 235603398], [558691828646, 111644290, 946316457, 470893595], [-228625403954, -16623905, -1011512720, 224878485], [255008471746, -42000840, -187180588, -680112123], [-116353232298, -172606877, 298384184, -47614119], [120150612752, -47143092, 831264217, 254851486], [835472523862, -6276378, -937102600, -483338627], [368279101722, 10652242, 1801925881, 59875477], [-887665059866, 124768939, 1686826036, -127724179], [233578977896, 246675149, -3018726036, -174984725], [744973220980, 99998863, 1791861462, 119068607], [-700534259594, 38658442, -915651482, -141212696], [-444956959740, -79003688, -1356654583, 366983492], [109338135548, -31225213, 946128486, 1123356091], [-531862635688, 108020903, 29586120, 285482949], [127087809734, -251075014, 610748746, 41736340], [30922890832, 81237272, -3688401227, -640627998], [122327309592, 30916816, 366179736, 741062528], [1355303651982, 82378220, 1173344, -570633609], [-30101038650, -96828161, 542431940, 194425457], [-656824821924, -99384076, -1344370820, -1280796302], [134906910844, 203465436, 325626445, -281627204], [-334135150970, 125669186, 534408861, -465659653], [-21264895672, -122149524, -809050824, 1105906208], [1003609658388, 3122969, 1899525070, 881656165], [351183744886, -251382706, -624682914, 101438220], [-1133062655456, -149565760, 679327605, 964595514], [-245683052708, 198677417, 1899535270, -390258435], [124395432018, -184325566, 2111159344, 456384462], [-1629905471496, -56092471, 727464160, -376600477], [-337520882868, 47316132, -2659445340, 360210878]]
