
# q-expansion of newform 3025.2.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 = 3025
weight = 2
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 = [[1], [0], [0], [0], [0], [2], [6], [4], [-4], [-6], [-8], [2], [-2], [4], [12], [2], [4], [10], [16], [8], [14], [-8], [-4], [10], [-10], [10], [4], [12], [18], [6], [16], [12], [-18], [-12], [10], [-8], [2], [-16], [-8], [-6], [4], [-10], [8], [-26], [2], [0], [-4], [4], [-20], [-10], [6], [-8], [-10], [12], [-18], [24], [-18], [0], [10], [-18], [4], [10], [20], [-24], [22], [18], [4], [6], [-4], [10], [-18], [32], [-4], [18], [20], [12], [6], [-30], [2], [6], [-28], [6], [24], [22], [8], [-8], [2], [-26], [34], [36], [0], [-24], [-28], [28], [-36], [-16], [14], [-6], [-20], [34], [12], [10], [36], [-26], [-36], [22], [24], [22], [24], [-2], [-32], [34], [-2], [-20], [40], [34], [16], [-20], [10], [-36], [-10], [-26], [-38], [16], [-28], [-22], [-10], [0], [-52], [42], [-4], [40], [16], [-6], [-10], [22], [-14], [52], [2], [-18], [12], [18], [36], [12], [-2], [-32], [2], [-18], [28], [-4], [-22], [18], [16], [56], [40], [8], [-24], [-14], [6], [2], [0], [-42], [8], [36], [-10], [4], [8], [-46], [-26], [-30], [-28], [-34], [-40], [-10], [32], [10], [-36], [6], [-16], [34], [36], [-28], [-22], [6], [36], [38], [-6], [24], [-58], [8], [-42], [-12], [-44], [30], [28], [38], [22], [-38], [-2], [-8], [-38], [40], [-62], [-10], [12], [50], [-40], [52], [30], [-44], [-18], [-58], [36], [-8], [48], [-6], [-56], [-34], [-36], [42], [-30], [32], [50], [-52], [68], [58], [-34], [24], [8], [36], [-14], [-20], [40], [-66], [16], [-72], [-14], [-54], [20], [0], [-64], [-76], [4], [-18], [30], [48], [28], [36], [52], [48], [2], [14], [12], [58], [-6], [-36], [-74], [36], [26], [-58], [32], [12], [-46], [-14], [62], [-20], [-66], [-38], [52], [42], [14], [-16], [-50], [-64], [14], [-52], [40], [-22], [-18], [-20], [-48], [16], [-32], [-22], [-28], [24], [6], [-22], [-40], [78], [-18], [40], [6], [84], [34], [50], [0], [2], [4], [68], [-74], [42], [64], [8], [-60], [30], [40], [-50], [-8], [-46], [56], [-42], [-50], [88], [24], [-18], [84], [80], [-26], [-50], [-52], [-2], [90], [36], [6], [82], [20], [-40], [56], [-78], [-22], [2], [-8], [-12], [-76], [-16], [-66], [46], [-54], [-40], [-86], [-58], [10], [0], [42], [68], [54], [96], [-72], [-46], [68], [-10], [30], [-56], [-62], [30], [-24], [20], [-2], [-28], [-70], [-42], [92], [-20], [-40], [-2], [42], [24], [30], [-28], [44], [16], [-22], [-48], [18], [36], [32], [14], [30], [38], [94], [-90], [-8], [-42], [52], [-28], [64], [-54], [-20], [4], [-30], [18], [-60], [-96], [-72], [-10], [-48], [-86], [-84], [-30], [-94], [6], [-8], [6], [-54], [88], [2], [78], [-40], [-52], [62], [42], [-8], [-76], [-34], [46], [-48], [28], [-66], [16], [-34], [74], [-28], [-36], [-26], [74], [-48], [6], [12], [96]]
