
# q-expansion of newform 80.6.a.f, downloaded from the LMFDB on 23 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 = 80
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 = [[0], [8], [25], [108], [604], [-306], [930], [1324], [852], [5902], [3320], [10774], [-17958], [-9264], [9796], [-31434], [-33228], [-40210], [-58864], [55312], [27258], [-31456], [-24552], [-90854], [154706], [-72714], [129396], [206680], [-70146], [-151854], [336596], [-275308], [-228502], [-224284], [-183802], [-296032], [134766], [60248], [62012], [-591682], [241404], [187622], [-37560], [164434], [360518], [654168], [693156], [-494756], [-907088], [1089494], [499706], [-1620384], [1001218], [-368980], [279010], [-811740], [353214], [1716216], [-245882], [-1676182], [1258816], [719158], [-1860128], [-278384], [-474182], [-1837378], [-2997428], [1875314], [-180312], [-87058], [2659010], [2149368], [3082580], [2287270], [1301540], [2032764], [94230], [-5555506], [-784814], [-4594006], [-1413012], [5945558], [6481144], [4055970], [1214504], [5531536], [2201106], [3298346], [-3942658], [-8820404], [1287088], [-6511792], [5795228], [-990276], [-2914996], [-2478716], [-6758066], [-6339030], [-231920], [-9444402], [-3101616], [-1223298], [14089592], [1484682], [2864700], [4217282], [2010472], [7336914], [-1148840], [11640938], [155540], [-11813690], [6422522], [-3852524], [6751360], [-7354926], [-15969448], [-17266692], [-1362514], [8818076], [-1520346], [-315086], [-1740922], [19893488], [-20151916], [8107662], [-13561258], [-4283136], [-11208388], [4705486], [23109868], [-5752940], [19242376], [4492102], [7335002], [-5855262], [13455750], [-10070608], [-11884418], [10605258], [1389436], [-11266138], [27709332], [-12366168], [12318190], [11727656], [15705878], [25239002], [-3662476], [41793772], [10898974], [-30433630], [-6090280], [-27790788], [-37151032], [7859592], [16269304], [-36936462], [4897050], [-6839426], [-10379040], [25958746], [39211980], [10687596], [27726562], [9492724], [20324312], [47050758]]
