
# q-expansion of newform 3549.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, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_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 = 3549
weight = 2
poly_data = [-1, -5, 0, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0, 0], 1], [[0, 1, 0], 1], [[-3, 0, 1], 1]]

hecke_ring_character_values = None
aps_data = [[0, -1, 0], [-1, 0, 0], [1, 1, -1], [1, 0, 0], [3, 1, -1], [0, 0, 0], [4, -1, 0], [1, -2, 0], [-2, 0, -1], [3, 1, 0], [2, 3, -1], [-1, 1, 3], [2, -4, 0], [-2, 0, -1], [2, -1, 3], [-5, 0, 2], [2, -2, 5], [7, -2, -2], [7, -3, 0], [7, 2, 1], [-5, 0, 1], [0, -3, -1], [11, -3, -1], [-1, 4, 0], [-8, -3, 3], [2, 6, 1], [3, -2, 4], [1, -2, 3], [3, -3, -2], [-2, -5, 3], [-3, 5, 1], [-7, -1, 1], [3, 2, 2], [1, 1, 0], [1, -1, 7], [4, 4, -2], [-6, -7, -1], [-15, 0, -4], [-1, 0, -4], [0, 0, -3], [-1, -9, 2], [4, 8, -3], [12, 6, -1], [-4, 4, -7], [-11, -2, -3], [7, 10, -1], [10, -2, -5], [-11, -2, -2], [2, 5, -5], [10, 12, -5], [-5, -4, -4], [20, 2, 0], [0, -9, 7], [-14, 1, -3], [3, 0, 5], [1, 8, -5], [-6, 1, 5], [-10, 5, 0], [-10, 12, 6], [2, 3, 3], [9, 5, 2], [13, -9, -1], [9, 5, 4], [4, 3, 2], [21, 3, -3], [8, -9, 0], [29, 1, -2], [-2, 7, -3], [-1, 3, -8], [3, -7, 6], [-6, 3, 7], [14, 0, 4], [6, 0, 7], [-6, -4, 9], [-6, -10, 8], [0, 0, 8], [10, 6, 0], [5, 7, 7], [7, 5, -4], [-1, -5, 6], [-7, -1, -5], [-12, -15, 5], [10, 5, 1], [11, -6, 2], [-5, 5, -12], [-7, 8, 2], [-1, -11, -3], [-6, 10, -9], [0, 9, -11], [-22, -2, 3], [-7, -11, 2], [-5, -4, 1], [-25, -3, 4], [-1, 1, 2], [-8, 3, 8], [15, 12, -8], [4, -6, 6], [-15, 1, 4], [4, 11, -3], [-5, 1, 0], [-6, -11, 8], [15, 3, 0], [8, -13, 0], [-2, 8, 5], [6, -3, 8], [-8, 4, -1], [34, -5, 1], [-1, 13, -6], [-11, -2, 2], [-1, -1, 1], [14, -13, 2], [-15, 11, -3], [1, -5, 1], [12, -6, 0], [20, 3, -6], [-14, 0, 1], [21, -8, 0], [7, -1, 2], [-21, -8, 10], [24, -5, 5], [6, 5, -7], [2, -18, -1], [5, 11, -2], [14, 2, -3], [2, -4, 9], [-23, -3, 10], [19, 0, 9], [-17, 16, 3], [7, -3, 4], [-2, 15, 8], [4, 22, -1], [-21, -1, 2], [-13, 5, 8], [10, 8, 5], [-18, 5, -5], [6, -18, -6], [-18, 13, -4], [-3, 5, -12], [-1, -14, -9], [-26, 11, -2], [3, 6, -13], [-24, -10, -2], [-7, 2, 0], [-12, -5, 14], [0, 12, -4], [-7, 11, 12], [-5, -10, 13], [-9, 3, -10], [-4, -7, -11], [2, -12, -7], [-21, 3, -16], [17, 7, -12], [-10, 9, 5], [-14, -4, 4], [-3, 5, -7], [9, -6, -16], [-6, -3, 3], [37, -10, -5], [36, 2, -8], [7, 13, 7], [40, -13, -5], [0, -5, -8], [17, -6, 0], [27, 0, 6], [10, 6, -1], [19, 4, -2], [-15, -9, 4], [12, 8, -12], [-7, -10, 0], [-26, -15, 2], [1, 17, 4], [-5, -8, 1], [8, -17, 4], [-4, 6, -2], [36, -3, 0], [20, 0, -2], [31, 15, -7], [-10, 6, 1], [24, 8, 0], [-2, 10, -3], [-20, -27, 10], [-1, -15, 10], [-33, 4, -6], [-15, 5, 5], [24, 10, 3], [-23, 9, 2], [-38, 0, -9], [18, 18, -4], [-20, 10, -4], [28, 2, -11], [-22, 11, -5], [25, 5, -10], [0, 14, 12], [14, -3, 9], [-39, 3, 3], [-26, -14, 0], [25, 3, -3], [-5, -6, 9], [12, -10, 1], [7, 3, -16], [-22, 21, 13], [-12, -10, 4], [-8, -9, -9], [14, -4, 17], [20, 9, -8], [0, 0, 14], [14, 10, -3], [1, -5, 4], [-24, 0, 5], [-8, -4, 14], [-27, 11, 7], [0, -15, 12], [-16, 8, -4], [4, -23, 1], [3, -1, 6], [-24, 17, 4], [-26, 4, 5], [-19, -13, 5], [11, 3, -5], [44, -3, 10], [14, -22, -4], [19, 2, -16], [4, 2, -7], [18, -5, -1], [-13, -27, 4], [4, 3, 6], [9, 6, 3], [18, 21, -13], [33, -7, -9], [26, 3, -9], [-20, -8, 6], [-10, -26, 4], [0, 15, -1], [-38, -4, 4], [24, 15, -5], [3, 21, 6], [-17, 7, -22], [-26, -9, -6], [-18, -3, 2], [3, -8, 8], [-20, 21, 12], [-13, -24, 5], [-3, 9, 11], [15, 6, -6], [-2, -26, -3], [29, 0, -8], [6, 21, -8], [0, 1, 1], [-15, -12, 2], [14, 18, -5], [10, 16, -16], [-19, 21, 12], [-30, -20, 1], [19, -17, 4], [5, -14, 2], [7, 14, 2], [-6, -10, -2], [-9, -5, 6], [-19, 16, 5], [2, -6, -16], [13, -5, 0], [-22, 13, 3], [-11, 7, -7], [39, 16, -1], [14, 9, -11], [15, 6, 13], [22, -11, 11], [16, -25, -5], [7, 3, 13], [9, -22, -6], [-22, 14, -4], [43, 7, 0], [-35, -15, 0], [-57, -5, 0], [9, -14, 10], [21, 9, -5], [-38, 15, -3], [-27, -1, -18], [-35, -1, 8], [-29, -4, 1], [11, 2, 6], [26, -26, -11], [-17, 19, 10], [-21, -3, 2], [-6, -1, 1], [49, 18, -12], [-10, 3, -13], [17, 14, -3], [-27, 3, -1], [52, 16, -7], [12, 8, -13], [32, 16, -7], [32, -16, -12], [-8, 12, -7], [31, 6, -12], [-49, -8, 12], [3, -29, 1], [8, -4, 28], [-5, 12, -26], [43, 10, -10], [-21, -14, -9], [2, -4, 10], [-37, -16, 10], [-2, 8, -18], [35, 17, -13], [2, 22, 5], [-36, -8, 15], [-8, 20, -7], [-5, 10, 0], [15, -36, -6], [-34, 0, 3], [-12, -10, 11], [-7, -14, -18], [-22, 2, 7], [-18, -7, 4], [-44, 4, 5], [26, 22, -1], [-13, -14, 3], [-54, 9, -2], [51, 24, -9], [-25, -33, 18], [23, -16, -17], [13, -11, 15], [-29, 5, -8], [-7, 4, 2], [13, -9, 20], [-19, -26, 13], [4, 28, -11], [-8, -24, 15], [19, -3, -22], [11, -7, -1], [50, -20, -1], [-43, -18, 8], [-30, -10, 16], [23, -4, 1], [4, 6, 3], [17, -13, -5], [-17, -8, 8], [8, 9, 0], [29, -3, 14], [-42, 11, 5], [27, 10, -13], [-9, -34, 10], [-12, -21, 11], [-31, -11, 22], [-25, 6, -8], [-7, -3, -7], [-20, 10, -5], [7, 8, 12], [7, 13, -8], [47, 3, -5], [-28, -14, -1], [9, -15, 9], [-10, 16, 1], [5, 12, -24], [68, 4, 4], [-22, 2, 17], [-33, -7, 8], [-60, 6, -12], [-12, -26, 5], [-43, -14, 14], [26, 21, -14], [4, -1, -32], [6, -37, 5], [15, -13, 0], [-23, -25, 17], [22, 20, -20], [-22, 7, -3], [-41, 14, 4], [36, -18, -6], [24, -6, 9], [-66, -12, 4], [11, 2, 27], [-44, 1, 12], [21, 14, 11], [-20, 2, -23], [20, -14, -1], [-3, -22, -6], [-30, -20, 2], [-44, 19, 15], [64, 3, -4], [-15, 34, -5], [14, 10, -5], [-8, 20, 4], [12, 15, -11], [-32, 30, 9], [-39, -25, 23], [54, 4, 13], [3, -21, 11], [-24, 11, 4], [6, 5, 19], [35, 10, -17], [28, 17, -18], [-45, 15, 14], [-62, -11, 8], [-56, -7, 11], [30, -7, -5], [-21, -6, -24], [-12, -13, -3], [28, -20, 0], [-1, 22, -14], [-54, 21, 0], [-26, -19, 14], [-3, -8, -23], [-43, 21, 12], [-32, -28, 9], [-9, 12, 7], [-7, 8, -37], [-17, 1, 24], [-25, 1, -10], [11, -2, -8], [-11, 3, -2], [-18, 0, 12], [-50, -35, 19], [-4, 14, -21], [-4, -4, 6], [-28, -28, -4], [44, 6, -9], [-30, 2, 2], [-25, 17, -1], [41, 5, 7], [-18, 8, -31], [-9, -32, 30], [11, -12, -24], [-32, -10, -15], [-9, -7, 6], [-86, -14, 6], [23, -13, 3], [-17, -25, 0], [40, 6, -1]]
