
# q-expansion of newform 1764.3.z.m, 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, 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 = 1764
weight = 3
poly_data = [4, 0, -8, 0, 14, 0, -4, 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, 0, 0, 0, 0, 0], 1], [[0, 76, 0, 0, 0, 0, 0, 1], 14], [[20, 0, 0, 0, 0, 0, 1, 0], 14], [[0, -27, 0, 0, 0, 0, 0, -1], 7], [[2, 0, -28, 0, 7, 0, -2, 0], 14], [[2, 0, -21, 0, 7, 0, -2, 0], 7], [[0, 64, 0, -112, 0, 35, 0, -8], 14], [[0, -88, 0, 154, 0, -42, 0, 11], 14]]

hecke_ring_character_values = [[883, [1, 0, 0, 0, 0, 0, 0, 0]], [785, [1, 0, 0, 0, 0, 0, 0, 0]], [1081, [0, 0, 0, 0, -1, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, -1, 0, 0, -1, 0, 2], [0, 2, -4, -1, 0, -8, -1, 2], [4, 0, 3, 3, -4, -3, 0, 0], [16, 0, -4, 0, 8, -2, -2, -1], [0, 2, 0, -4, 2, -9, -2, 1], [-10, 1, -5, 6, 0, 0, -6, -1], [-4, 3, -14, 4, 4, 14, 0, 0], [0, -12, 0, 8, 16, -9, 4, -6], [-14, 5, 13, -7, -28, 26, -7, 5], [-14, -2, -8, -8, 0, 0, 8, 2], [-44, 0, 4, 0, -22, 2, -8, 7], [-18, 6, 26, -4, -18, 26, -8, 12], [14, 5, 22, 12, -14, -22, 0, 0], [24, 0, -28, 0, 12, -14, 5, 8], [8, -6, 12, -4, 8, 12, -8, -12], [-28, -1, 43, 8, 0, 0, -8, 1], [-28, -8, -6, 15, 28, 6, 0, 0], [0, 8, 0, 0, -54, -28, 0, 4], [16, 14, 6, -6, 32, 12, -6, 14], [16, 0, 46, 0, 8, 23, 11, 16], [28, 4, -10, 3, 56, -20, 3, 4], [2, 3, -11, 37, -2, 11, 0, 0], [16, 0, 36, 0, 8, 18, -4, 9], [0, -6, 0, -4, -82, -73, -2, -3], [-2, 0, 43, 20, -2, 43, 40, 0], [-64, 8, 12, -14, 0, 0, 14, -8], [-56, 6, 92, 0, 0, 0, 0, -6], [16, 0, -92, 0, 8, -46, -10, 28], [62, -21, 59, -10, 62, 59, -20, -42], [-16, 6, 36, -18, -32, 72, -18, 6], [0, 8, 0, 32, -34, -108, 16, 4], [-62, 10, 40, -24, -62, 40, -48, 20], [8, 1, 54, 25, -8, -54, 0, 0], [0, 36, 0, -24, -12, -20, -12, 18], [30, 23, -40, -30, 60, -80, -30, 23], [32, 0, 34, 0, 16, 17, 3, 46], [-140, -7, 95, 12, -140, 95, 24, -14], [-24, 13, 44, 1, -48, 88, 1, 13], [0, -62, 0, 40, -56, 27, 20, -31], [34, 24, 56, 12, 34, 56, 24, 48], [-32, 6, 22, -42, 0, 0, 42, -6], [32, -10, 20, 34, -32, -20, 0, 0], [-32, 12, -56, 20, 0, 0, -20, -12], [-68, 20, 24, -24, -136, 48, -24, 20], [-6, 61, -20, 30, 6, 20, 0, 0], [-80, 0, -96, 0, -40, -48, 43, -13], [0, 6, 0, -44, 22, -159, -22, 3], [58, -3, 117, -6, 0, 0, 6, 3], [-8, 3, 26, 43, 8, -26, 0, 0], [66, 49, -64, -58, 132, -128, -58, 49], [164, 0, 58, 0, 82, 29, 25, 5], [32, -7, -5, 16, 32, -5, 32, -14], [-30, -37, -15, 31, 30, 15, 0, 0], [232, 0, 132, 0, 116, 66, -34, 13], [40, -4, -6, 40, 40, -6, 80, -8], [-150, 7, -113, 26, 0, 0, -26, -7], [44, 39, -62, -8, -44, 62, 0, 0], [-90, -33, -15, 7, -180, -30, 7, -33], [8, 35, -10, 96, 16, -20, 96, 35], [-10, -7, 88, -50, 10, -88, 0, 0], [-48, 0, -8, 0, -24, -4, 21, -10], [0, 68, 0, 60, 60, 26, 30, 34], [0, 8, 0, 72, -16, 224, 36, 4], [28, -34, -49, -20, 0, 0, 20, 34], [46, 13, 143, -2, 46, 143, -4, 26], [88, -31, -6, -27, 176, -12, -27, -31], [182, -31, 23, 7, -182, -23, 0, 0], [0, 38, 0, -60, 162, 45, -30, 19], [-188, -34, -64, -26, 188, 64, 0, 0], [0, -32, 0, -24, -208, 86, -12, -16], [184, -12, 104, -52, 0, 0, 52, 12], [-304, 0, 176, 0, -152, 88, -20, -32], [302, 29, -199, -34, 302, -199, -68, 58], [152, 0, -316, 0, 76, -158, -37, 50], [0, -26, 0, -124, 78, 53, -62, -13], [-196, 32, 10, -57, 196, -10, 0, 0], [10, 11, 94, 56, 20, 188, 56, 11], [-68, 40, 16, -72, 0, 0, 72, -40], [-320, 47, -79, 36, -320, -79, 72, 94], [48, -65, -96, 137, 96, -192, 137, -65], [-72, 0, -8, 0, -36, -4, 38, -44], [0, 54, 0, 8, -88, 345, 4, 27], [112, 38, -26, -6, 0, 0, 6, -38], [0, -24, 0, 120, 56, -6, 60, -12], [-64, -42, -89, 37, -128, -178, 37, -42], [300, 2, -106, -40, 0, 0, 40, -2], [60, 0, 212, 0, 30, 106, -60, -95], [-10, -27, -6, -148, 10, 6, 0, 0], [-402, 18, -208, 76, -402, -208, 152, 36], [390, -5, 127, 42, 0, 0, -42, 5], [0, -60, 0, 72, -138, 362, 36, -30], [-80, 28, -50, 94, -160, -100, 94, 28], [-52, 0, 186, 0, -26, 93, 41, -73], [-6, -29, 77, -111, 6, -77, 0, 0], [-320, 0, -48, 0, -160, -24, -10, 20], [0, 96, 0, -112, 530, -122, -56, 48], [310, -16, -168, 108, 0, 0, -108, 16], [360, -8, -40, -34, 360, -40, -68, -16], [14, -1, -204, -94, -14, 204, 0, 0], [0, -66, 0, -20, 414, 43, -10, -33], [298, 4, 302, -32, 298, 302, -64, 8], [56, -141, 152, -21, -56, -152, 0, 0], [-246, 17, 58, -20, -492, 116, -20, 17], [-48, 0, -426, 0, -24, -213, 125, -18], [-400, -53, -227, -60, -400, -227, -120, -106], [-400, 24, 48, -3, -800, 96, -3, 24], [-312, 0, -256, 0, -156, -128, -30, -100], [-258, 2, -405, -8, -258, -405, -16, 4], [150, 35, -467, -42, 0, 0, 42, -35], [44, 104, 152, -74, -44, -152, 0, 0], [212, 38, 330, 68, 0, 0, -68, -38], [114, -33, -151, 158, 114, -151, 316, -66], [-176, 41, 54, -222, -352, 108, -222, 41], [90, 1, -298, -104, -90, 298, 0, 0], [0, -118, 0, 164, 542, -175, 82, -59], [120, 31, -5, -116, 0, 0, 116, -31], [160, 81, -182, -23, -160, 182, 0, 0], [182, -28, -215, 28, 0, 0, -28, 28], [72, 0, 286, 0, 36, 143, 177, -88], [324, -37, -147, -72, 324, -147, -144, -74], [-16, 0, 72, 0, -8, 36, -84, -58], [78, -123, -91, -2, 0, 0, 2, 123], [0, 32, 0, -248, -238, 49, -124, 16], [744, 0, 192, 0, 372, 96, -100, 10], [312, 9, 10, 76, 624, 20, 76, 9], [-368, 0, 128, 0, -184, 64, 223, -105], [-28, 50, -330, 72, -28, -330, 144, 100], [28, 25, 209, -116, 0, 0, 116, -25], [0, 72, 0, -40, -344, 158, -20, 36], [34, 68, 397, 28, 0, 0, -28, -68], [-224, 0, -890, 0, -112, -445, 3, -20], [-296, -85, -84, -185, -592, -168, -185, -85], [-440, -122, 81, 41, 440, -81, 0, 0], [-4, 146, 252, 54, 4, -252, 0, 0], [-274, 63, -127, 3, -548, -254, 3, 63], [294, -66, -18, 68, 294, -18, 136, -132], [-56, 36, 144, 280, -112, 288, 280, 36], [0, -116, 0, 92, 4, -158, 46, -58], [210, 16, 370, 84, 210, 370, 168, 32], [390, 63, -85, 22, 0, 0, -22, -63], [224, -224, -188, 141, -224, 188, 0, 0], [158, 81, 4, 2, 316, 8, 2, 81], [368, -77, 34, -91, 736, 68, -91, -77], [288, -88, -187, 39, -288, 187, 0, 0], [-8, 0, -316, 0, -4, -158, 114, 3], [0, 110, 0, 4, 166, -147, 2, 55], [0, -148, 0, -96, -226, 251, -48, -74], [312, 62, 259, 113, 624, 518, 113, 62], [-462, 2, 446, 20, 0, 0, -20, -2], [-116, 0, 348, 0, -58, 174, -208, 153], [-18, -66, 216, 136, -18, 216, 272, -132], [128, -31, 737, 76, 0, 0, -76, 31], [0, -44, 0, 96, 510, -264, 48, -22], [608, 0, 230, 0, 304, 115, 63, 40], [-336, 112, -364, 149, -672, -728, 149, 112], [66, 19, 355, 101, -66, -355, 0, 0], [0, 202, 0, -148, -266, 3, -74, 101], [-1034, 50, -262, 76, 0, 0, -76, -50], [84, -86, 90, 4, 0, 0, -4, 86], [-1472, 0, -180, 0, -736, -90, -122, -30], [-126, 45, 65, -70, -126, 65, -140, 90], [-92, -128, 100, 204, 92, -100, 0, 0], [-642, -94, -638, -104, -642, -638, -208, -188], [-440, 73, -66, 33, 440, 66, 0, 0], [-372, -16, 506, -92, 0, 0, 92, 16], [204, 0, 274, 0, 102, 137, 291, 151], [-214, 105, 551, -66, -214, 551, -132, 210], [4, 62, 198, -281, 8, 396, -281, 62], [0, -6, 0, 40, -868, -425, 20, -3], [-90, 22, 279, -72, -90, 279, -144, 44], [-456, 166, -72, -18, 456, 72, 0, 0], [-690, 119, 197, -137, -1380, 394, -137, 119], [402, 28, 138, -236, 0, 0, 236, -28], [166, 79, 105, 102, 166, 105, 204, 158], [-196, 69, -82, 332, -392, -164, 332, 69], [928, 0, -292, 0, 464, -146, 115, 45], [0, -344, 0, 8, 222, 148, 4, -172], [480, 64, -114, -246, 960, -228, -246, 64], [212, 28, -463, -32, 0, 0, 32, -28], [220, 0, 306, 0, 110, 153, 35, 171], [90, 81, -113, 2, 90, -113, 4, 162], [-468, -96, 91, 219, 468, -91, 0, 0], [-760, 4, -374, 140, -760, -374, 280, 8], [316, 110, -84, 200, -316, 84, 0, 0], [0, -212, 0, 208, 58, 379, 104, -106], [144, 26, 208, 412, -144, -208, 0, 0], [624, 0, 44, 0, 312, 22, 17, 231], [-116, 5, -487, 84, 0, 0, -84, -5], [0, 224, 0, -176, 756, -524, -88, 112], [-900, 0, -190, 0, -450, -95, -253, 23], [-574, -47, 227, -110, -574, 227, -220, -94], [728, 26, -31, 269, -728, 31, 0, 0], [-18, 12, 589, -140, -18, 589, -280, 24], [0, -152, 0, -16, 448, -565, -8, -76], [-516, 214, 205, -179, -1032, 410, -179, 214], [916, 0, -344, 0, 458, -172, -70, 229], [-290, 26, 530, -176, -290, 530, -352, 52], [-944, 40, -36, -82, -1888, -72, -82, 40], [-464, 0, -1016, 0, -232, -508, 21, -164], [-360, -67, 110, 383, 360, -110, 0, 0], [92, 176, 60, -300, 184, 120, -300, 176], [200, 182, -425, 59, -200, 425, 0, 0], [248, 0, -304, 0, 124, -152, -272, 300], [0, -162, 0, 312, -404, -79, 156, -81], [-156, 56, 148, -110, 0, 0, 110, -56], [-168, 269, -370, 124, 168, 370, 0, 0], [0, -80, 0, 128, -132, -651, 64, -40], [462, 127, -233, -37, 924, -466, -37, 127], [-622, 118, -422, 196, 0, 0, -196, -118], [1376, 0, 404, 0, 688, 202, 10, -20], [-394, -105, -428, 158, 394, 428, 0, 0], [-1136, 0, 736, 0, -568, 368, -243, 51], [1066, -10, 624, 88, 1066, 624, 176, -20], [-578, 245, 117, -159, 578, -117, 0, 0], [0, -218, 0, 332, 758, 1, 166, -109], [62, -5, -367, -94, 0, 0, 94, 5], [0, 344, 0, -216, -682, 295, -108, 172], [-492, 59, 326, -42, -984, 652, -42, 59], [0, 108, 0, -72, -310, -94, -36, 54], [0, 64, 0, 80, 780, -146, 40, 32], [540, 28, -346, -154, 1080, -692, -154, 28], [84, -10, 1061, 68, 0, 0, -68, 10], [1136, 0, -138, 0, 568, -69, 231, -12], [384, 3, -567, -36, 384, -567, -72, 6], [-616, 0, 484, 0, -308, 242, 178, -43], [0, -250, 0, -80, -980, 121, -40, -125], [830, 80, 65, 20, 830, 65, 40, 160], [632, -189, 590, -228, -632, -590, 0, 0], [570, 150, 140, -172, 0, 0, 172, -150], [-728, -78, 226, 146, -728, 226, 292, -156], [8, -147, 590, 20, 16, 1180, 20, -147], [324, -364, -130, 182, -324, 130, 0, 0], [-1808, 0, -364, 0, -904, -182, 29, -81], [0, 264, 0, -8, -1050, -416, -4, 132], [498, 53, -571, -62, 0, 0, 62, -53], [-56, 154, -488, 224, -112, -976, 224, 154], [1478, -49, -151, 6, 1478, -151, 12, -98], [392, 0, 664, 0, 196, 332, -242, 70], [-116, 74, 176, 524, 116, -176, 0, 0], [0, -144, 0, -400, 202, -642, -200, -72], [626, -63, 57, -55, 1252, 114, -55, -63], [-932, 0, -440, 0, -466, -220, 182, 173], [472, 111, 302, 606, 944, 604, 606, 111], [-774, 155, 266, -136, 774, -266, 0, 0], [-406, 72, 1156, -52, -406, 1156, -104, 144], [-232, 75, -745, 112, 0, 0, -112, -75], [240, -136, -566, 76, 0, 0, -76, 136], [972, 0, -198, 0, 486, -99, -221, -109], [44, -171, -761, 0, 44, -761, 0, -342], [744, 121, -6, -117, 1488, -12, -117, 121], [-182, 35, -389, 195, 182, 389, 0, 0], [0, -186, 0, -100, -970, -203, -50, -93], [-692, 36, -535, -56, -692, -535, -112, 72], [-1012, 25, 94, -358, 1012, -94, 0, 0], [-994, -89, 7, 129, -1988, 14, 129, -89], [624, 0, -712, 0, 312, -356, -197, -11], [754, -140, -576, -20, 754, -576, -40, -280], [666, 3, -457, -154, 0, 0, 154, -3], [184, 148, 52, -499, -184, -52, 0, 0], [-360, 35, -394, 401, -720, -788, 401, 35], [4, 40, -513, -269, -4, 513, 0, 0], [-1024, 0, 616, 0, -512, 308, 212, -310], [498, 16, 696, -44, 0, 0, 44, -16], [320, 158, -45, 93, 640, -90, 93, 158], [62, 76, -896, -136, 0, 0, 136, -76], [838, -35, -757, -162, 838, -757, -324, -70], [1376, 0, 124, 0, 688, 62, -117, -305], [-144, -20, -326, 120, -144, -326, 240, -40], [528, 89, 50, -147, -528, -50, 0, 0], [0, -112, 0, 560, 324, -612, 280, -56], [472, -211, -278, -269, 944, -556, -269, -211], [-304, 0, -236, 0, -152, -118, -308, 347], [0, 298, 0, -276, -330, 7, -138, 149], [-376, -36, -336, 84, -376, -336, 168, -72], [0, -32, 0, -328, 1110, 16, -164, -16], [492, 0, -856, 0, 246, -428, -38, -131], [428, -340, 552, -100, -428, -552, 0, 0], [504, -82, 64, -92, 504, 64, -184, -164], [504, 4, 62, 590, 1008, 124, 590, 4], [92, 184, -306, -41, 184, -612, -41, 184], [2144, 0, -864, 0, 1072, -432, 394, -330], [0, -30, 0, -400, 896, 351, -200, -15], [110, -56, -1074, 32, 110, -1074, 64, -112], [948, 178, 350, 118, 0, 0, -118, -178], [-332, -199, 46, -38, 332, -46, 0, 0], [12, 102, -283, -43, 24, -566, -43, 102], [-546, 86, -778, -68, -546, -778, -136, 172], [-1084, -40, -136, -28, 1084, 136, 0, 0], [0, 58, 0, -588, 386, 145, -294, 29], [-590, 11, 168, -438, -1180, 336, -438, 11], [-730, -112, -1172, -80, 0, 0, 80, 112], [-358, 195, 397, -379, 358, -397, 0, 0], [2728, 0, 8, 0, 1364, 4, 156, -68], [-384, -108, 855, 427, -768, 1710, 427, -108], [476, 0, -296, 0, 238, -148, 354, -571], [24, -326, -28, 250, 48, -56, 250, -326], [-224, 0, 264, 0, -112, 132, 339, -574], [0, 246, 0, -716, 762, 253, -358, 123], [-416, -186, -1276, 36, -416, -1276, 72, -372]]
