
# q-expansion of newform 1728.3.g.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, 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 = 1728
weight = 3
poly_data = [1, -1, 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], 1], [[-1, 2], 1]]

hecke_ring_character_values = [[703, [-1, 0]], [325, [1, 0]], [1217, [1, 0]]]
aps_data = [[0, 0], [0, 0], [7, 0], [0, -5], [0, 5], [-20, 0], [8, 0], [0, -6], [0, 2], [10, 0], [0, -31], [10, 0], [50, 0], [0, -10], [0, -50], [-47, 0], [0, -20], [64, 0], [0, -50], [0, 0], [-55, 0], [0, 4], [0, 17], [-10, 0], [-25, 0], [-155, 0], [0, 80], [0, -75], [-134, 0], [74, 0], [0, -15], [0, -95], [62, 0], [0, 100], [115, 0], [0, 25], [-20, 0], [0, -60], [0, -142], [127, 0], [0, 135], [-56, 0], [0, -20], [65, 0], [253, 0], [0, -75], [0, -86], [0, -20], [0, -52], [-146, 0], [-334, 0], [0, -10], [134, 0], [0, -120], [-268, 0], [0, 250], [-350, 0], [0, -21], [520, 0], [440, 0], [0, 190], [-218, 0], [0, 120], [0, 170], [485, 0], [217, 0], [0, -250], [-310, 0], [0, -125], [-74, 0], [-394, 0], [0, 330], [0, 325], [40, 0], [0, 396], [0, -208], [475, 0], [-260, 0], [740, 0], [659, 0], [0, 340], [496, 0], [0, 330], [-235, 0], [0, -239], [0, 332], [470, 0], [-325, 0], [655, 0], [0, 95], [0, 33], [0, 190], [0, 300], [0, -125], [0, -26], [0, 222], [265, 0], [380, 0], [0, -360], [532, 0], [0, -520], [-89, 0], [0, 175], [-100, 0], [0, 196], [-730, 0], [0, -463], [-982, 0], [0, -130], [251, 0], [0, -220], [-650, 0], [758, 0], [0, -100], [0, -69], [-910, 0], [0, -20], [0, 528], [103, 0], [0, 35], [-578, 0], [845, 0], [-1154, 0], [0, -108], [0, 284], [-215, 0], [532, 0], [0, -660], [0, 715], [-950, 0], [0, 336], [0, 500], [0, 101], [-830, 0], [560, 0], [-331, 0], [298, 0], [0, 640], [1303, 0], [170, 0], [0, 450], [1090, 0], [0, 545], [0, -48], [-542, 0], [0, 400], [-290, 0], [368, 0], [0, 616], [0, -588], [1330, 0], [-1060, 0], [0, -870], [0, -412], [0, 770], [0, -890], [0, 525], [1340, 0], [-1225, 0], [115, 0], [0, -397], [44, 0], [0, -145], [0, -195], [-346, 0], [0, -458], [0, -609], [-260, 0], [-109, 0], [-338, 0], [0, -445], [-1154, 0], [0, 1070], [530, 0], [0, -211], [50, 0], [0, 26], [-485, 0], [0, 975], [-1088, 0], [0, -515], [0, 845], [1510, 0], [956, 0], [0, -772], [1495, 0], [-170, 0], [0, -280], [779, 0], [0, 450], [1970, 0], [0, -37], [0, -846], [415, 0], [0, -612], [-1732, 0], [-349, 0], [70, 0], [1916, 0], [0, 300], [115, 0], [0, 25], [-680, 0], [-199, 0], [0, -1185], [754, 0], [0, 600], [0, -983], [-70, 0], [0, 400], [2405, 0], [-470, 0], [0, -5], [0, -1225], [0, -880], [-979, 0], [0, 860], [1970, 0], [0, -942], [1798, 0], [1438, 0], [0, 1376], [-160, 0], [0, 600], [0, 973], [1504, 0], [-592, 0], [0, 90], [0, 220], [0, 980], [-290, 0], [0, 384], [0, 1100], [1100, 0], [0, 1430], [0, 412], [-1186, 0], [-218, 0], [0, 895], [0, 660], [0, -700], [0, -594], [0, -925], [2176, 0], [1256, 0], [0, -860], [0, 105], [0, -815], [0, 1150], [0, -1092], [-1460, 0], [-640, 0], [0, -1018], [-1891, 0], [613, 0], [0, 705], [604, 0], [0, -640], [-2663, 0], [1685, 0], [0, 1795], [0, -733], [1294, 0], [2320, 0], [-3028, 0], [0, -700], [10, 0], [-730, 0], [0, -20], [2734, 0], [16, 0], [0, -360], [-2455, 0], [0, -1309], [785, 0], [0, -1635], [0, 37], [-1664, 0], [-2449, 0], [0, 260], [0, 500], [0, 1769], [0, -1022], [-3014, 0], [0, 970], [0, 1170], [-505, 0], [1471, 0], [0, -1796], [1520, 0], [-2810, 0], [0, -1443], [3476, 0], [0, 895], [1990, 0], [1870, 0], [0, 49], [2521, 0], [0, 1785], [0, 890], [-1150, 0], [2347, 0], [0, -225]]
