
# q-expansion of newform 1183.2.a.f, downloaded from the LMFDB on 24 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 = 1183
weight = 2
poly_data = [-3, 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], [0, 1], [1, 0], [3, -1], [0, 0], [-6, -1], [2, 0], [3, 1], [-3, 0], [-1, 3], [-7, 0], [0, -3], [5, -3], [6, 4], [-3, -4], [9, -1], [-10, 3], [-1, -3], [6, 0], [2, -3], [11, 3], [3, -3], [6, 4], [-4, 6], [-6, -1], [-4, -6], [6, -8], [2, -6], [3, 6], [8, 6], [0, -2], [15, -4], [5, -9], [-3, -2], [2, 0], [-4, 3], [11, 3], [9, -9], [12, -2], [0, -4], [-10, 9], [3, 1], [5, 0], [12, 0], [2, 0], [-7, 3], [-10, 0], [-3, 5], [-4, -6], [12, -8], [-21, 3], [-16, -3], [-12, 6], [-6, 7], [3, -1], [12, -4], [11, -3], [17, 0], [3, 6], [5, 3], [-6, 3], [11, -9], [3, -1], [8, 12], [-3, -2], [-1, 15], [11, 0], [9, -1], [-4, -12], [12, 5], [12, 4], [-1, 3], [-1, -6], [11, 9], [-3, -5], [-27, 2], [2, -12], [3, -8], [-22, 3], [-27, -3], [-1, -18], [18, -10], [2, -9], [-1, 9], [6, 10], [-12, 0], [11, 0], [0, -9], [11, -9], [3, 13], [3, -1], [20, 12], [18, -6], [-13, -15], [-3, -9], [12, 1], [-12, -7], [2, -18], [-25, 6], [23, -3], [9, 20], [9, 11], [36, 4], [-4, 12], [38, 3], [6, 6], [12, -17], [30, 8], [-4, -15], [-4, -6], [-7, 6], [39, 6], [-1, 21], [8, -12], [15, 8], [20, -12], [0, 26], [-24, -8], [18, 6], [-28, -3], [-13, -18], [-30, 4], [12, 2], [-10, 6], [0, 12], [-1, 18], [-9, 1], [-10, -18], [8, 9], [20, 12], [-18, 6], [41, -3], [-16, 0], [24, 10], [-16, 18], [-6, -4], [-13, 15], [-24, -6], [9, -4], [-1, -9], [18, -8], [-10, -18], [9, -15], [-16, 9], [-18, 0], [-10, 9], [-18, -7], [-13, 3], [-15, 13], [-1, 12], [-24, 9], [-1, -27], [-6, 10], [-1, -9], [12, 0], [2, -24], [30, 13], [-46, -3], [-42, 8], [-9, 1], [6, -18], [29, 15], [-18, -20], [-3, 20], [0, -10], [-7, 15], [-10, 3], [-10, -6], [0, 7], [9, 11], [-22, 9], [-30, 16], [-1, -12], [-13, -9], [12, 27], [-28, -18], [-3, 2], [-10, -6], [8, -30], [-19, 3], [12, 0], [-13, 0], [30, 4], [-12, -4], [6, -1], [-16, 0], [-46, 0], [-19, -12], [-6, -22], [32, -9], [-9, -3], [2, -18], [-36, 4], [3, 23], [-12, 8], [-1, -6], [-37, -18], [-6, -9], [-6, -32], [-27, -22], [-4, -6], [14, 9], [-10, -3], [12, 18], [-18, -19], [11, -15], [-3, 13], [-21, -6], [-28, 0], [-43, -12], [-12, 6], [32, 6], [30, 4], [-36, 2], [-28, -9], [5, -33], [6, -37], [6, -26], [6, 24], [5, 18], [2, -12], [9, 10], [2, -18], [-18, -18], [5, 6], [0, 1], [48, -4], [-16, 6], [42, -2], [23, -12], [38, 18], [11, -15], [21, -4], [59, 3], [36, -10], [8, -24], [15, 4], [-6, 12], [3, -3], [-33, 5], [47, 3], [-22, 18], [29, -12], [48, 3], [-21, 1], [-19, -15], [24, -16], [23, -9], [-6, 0], [-34, 6], [-12, -2], [48, -4], [-10, 9], [18, 32], [36, 16], [-34, 0], [-28, -12], [-36, 18], [-40, -9], [-10, 18], [6, 30], [26, -15], [-64, 3], [54, -1], [-19, -15], [-30, -6], [30, -3], [-22, 0], [-45, 20], [-10, -27], [-16, 12], [62, -3], [50, 0], [38, 0], [59, 3], [-21, -5], [17, 12], [-49, 18], [-6, -20], [-30, 14], [-40, -18], [21, 15], [14, 21], [-46, -18], [-6, 4], [-61, 0], [15, 12], [20, 24], [-30, 27], [-6, -16], [-24, 8], [-33, -8], [-51, -3], [14, 6], [-6, -1], [-10, 0], [6, -3], [78, -2], [17, 9], [-40, -3], [-33, -14], [-40, 0], [60, 0], [-4, 6], [-7, 18], [-36, 8], [38, 9], [3, 7], [-7, -30], [66, -2], [-18, -22], [51, -14], [5, 21], [6, 36], [68, 3], [-27, -15], [-15, -37], [44, -18], [-27, 0], [11, 27], [-46, 0], [24, -33], [26, 6], [-18, -4], [14, -15], [-34, 12], [35, 9], [9, 1], [3, -42], [-1, 42], [3, 26], [8, -18], [42, 20], [20, -12], [-54, 0], [35, -12], [-42, -8], [2, 3], [41, -21], [8, -12], [-63, -6], [6, 15], [5, 9], [-60, -8], [27, -33], [14, -39], [38, 6], [33, -27], [0, -32], [68, -12], [14, 18], [27, 12], [-55, -3], [59, 12], [18, -3], [-12, -44], [-60, -16], [-9, 46], [-6, 36], [-1, 18], [-36, -29], [36, 14], [-27, 37], [14, -18], [44, 12], [0, 24], [-49, 3], [29, 0], [42, -16], [59, -9], [0, 34], [3, -30], [5, 33], [-7, 42], [12, -22], [15, -9], [74, 0], [-18, 7], [-82, -9], [36, 20], [21, -18], [-25, -9], [0, 8], [29, 39], [36, -34], [17, 45], [32, 18], [59, -3], [3, -21], [23, -6], [90, 1], [-57, -1], [17, 15], [39, 7], [-4, 24], [5, -9], [-6, -24], [-25, 39], [51, -4], [-22, -24], [-12, 16], [32, 24], [36, 7], [-42, -1], [-85, -9], [-64, -12], [27, 12], [-49, -3], [0, 4], [62, 21], [9, 34], [60, -24], [-52, 6], [-13, -18], [-6, -47], [0, -50], [11, 27], [48, 18], [15, 13], [57, -4], [-16, 21], [42, 18], [-3, -15], [8, 18], [-18, -19], [-21, -17], [-9, 0], [2, -24], [-57, 23]]
