
# q-expansion of newform 5915.2.a.f, downloaded from the LMFDB on 13 May 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 = 5915
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], [1], [1], [-1], [3], [0], [3], [-2], [-6], [3], [4], [-2], [12], [-10], [-9], [12], [0], [8], [4], [0], [-2], [-1], [-12], [12], [1], [6], [5], [6], [7], [6], [-16], [-6], [12], [14], [6], [1], [14], [-2], [3], [-9], [12], [20], [9], [4], [0], [-16], [-13], [19], [3], [4], [24], [21], [10], [18], [30], [6], [-6], [16], [-10], [-3], [-13], [21], [-11], [18], [-19], [18], [28], [14], [-18], [-26], [-15], [-24], [17], [-4], [-20], [-12], [-3], [25], [15], [-14], [-12], [-17], [-21], [2], [26], [-18], [9], [-8], [24], [-32], [15], [30], [-38], [15], [31], [27], [6], [-42], [20], [-11], [8], [24], [36], [18], [-4], [7], [24], [39], [45], [-10], [-13], [-2], [-42], [-26], [-29], [-30], [-41], [-24], [-6], [-15], [-32], [-28], [45], [24], [28], [-9], [-35], [-30], [8], [31], [43], [12], [23], [-16], [-30], [-14], [-21], [-5], [15], [-15], [-2], [27], [-4], [-54], [-52], [42], [10], [-30], [-4], [-24], [-50], [0], [20], [-24], [26], [-24], [11], [-36], [47], [0], [0], [0], [22], [-48], [-54], [21], [56], [-37], [43], [-6], [-24], [-50], [-15], [46], [50], [-12], [55], [51], [-52], [8], [28], [12], [14], [-6], [36], [42], [-16], [-17], [31], [-48], [2], [-30], [-25], [0], [-60], [9], [49], [44], [-3], [-3], [18], [26], [-50], [-46], [-54], [3], [-2], [-60], [42], [32], [-52], [-30], [-28], [27], [-18], [28], [50], [60], [-42], [-6], [-22], [22], [51], [-2], [-75], [-10], [-9], [-51], [-19], [-36], [68], [38], [40], [9], [-19], [3], [-32], [48], [15], [-54], [-24], [56], [-31], [-38], [-33], [54], [-56], [-18], [-59], [-18], [-50], [-42], [36], [8], [6], [39], [38], [28], [-27], [7], [-10], [-78], [4], [-7], [-18], [-46], [27], [6], [4], [18], [-40], [52], [-71], [-4], [-58], [7], [-12], [46], [-65], [18], [-27], [49], [48], [10], [-77], [69], [38], [-42], [28], [-36], [-75], [39], [24], [12], [26], [0], [26], [21], [60], [55], [-85], [-78], [65], [-48], [23], [-2], [6], [32], [-48], [-16], [72], [-39], [-18], [86], [90], [20], [-66], [27], [37], [69], [-82], [-32], [-54], [-20], [66], [20], [25], [-44], [72], [-36], [10], [36], [-82], [21], [-20], [63], [-65], [-66], [-14], [-7], [-26], [48], [-42], [17], [18], [36], [38], [-44], [-66], [-57], [-32], [16], [3], [89], [5], [-18], [42], [42], [-6], [6], [64], [0], [48], [63], [-52], [98], [-39], [70], [29], [33], [-16], [-48], [39], [86], [2], [72], [9], [79], [6], [53], [-6], [-78], [52], [66], [40], [-21], [19], [77], [-20], [15], [55], [-27], [-75], [44], [27], [-40], [-20], [-24], [-67], [-18], [4], [-84], [94], [33], [-12], [-70], [-26], [33], [76], [36], [71], [-18], [-18], [-28], [-58], [24], [75], [-28], [54], [-51], [33], [-38], [78], [-12], [43], [9], [72], [54], [16], [-48]]
