
# q-expansion of newform 9702.2.a.w, downloaded from the LMFDB on 01 May 2026.

# 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 = 9702
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], [2], [0], [1], [2], [3], [7], [7], [5], [2], [3], [-6], [11], [7], [4], [-11], [10], [-4], [5], [-8], [-8], [-14], [-2], [15], [-3], [-10], [-18], [4], [-2], [-19], [8], [-6], [17], [-17], [-5], [1], [6], [10], [-14], [9], [-10], [8], [24], [-15], [10], [20], [-14], [-10], [-10], [9], [10], [-4], [-5], [14], [-30], [20], [8], [24], [-3], [24], [3], [28], [-27], [15], [-30], [-14], [8], [-24], [8], [-10], [18], [0], [-22], [-16], [-31], [6], [-3], [-32], [32], [-3], [-17], [-40], [5], [5], [-41], [36], [40], [-13], [-24], [-13], [-18], [18], [26], [-40], [30], [-4], [18], [-20], [16], [-11], [-9], [42], [-13], [-43], [-18], [12], [21], [0], [0], [36], [2], [20], [-26], [-10], [12], [40], [0], [10], [20], [-11], [-10], [21], [-39], [18], [27], [-31], [-9], [-14], [22], [20], [4], [-40], [15], [30], [28], [-4], [-37], [50], [14], [-28], [-50], [-4], [10], [-17], [-24], [46], [-21], [-22], [28], [26], [-36], [8], [20], [-24], [-13], [43], [-4], [26], [-15], [27], [10], [-3], [36], [44], [-49], [8], [30], [-16], [60], [-8], [-46], [42], [-6], [4], [-10], [3], [-26], [40], [14], [34], [2], [-53], [63], [-9], [44], [-20], [38], [-20], [-2], [-13], [-48], [-50], [6], [-48], [-6], [40], [-15], [-58], [56], [-22], [-33], [62], [-10], [-55], [56], [-70], [-40], [-6], [48], [12], [48], [26], [-60], [36], [-65], [-68], [66], [8], [12], [-32], [-5], [6], [56], [30], [28], [24], [27], [-37], [18], [31], [-41], [35], [67], [46], [-18], [43], [50], [28], [-56], [-11], [12], [58], [-43], [49], [-54], [20], [-25], [15], [50], [58], [-59], [-29], [-62], [-62], [-20], [10], [-37], [-4], [-20], [-72], [-18], [64], [-30], [28], [-42], [-58], [6], [19], [-34], [-15], [2], [-26], [-31], [-20], [-18], [3], [-40], [68], [-22], [48], [-32], [-72], [52], [27], [45], [-74], [-43], [16], [57], [-64], [-25], [-30], [42], [52], [26], [-68], [-18], [-82], [-13], [-44], [-57], [-31], [1], [88], [-38], [60], [11], [-53], [26], [0], [18], [57], [34], [-72], [-12], [-65], [-48], [51], [-33], [17], [41], [67], [-20], [-59], [-70], [2], [-54], [6], [6], [46], [6], [11], [56], [4], [12], [-39], [-19], [-23], [43], [46], [90], [-33], [74], [8], [6], [53], [22], [-42], [6], [5], [65], [28], [9], [-52], [39], [20], [-8], [39], [48], [-56], [-43], [-24], [-72], [-48], [-79], [63], [-56], [-62], [65], [-36], [-82], [-90], [0], [47], [-45], [-24], [-90], [-62], [10], [-76], [76], [0], [-45], [-47], [76], [32], [59], [-21], [-33], [79], [-52], [59], [-8], [7], [-8], [31], [84], [-40], [101], [30], [0], [-40], [72], [55], [-32], [-53], [57], [20], [-51], [-78], [-25], [-37], [-9], [-70], [-64], [64], [52], [-90], [-22], [8], [78], [89], [-52], [-5], [68], [28], [-39], [-34], [-36], [29], [46], [-60], [-80], [-39], [30], [-54], [46], [6], [33], [-101], [48], [-70], [30], [64], [-7], [-61], [78], [-70], [70], [-41], [95], [-108], [-45], [50], [-40], [-70], [-36], [-8], [78], [88], [58], [-50], [-93], [36], [54], [43], [-83], [46], [-50], [-1], [63], [-87], [38], [-17], [-8], [-60], [88], [78], [-48], [74], [-17], [14], [-49], [98], [-78], [-75], [-111], [-50], [68], [-108], [-68], [53], [-59], [-48], [74], [-56], [60], [-75], [8], [87], [-16], [-97], [-48], [-79], [110], [-83], [72], [-2], [41], [-62], [50], [16], [38], [33], [-97], [-4], [40], [72], [-68], [38], [40], [-107], [-32], [38], [60], [79], [85], [112], [8], [-72], [54], [43], [-48], [-55], [-60], [67], [-86], [114], [15], [-104], [32], [38], [-92], [58], [72], [16], [-35], [49], [106], [-55], [77], [48], [36], [7], [18], [4]]
