
# q-expansion of newform 363.6.a.f, downloaded from the LMFDB on 25 April 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
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K.gens()[0]**i for i in range(len(poly_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 = 363
weight = 6
poly_data = [-8, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = None
aps_data = [[-6, -1], [9, 0], [34, -10], [-104, 62], [0, 0], [102, -74], [178, 372], [840, -852], [-284, 330], [398, -1492], [-4440, -1600], [-2362, 2816], [-18238, -8], [-3328, -3112], [21676, 390], [-9638, 7102], [-404, -1980], [11638, 2026], [-26612, 12704], [13516, 4354], [20606, 5568], [2712, 11426], [-50700, 21960], [-13750, -26704], [-115822, -9924], [-4906, -17052], [-72336, -5252], [-102140, -5432], [24550, 19958], [-109718, 23752], [-205416, -19486], [-43796, 79408], [-103766, -72492], [-312880, -6204], [-176922, -39536], [-75776, 38706], [54358, 49580], [46540, -80592], [-363544, 52412], [103374, 180972], [597756, 56844], [30686, 2860], [-277028, 121806], [137030, 96444], [-324682, 67684], [-40488, -309036], [-102688, -229192], [1072160, -24944], [453884, -154480], [-862242, 59340], [-570158, -240032], [449616, -258996], [945086, 119484], [189140, -488772], [-742190, 382736], [135792, -308720], [91666, -75826], [33224, -303314], [-776634, 14674], [1168578, -234108], [126912, 168568], [307990, -170912], [833160, -777388], [-602076, 286098], [330762, -437264], [1415042, 599730], [1022740, 27144], [-1467146, 1104648], [433932, 218432], [-1159250, -17138], [-2074814, 700120], [-1344912, 45740], [1299696, 537176], [-466826, -924754], [-1745116, 1074448], [485372, -340430], [-1187950, -1155226], [267046, -232908], [1280466, -45988], [770326, -1163684], [-3602116, 1305772], [-3707626, 549520], [-342328, -627976], [623698, 740904], [-1855560, 2356954], [671292, -2551940], [3182330, 423388], [5512246, 753892], [-4115266, 264200], [-2299016, 1066068], [3556172, -1688824], [2980344, 531712], [1488168, 1926172], [2149812, 459776], [-1582796, -1621624], [7702200, 21068], [1986866, 631358], [-256998, -683964], [4835680, -339024], [-987130, 3061278], [2245504, -1053780], [-4633282, -689792], [-563788, -1879496], [-2589766, -214348], [-13514104, -260636], [2110674, 357900], [-6507220, 2554524], [2322826, -844492], [5624500, -3752398], [682518, 127232], [-3405272, -3539886], [-3733426, -311894], [10669154, 1851104], [-1248708, -2197664], [-1917248, 3249456], [-6293494, -1725172], [12702356, -3099624], [3466932, 1407098], [-2973414, -2531702], [16747668, 351752], [256942, -2635428], [11287958, 2372236], [6260902, -3835652], [-2373116, -1620300], [-10646620, -2946720], [6728398, 639080], [-6096226, 3685308], [9677748, -1716462], [4859512, 5507356], [-14431610, -998186], [4701800, -2331152], [-12400160, 4973196], [13589912, 1086640], [-18741242, 899336], [-18842038, 4101668], [368662, -1139748], [-8243750, 9258526], [18021736, -1165000], [-9141686, -500082], [27279354, -1343280], [-1984600, 4560816], [653446, 5065548], [-4437784, -5343040], [-4821364, 7285008], [7534462, 5527680], [-15239748, 3421966], [-17234034, -3492622], [16064378, 5915184], [-20159132, -389168], [17674772, -996178], [-20947218, -463074], [-13764966, 6571592], [27100140, -4813816], [-4760528, -3139804], [-1294340, 2735368], [676852, -13008278], [-15723152, 11126534], [30770, -3964612], [-18310922, 1465248], [-22290994, -178396], [15601492, -3638696], [-51990406, 1525456], [27386000, 2728938], [16569100, -105084], [-20900750, 5752468], [-4582316, 12410386], [-39482856, 2218496], [26534582, 8712982], [5192862, -10188172], [34602610, 1195906], [26562228, -9029144], [14780966, 12157804], [-984352, -2683380], [-10265858, -6019248], [-697632, 430072], [-21756078, 530696], [-3124104, -7758244], [-33768334, -1095398], [36319256, 444286], [28319790, -3925778], [44010680, -11110776], [-7740836, 2794160], [22212230, -16082536], [26147578, 2229856], [-35189276, 1110106], [-29512142, 2064010], [-31812322, 10031282], [-19205580, -555720], [-191434, 230284], [6617992, 7002968], [-22808894, -3220108], [49955820, -13022296], [-16502684, -4798208], [-28221686, -3643682], [45094852, -7152728], [-26427254, 12891544], [-20204978, -5456856], [8148390, 874820], [-14747310, 546192], [7545432, -2759360], [-34643458, -5869624], [7069040, 15037286], [-51823426, 12280316], [-67703018, 4150232], [65053396, 3454188], [66394530, -19851110], [-76957784, 3660964], [-53373348, 15047448], [75495850, -3711140], [40492164, 16502936], [-1911274, -12530140], [60202178, 350042], [3753456, 29864304], [21963332, 10728720], [-2363712, -459780], [49581738, -8541908], [-16834608, -1181614], [49555514, -20092492], [23235932, 27500282], [-7589382, -18682038], [-27562618, -15584214], [43121488, 19008850], [126127874, 2247956], [-26467600, -6606408], [-71810908, -3469312], [42968614, -32593146], [34451394, -10905480], [63501204, 15342534], [-10829096, 28161746], [5078708, -3344720], [-74732466, 9871856], [-62400672, 24230200], [71219968, 14525678], [74934218, 1277820], [8375548, 27462384], [-45020016, 42566120], [-63156574, -4403344], [75954470, 3304880], [31868548, -41030428], [28020684, 29970190], [36355468, 36185096], [-107107152, 1726136], [-107017056, -14559456], [34899350, -30141244], [-41977990, 25277908], [4579296, 44599764], [125802688, -2562172], [62853316, -10815336], [-23473784, -39765716], [69642136, 25117284], [52228910, -3956454], [-17430534, 48295744], [62298676, -18487058], [-119863670, 21467084], [3794014, -56330120], [15553428, -59596792], [-16478058, -56420704], [-85645144, 19467056], [11740746, -45774606], [79134862, -30380812], [-18743800, -25566690], [101474316, -21679080], [90455598, 8509742], [-11792114, 3615070], [30031690, 35379028], [-28344292, 8989936], [148263546, -121614], [-10937070, -22711728], [-12431632, 52332340], [-25433114, 54764476], [29163974, -11708820], [136802468, 7595888], [-109070598, -11262412], [33199264, -6808734], [46373446, -58745472], [-213583880, 5699948], [85739564, -36116920], [-1937818, -9780174], [-111590506, 5303256], [198381700, -1136864], [-45260120, 4216344], [89069320, -57041188], [78872032, 26113412], [122836038, -70999954], [-58840488, 25740724], [-32478004, -70659358], [119713858, -35638388], [-122147722, -51018028], [3625304, -25204772], [-19187190, -27725068], [127719434, -20136578], [158574404, -1460924], [39008306, 15403220], [72721564, -92888], [41411518, 9303694], [-165016946, 12935504], [-90182464, -34153436], [-87278054, -4327690], [39636988, -819248], [-79988112, 42377432], [46106750, 3407804], [-119022018, 7997760], [199878432, -19403162], [-164794612, 7283112], [196435300, -20131120], [209628034, 19521288], [-64875716, 74781160], [-163432722, -52521264], [80617100, -1910194], [43574854, 17823190], [33104096, -14649100], [-89372294, -11175358], [-88340790, -39508440], [-51777612, 43913032], [57332416, 7420552], [207651294, 4636976], [-36912276, -49807888], [217130992, -71129016], [-40253582, -87548016], [-19071790, 93803472], [238291256, -10129236], [83670714, 79732460], [-165535218, -25124648], [212928784, -45061468], [38156930, 22156900], [-154375982, -9933796], [289746828, -43737288], [-148613972, 54401432], [-96495248, 27778468], [-32979194, 32215908], [-100346642, 24228314], [8768314, -86725610], [-59901792, -43723954], [28443132, -61913968], [96949008, -60118296], [61654724, 69780728], [102735878, 77233684], [-25256470, 57895972], [-55446646, -35152976], [-232827096, 32080898], [-270791842, -43028484], [17481810, 6637140], [15214550, -98958088], [-166053064, 70118208], [377222738, -37837250], [50053428, -26436856], [-205517746, 37324564], [91601092, 57557264], [28470296, -9455140], [-105224662, -49090786], [101611152, 46717784], [-13396678, 35287208], [-204570158, -31612466], [-155653000, 11046290], [230621742, 26736226], [104848426, -65397728], [3658516, 105738178], [124570932, -25271120], [-472528510, -10357008], [-53882524, 64079038], [-84182882, 143564154], [-149821054, 159054980], [258283836, 45579114], [-216680268, 62556104], [-143169828, 193065360], [-70357782, -103762480], [-51774786, 46888944], [271928080, -76839630], [409258590, 3363108], [-77188460, -139432460], [-246924332, 508336], [170483328, -53139976], [51238502, 41228572], [-175476680, -53549662], [336084558, -14268232], [101442932, 45283192], [-287643760, 46922916], [195931406, -3660896], [14037874, 43863568], [125867030, -115127260], [460740154, -44615170], [141806114, 93333380], [-425807728, 97639186], [-59541166, -82766676], [199587368, 29341872], [345186004, 14399206], [-246413624, -17646680], [51681286, -141533776], [-267716752, 41923168], [-113257444, -121684298], [80397522, 102999028], [255167682, 89488930], [158742084, 151216004], [-56972204, 62762160], [456298924, 3589966], [329731270, -102230692], [510640, 50238894], [95318210, -41970052], [-97612604, 42398232], [-36210442, 177441732], [277064902, 49907850], [-182511406, -40304940], [13162432, 170232334], [56765554, -193434764], [-526285290, 82035896], [423947064, -109400226], [-209287346, 114177352], [-251173158, -150378232], [156394252, -163954816], [-321313708, 17753920], [-334377602, -13781792], [-14536698, -96086056], [103557756, -61355312], [367341712, 74713404], [89945950, -54618672], [380778706, -16665590], [-540369760, 17706948], [-596048, -27021548], [-580653558, -72045988], [247130808, 50208948], [-187332006, 302210810], [-502585746, 112075066], [-100486140, -21305046], [573639428, -68255000], [214397786, -66972932], [242011490, -148804786], [-401086764, 159027888], [321512034, 150426656], [-437712092, 43426824], [-397117296, 45269504]]
