
# q-expansion of newform 550.6.b.f, downloaded from the LMFDB on 16 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 = 550
weight = 6
poly_data = [1, 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 = [[177, [-1, 0]], [101, [1, 0]]]
aps_data = [[0, 4], [0, 1], [0, 0], [0, 166], [-121, 0], [0, 692], [0, 738], [-1424, 0], [0, -1779], [2064, 0], [6245, 0], [0, 14785], [5304, 0], [0, 17798], [0, 17184], [0, -30726], [34989, 0], [-45940, 0], [0, -25343], [13311, 0], [0, -53260], [-77234, 0], [0, 55014], [-125415, 0], [0, 88807], [1482, 0], [0, -117496], [0, 79362], [-87842, 0], [0, -47247], [0, 239416], [-98142, 0], [0, -400137], [-205766, 0], [-87726, 0], [-432778, 0], [0, 34075], [0, 45020], [0, -482556], [0, -766254], [-303399, 0], [-285181, 0], [767067, 0], [0, 411668], [0, 759258], [46600, 0], [-932428, 0], [0, 169745], [0, -198078], [849997, 0], [0, -401832], [-855174, 0], [1125464, 0], [-1197513, 0], [0, -37758], [0, -631254], [1080342, 0], [-816100, 0], [0, -1688198], [-879042, 0], [0, 1540268], [0, 720840], [0, 1039048], [-1251348, 0], [0, -1443361], [0, 2012079], [2017337, 0], [0, -264122], [0, 1710492], [-218822, 0], [0, 3681915], [-1885284, 0], [0, 3116659], [0, 1394414], [4260355, 0], [0, 201765], [-1948821, 0], [0, 1468258], [2246178, 0], [3614878, 0], [3812388, 0], [1973462, 0], [-2083590, 0], [0, -72691], [-594392, 0], [0, 4566507], [5443821, 0], [0, -6703124], [-1259940, 0], [0, -5023081], [0, 2356605], [6722580, 0], [0, -1960013], [-579624, 0], [-1369052, 0], [0, 1833426], [1712661, 0], [-789435, 0], [0, 627392], [3208952, 0], [0, -3426584], [0, -10519830], [0, 5472876], [11778672, 0], [-8356276, 0], [0, 13775839], [0, 12709308], [0, 1008252], [-10510032, 0], [-199390, 0], [0, -16190], [0, -11525344], [0, -16997394], [18487471, 0], [-4542811, 0], [18428631, 0], [0, 9666035], [0, 4514301], [0, -5372349], [-9879558, 0], [10805201, 0], [0, 11327486], [0, 12059490], [0, -5141664], [13124255, 0], [3659562, 0], [-10225211, 0], [-24168285, 0], [0, -16824641], [0, -5041684], [6263746, 0], [0, 3639756], [-18736957, 0], [0, -489242], [14696940, 0], [-24207236, 0], [0, 13526010], [0, -14209424], [0, 7933335], [10468512, 0], [11914742, 0], [-1861122, 0], [0, 23015285], [0, 16835148], [23529859, 0], [-29154921, 0], [0, -9490522], [0, 1815528], [10781209, 0], [0, -28335456], [0, 26891884], [-19213227, 0], [0, 11593100], [0, -13185678], [0, -2981948], [29657868, 0], [-31805678, 0], [23344446, 0], [0, -20737208], [26919282, 0], [0, -10189563], [0, 10392354], [0, 8188768], [-17327439, 0], [0, 438963], [0, -27912387], [-42684640, 0], [0, 22104418]]
