
# q-expansion of newform 2601.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 = 2601
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 = [[0], [0], [3], [4], [-3], [-1], [0], [-1], [9], [6], [-2], [4], [-3], [-7], [6], [6], [-6], [-8], [-4], [12], [-2], [10], [6], [0], [16], [0], [5], [9], [-20], [-9], [-13], [3], [6], [-2], [18], [8], [11], [-2], [21], [15], [6], [-14], [-18], [22], [3], [16], [-2], [-1], [3], [14], [21], [12], [-8], [-24], [-12], [-12], [-15], [11], [-2], [-12], [10], [24], [20], [-24], [16], [-6], [-13], [-14], [-12], [-19], [-6], [0], [-8], [-22], [-32], [12], [-36], [-20], [-15], [-19], [12], [-25], [-24], [-1], [28], [-6], [-6], [-19], [-30], [8], [-42], [-27], [22], [6], [22], [15], [-36], [21], [20], [16], [-8], [30], [30], [24], [-8], [-7], [36], [18], [6], [-38], [-38], [11], [-6], [10], [-37], [-33], [-32], [-18], [27], [-6], [-31], [22], [-27], [3], [-20], [-24], [-14], [3], [8], [2], [-1], [24], [46], [-43], [-30], [41], [-24], [40], [48], [-51], [10], [-21], [28], [-21], [14], [-57], [-26], [-18], [20], [-24], [-14], [18], [11], [39], [-2], [-27], [11], [15], [-22], [18], [36], [-36], [41], [-6], [30], [-9], [52], [-62], [-20], [6], [-42], [5], [9], [59], [-61], [51], [-20], [-15], [-43], [47], [-19], [-60], [22], [-36], [18], [-54], [-38], [-19], [-62], [36], [10], [-12], [-1], [-48], [-9], [6], [34], [-44], [42], [54], [-15], [28], [-7], [17], [60], [-54], [-40], [48], [-27], [20], [-62], [-54], [-26], [12], [39], [28], [-43], [36], [-45], [48], [-7], [-68], [-48], [-14], [18], [-34], [-69], [57], [41], [48], [-1], [70], [20], [66], [56], [42], [40], [33], [-15], [12], [21], [20], [-49], [11], [51], [9], [10], [-21], [-19], [36], [41], [18], [-48], [64], [-42], [-60], [16], [52], [51], [-58], [10], [-48], [-68], [40], [9], [-37], [66], [0], [64], [18], [-32], [-55], [-49], [32], [14], [-25], [-36], [-43], [-19], [0], [-60], [-50], [-72], [-10], [22], [-48], [-74], [42], [35], [0], [27], [-3], [66], [3], [64], [63], [80], [48], [33], [68], [-31], [24], [4], [9], [28], [-2], [-42], [4], [60], [-22], [-12], [-18], [3], [59], [-48], [23], [30], [3], [-68], [-36], [46], [22], [-66], [-13], [54], [-61], [-2], [10], [24], [45], [28], [81], [-62], [42], [16], [-75], [65], [-81], [-38], [29], [-19], [12], [51], [71], [-24], [-51], [-2], [47], [57], [-42], [5], [4], [36], [10], [-49], [0], [36], [-84], [3], [30], [-44], [81], [24], [36], [-43], [17], [-75], [-52], [-8], [-12], [76], [-57], [0], [-40], [-8], [-45], [36], [-49], [90], [17], [15], [-96], [-44], [15], [70], [93], [17], [38], [-56], [-96], [22], [-87], [12], [-1], [6], [4], [104], [-6], [-20], [18], [64], [48], [-31], [30], [6], [-62], [14], [-60], [77], [105], [-44], [78], [0], [28], [65], [-30], [-15], [-14], [63], [30], [-6], [-98], [3], [78], [64], [-24], [48], [-27], [65], [-9]]
