
# q-expansion of newform 5265.2.a.m, downloaded from the LMFDB on 19 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 = 5265
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], [1], [2], [1], [-1], [-2], [-3], [0], [-5], [-1], [-5], [0], [-8], [2], [-14], [9], [-1], [14], [0], [6], [-12], [10], [-2], [1], [-3], [-1], [-19], [-14], [-10], [-8], [4], [5], [12], [-6], [-8], [-6], [-12], [0], [-12], [18], [17], [-18], [13], [-15], [-22], [0], [-26], [26], [-16], [14], [-15], [10], [-12], [28], [16], [-3], [-7], [10], [12], [-25], [-1], [2], [4], [-28], [27], [27], [-22], [-17], [12], [3], [31], [25], [-20], [-23], [12], [22], [-30], [-28], [0], [-20], [10], [-17], [-38], [0], [7], [30], [26], [26], [-6], [28], [-15], [-34], [6], [28], [9], [24], [-6], [-15], [32], [-15], [5], [19], [11], [12], [11], [14], [31], [-14], [-17], [-8], [30], [-9], [-11], [-5], [-17], [32], [-41], [-48], [36], [38], [24], [-6], [20], [1], [5], [4], [2], [48], [13], [9], [48], [2], [-16], [36], [-40], [-31], [38], [42], [5], [-36], [-32], [11], [44], [34], [-5], [-54], [-24], [28], [30], [15], [-23], [47], [23], [-1], [-42], [38], [56], [60], [36], [-24], [48], [-50], [-50], [9], [4], [-18], [-40], [-10], [32], [56], [2], [-2], [-11], [10], [-1], [16], [-26], [36], [-1], [-50], [8], [-4], [23], [36], [-15], [30], [14], [-26], [-41], [-26], [-30], [-58], [-6], [-60], [-46], [38], [-4], [-9], [-21], [-38], [-38], [58], [62], [-39], [4], [-64], [-43], [-42], [50], [66], [14], [16], [36], [24], [52], [-37], [-38], [46], [62], [43], [1], [-50], [32], [4], [50], [56], [-42], [-57], [-13], [2], [-20], [-55], [-57], [-44], [36], [-62], [23], [-6], [-60], [2], [14], [-39], [-20], [-54], [-70], [46], [-76], [-45], [-39], [43], [64], [48], [67], [-60], [-45], [-33], [0], [38], [-57], [15], [3], [-60], [50], [-21], [-34], [4], [-30], [-72], [-66], [-49], [34], [37], [26], [28], [-72], [-46], [40], [36], [-24], [55], [48], [9], [-54], [10], [28], [36], [37], [-63], [19], [9], [-4], [41], [60], [32], [62], [66], [-32], [-30], [-46], [10], [83], [-50], [36], [-58], [-30], [15], [-41], [-19], [-8], [0], [-72], [-30], [76], [54], [-38], [-25], [33], [-21], [-3], [22], [39], [-30], [-4], [37], [-39], [-75], [-58], [75], [16], [76], [-36], [-48], [42], [33], [-30], [64], [-1], [22], [-83], [1], [-12], [48], [-70], [30], [-70], [-87], [-64], [-75], [-40], [-7], [-25], [-80], [29], [37], [-18], [25], [57], [30], [-84], [-27], [81], [-49], [15], [57], [80], [-85], [6], [73], [-44], [-56], [36], [50], [-68], [-72], [-15], [-16], [7], [-78], [-34], [-12], [-94], [8], [18], [-37], [70], [25], [54], [52], [51], [2], [-22], [-60], [35], [-24], [-58], [37], [-45], [-58], [48], [-8], [-44], [-42], [-42], [-36], [-56], [22], [48], [-36], [-36], [84], [66], [-21], [-16], [-46], [51], [-9], [-23], [14], [-8], [-51], [83], [-22], [-50], [70], [-21], [44], [-2], [-100], [-56]]
