
# q-expansion of newform 150.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 = 150
weight = 6
poly_data = [0, 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 = [[-4], [9], [0], [4], [-500], [288], [-1516], [-1344], [4100], [-2646], [-5612], [7288], [-18986], [2404], [-8900], [-39804], [-28300], [18290], [-65956], [-28800], [30808], [60228], [2468], [22678], [36968], [167918], [154364], [-136788], [-53810], [-82692], [211780], [169500], [-252036], [192016], [235694], [-371492], [-264952], [403124], [261900], [-326228], [-109516], [-53146], [232056], [1030672], [522796], [-215292], [-1030080], [-456020], [434252], [-722710], [565348], [324904], [915262], [1367076], [-892932], [1866500], [-1372266], [458644], [985408], [165798], [1664708], [-2551044], [-736020], [1716600], [-2838512], [1276052], [443992], [-2713256], [1310508], [-298910], [-737996], [-2340744], [-127292], [-4038696], [1012136], [2376100], [1424974], [-1693448], [-2845006], [-1890694], [4609300], [-6041510], [-3800], [-250736], [-3588732], [1414788], [-829806], [-4681976], [-141930], [-727476], [4476396], [-1327184], [4116468], [-6123156], [-7904904], [-3976284], [781914], [5826938], [9789380], [4760590], [1165948], [1612932], [-3406028], [-14400902], [4747720], [10909408], [-8532228], [4631820], [6275976], [7719878], [6061604], [3664888], [9325220], [-7401616], [160052], [-16956530], [-11012796], [-3338484], [4761812], [798188], [-15404806], [976704], [-19388524], [5255732], [-5450336], [-4439606], [4559178], [-20663000], [-5481612], [8555792], [-5291192], [2364324], [-8796940], [-29580752], [-12629622], [-23218578], [17320068], [-556676], [-3005620], [2231526], [22486216], [-16592062], [-14754420], [3394748], [-509442], [40060904], [-9675064], [-32753532], [-21742024], [-20874444], [-39680392], [26074206], [-41048556], [-13755300], [5869356], [46398192], [22785924], [27035154], [28614944], [-36789242], [-7968276], [48220204], [-48350956], [-40551516], [43492932], [3348964], [-55572596], [12734184], [-32234338], [9083724], [-54714972], [-12922626], [49893664], [33602600], [39741076], [-62521482], [-7086352], [-16514418], [27122668], [2345054], [32763412], [-19735612], [14134400], [64896204], [1801300], [-42283086], [21666928], [7727492], [39504266], [-3347224], [13439352], [-23066572], [-40587248], [40115370], [58641516], [19684044], [65055150], [-41430624], [-32865780], [81786004], [-67467462], [90269388], [45670032], [64324654], [97333900], [-13972020], [-23804340], [-59816668], [28355270], [62624032], [-84550048], [83848242], [99841196], [-108745860], [57912272], [-42499034], [69189380], [-59016526], [94796236], [-94990636], [-2584710], [-16586540], [-89439330], [-1984708], [126696348], [-52841178], [-18435316], [87824600], [-66559420], [31911748], [-137450032], [-147057080], [-4192156], [23535798], [-20086892], [-55955956], [40495650], [-105368996], [-83260452], [-9111408], [36194244], [12705320], [-99799268], [148359538], [53759204], [-8473488], [-97821948], [-104092716], [91428152], [73458164], [-103452048], [-46951934], [-80483252], [104338906], [57174004], [-95117028], [-178476794], [-50684212], [46381348], [176498048], [96589980], [-6872068], [-211393238], [-136436776], [115834188], [199429544], [-79782630], [52946122], [-45794204], [23064516], [86732846], [8479580], [-94041064], [-123435740], [208037704], [127952972], [234165916], [89073698], [81990278], [110175900], [-115146012], [-28030540], [-84310148], [195006790], [-26317156], [266578984], [84390216], [-121105532], [-281673172], [151202386], [-38931830], [-265623060], [-106802604], [-226277100], [96367864], [-35207082], [-100172244], [77026668], [-89063300], [98193468], [42264800], [-241987452], [45254780], [155560308], [-212486272], [84399256], [-120773348], [-12618526], [181327808], [210813816], [-199618332], [-77076174], [-41604894], [127140708], [253257932], [-236575354], [-147699772], [-88417696], [199714120], [-233973630], [-187692616], [-81121312], [77098026], [-401124596], [-117230844], [24961742], [321331320], [-306962604], [-127502548], [-259559764], [-88899758], [1781204], [92780252], [-56464460], [-18892752], [-254513796], [-16626674], [241778532], [-412840586], [-237022220], [-320563224], [292124452], [318324382], [280359860], [93862052], [-308784996], [461645178], [314369564], [-71600272], [-212050692], [387348920], [-26260680], [215439162], [146546508], [-516257206], [262987716], [79617552], [270531492], [81701276], [298134308], [324020920], [-60276198], [-314948100], [-105319700], [324460188], [13785712], [435181380], [-219386868], [-390901434], [-134789764], [347763224], [-147094252], [-240513378], [-498302340], [488789472], [11377084], [368821088], [276903696], [535904802], [-523094536], [127016838], [238803484], [-274144972], [-273843308], [-449421192], [-615206412], [-242742972], [289752224], [-658874412], [-311607556], [-644608558], [-18320844], [-346998348], [-520593748], [281579504], [3527032], [23018852], [-89867578], [-511672480], [776785026], [415376014], [211134620], [-361952092], [-404750484], [193831470], [457086404], [-338979984], [-133285806], [-399117436], [-591885228], [358912928], [177413724], [11401860], [-175579856], [415432648], [45386374], [788684464], [786696948], [-733596148], [-33748236], [-54389418], [-419510536], [258423308], [-278122812], [-501365632], [-694491972], [831619204], [-120945766], [885270720], [-380615624]]
