
# q-expansion of newform 525.6.d.m, downloaded from the LMFDB on 06 June 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 = 525
weight = 6
poly_data = [153664, 0, 47104, 0, 4400, 0, 121, 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, 1, 0, 0, 0, 0, 0, 0], 1], [[0, -267392, 0, -46126, 0, -1475, 0, -13], 2352], [[-19664, 0, -3496, 0, -113, 0, -1, 0], 24], [[-20384, 0, -3520, 0, -113, 0, -1, 0], 24], [[0, 5614192, 0, 959768, 0, 30589, 0, 269], 4704], [[0, -1505444, 0, -259705, 0, -8294, 0, -73], 588], [[392768, 0, 67636, 0, 2159, 0, 19, 0], 48]]

hecke_ring_character_values = [[176, [1, 0, 0, 0, 0, 0, 0, 0]], [127, [-1, 0, 0, 0, 0, 0, 0, 0]], [451, [1, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 1, -4, 0, 0, 0, 0, 0], [0, 0, -9, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 49, 0, 0, 0, 0, 0], [46, 0, 0, -15, -11, 0, 0, 13], [0, -23, 159, 0, 0, 3, -26, 0], [0, 5, -35, 0, 0, 27, -6, 0], [704, 0, 0, 49, -74, 0, 0, 0], [0, 184, -773, 0, 0, -82, -66, 0], [-207, 0, 0, 33, 110, 0, 0, 148], [-2409, 0, 0, -39, -81, 0, 0, 303], [0, 585, -3930, 0, 0, 447, 375, 0], [-3851, 0, 0, -39, -1531, 0, 0, -69], [0, -628, 2397, 0, 0, 360, 29, 0], [0, 1226, -6540, 0, 0, -184, 357, 0], [0, -575, -2611, 0, 0, -885, -381, 0], [-2079, 0, 0, -426, -535, 0, 0, -929], [-14865, 0, 0, -27, -753, 0, 0, -195], [0, 4783, -38868, 0, 0, 267, 22, 0], [2160, 0, 0, -1365, -8297, 0, 0, 671], [0, 6610, 7546, 0, 0, -2472, -1019, 0], [-39514, 0, 0, -812, 7885, 0, 0, 1011], [0, -3769, 31467, 0, 0, 4001, 1305, 0], [1642, 0, 0, -1509, 1656, 0, 0, -262], [0, -676, 13114, 0, 0, -636, -3538, 0], [-75728, 0, 0, -3033, 2180, 0, 0, 3330], [0, 19331, 44871, 0, 0, 1707, 938, 0], [0, -9302, -48822, 0, 0, 946, -2634, 0], [35036, 0, 0, -1695, -9381, 0, 0, -2025], [0, 25217, 1530, 0, 0, -5443, -1248, 0], [0, 15641, -49858, 0, 0, -2031, -4138, 0], [23044, 0, 0, 2649, -15304, 0, 0, -3342], [0, -7522, -39968, 0, 0, -3798, 11688, 0], [4828, 0, 0, -3077, -49316, 0, 0, -2538], [29029, 0, 0, -195, -40892, 0, 0, -5138], [43070, 0, 0, -10712, -28283, 0, 0, 7635], [0, 43774, -45382, 0, 0, 7950, -5654, 0], [0, 15035, 214783, 0, 0, -5949, 10937, 0], [0, -19848, -27754, 0, 0, -8026, -13671, 0], [0, -16270, 207416, 0, 0, -3092, -3327, 0], [26682, 0, 0, -7710, -43018, 0, 0, 3334], [-374962, 0, 0, -10691, 2590, 0, 0, 10176], [-153413, 0, 0, -23619, 62299, 0, 0, 5869], [0, 16749, 256198, 0, 0, 4407, 8019, 0], [0, -22458, -32461, 0, 0, 13676, 30009, 0], [381336, 0, 0, 24544, -73976, 0, 0, -6720], [89877, 0, 0, 2085, -91791, 0, 0, -8421], [0, -49399, 197611, 0, 0, -8643, -7180, 0], [0, 16255, -149373, 0, 0, 6535, -5982, 0], [376982, 0, 0, 31450, -66836, 0, 0, 6276], [0, 31853, -120332, 0, 0, -12267, 5058, 0], [-118144, 0, 0, 13806, 118040, 0, 0, -37684], [-468234, 0, 0, 24577, -30188, 0, 0, -19374], [-833957, 0, 0, -8370, 201493, 0, 0, -11861], [0, -23625, -673931, 0, 0, -24497, 12501, 0], [0, 166694, -696161, 0, 0, 35016, 19956, 0], [-194022, 0, 0, -32178, -1136, 0, 0, 15332], [263408, 0, 0, -19155, 111510, 0, 0, 55356], [0, 76460, 311450, 0, 0, 16392, -17944, 0], [253744, 0, 0, 45042, 175709, 0, 0, -29769], [0, 113370, -487276, 0, 0, -21690, -34212, 0], [0, -130982, -550476, 0, 0, -29528, -40659, 0], [0, 268866, -453090, 0, 0, -39624, -5529, 0], [982022, 0, 0, -33123, 42262, 0, 0, 47472], [0, 80236, 87266, 0, 0, -12618, -92189, 0], [0, 26706, -58273, 0, 0, 38924, -54849, 0], [340551, 0, 0, 47349, 244320, 0, 0, -38736], [0, 333809, -453983, 0, 0, 12411, -17689, 0], [0, 162339, 566918, 0, 0, 23765, -19275, 0], [1035799, 0, 0, -74218, 51809, 0, 0, 49293], [0, 16548, -1907942, 0, 0, 4528, -32508, 0], [-233307, 0, 0, -66816, 22850, 0, 0, 48208], [0, 169221, -97625, 0, 0, 17391, 132741, 0], [0, -199797, -899788, 0, 0, -64971, 114255, 0], [1250687, 0, 0, -6947, 107866, 0, 0, -126762], [0, 50042, -2342092, 0, 0, 35704, -47145, 0], [-741922, 0, 0, 165426, -83367, 0, 0, -156749], [0, -72539, 243479, 0, 0, 76377, -51743, 0], [879572, 0, 0, -54336, 476345, 0, 0, 126275], [3403310, 0, 0, -12703, -44008, 0, 0, 5802], [-864761, 0, 0, -93117, -193665, 0, 0, 36899], [348410, 0, 0, -194685, 225261, 0, 0, 130569], [4294475, 0, 0, 17151, 330311, 0, 0, -97651], [0, -155182, -1546970, 0, 0, 101166, -30868, 0], [1204041, 0, 0, 180804, 405993, 0, 0, 82539], [0, -1103676, 955632, 0, 0, -105552, -5730, 0], [279520, 0, 0, 57678, 183229, 0, 0, 138139], [0, 31564, -3322743, 0, 0, -18744, 53938, 0], [-1847344, 0, 0, 10449, 77190, 0, 0, -110036], [0, -214868, 447400, 0, 0, -53628, -157538, 0], [0, -127231, -3541639, 0, 0, -15053, 100833, 0], [-884132, 0, 0, 58593, -600402, 0, 0, 75776], [0, -246905, 2015242, 0, 0, 69495, 148126, 0], [452426, 0, 0, -17475, 540509, 0, 0, 156113], [2389841, 0, 0, -38899, -209167, 0, 0, -200781], [0, -157556, -2747614, 0, 0, -267516, 114630, 0], [430300, 0, 0, 108045, -353294, 0, 0, -172004], [3011727, 0, 0, -82803, -1067995, 0, 0, 107935], [0, 1005268, 1818332, 0, 0, -41556, -42020, 0], [-1277152, 0, 0, 13367, 580271, 0, 0, -80733], [0, 67304, -2068571, 0, 0, -49596, 44753, 0], [0, -227325, -5190374, 0, 0, -148529, 258294, 0], [0, -690221, 2355375, 0, 0, -224675, -168567, 0], [-3976714, 0, 0, -168396, -113599, 0, 0, 37787], [3663281, 0, 0, 73537, 915622, 0, 0, 237726], [0, -1464564, 1209190, 0, 0, -155994, -170463, 0], [0, -748161, -1510375, 0, 0, 139763, -325968, 0], [0, 540510, 1573270, 0, 0, 119314, -235176, 0], [-1170191, 0, 0, -265806, -1937136, 0, 0, 130838], [-1249676, 0, 0, -313874, -1394864, 0, 0, 56808], [0, -315474, -382424, 0, 0, 14820, 346737, 0], [0, 1400595, 7408174, 0, 0, -141915, -6573, 0], [0, -1517715, -2827454, 0, 0, 119881, -100068, 0], [4295582, 0, 0, 136473, -706356, 0, 0, -332634], [3550150, 0, 0, 164984, -829429, 0, 0, -487071], [9282990, 0, 0, 150540, 981451, 0, 0, 201089], [0, 21062, 2695322, 0, 0, -53370, -218230, 0], [0, 841364, -3716122, 0, 0, 89320, 217644, 0], [0, -1059188, 7833338, 0, 0, 30144, 141510, 0], [-14187406, 0, 0, -178746, 452502, 0, 0, -79814], [-2122734, 0, 0, 9869, -287080, 0, 0, 353454], [0, 945667, -3220153, 0, 0, -662595, -85733, 0], [0, 2038570, -7567652, 0, 0, -113266, -297012, 0], [0, 889413, 15346362, 0, 0, 221919, -47817, 0], [6247298, 0, 0, -404416, -1020514, 0, 0, 503562], [-2437537, 0, 0, 111765, -700297, 0, 0, -678781], [2070592, 0, 0, 242102, 1471874, 0, 0, -246594], [-11025634, 0, 0, -168348, 1478282, 0, 0, 57098], [0, 495611, -9547631, 0, 0, -61053, -310570, 0], [0, 2013357, -7077103, 0, 0, 235485, 304377, 0], [-8131601, 0, 0, -49253, 1185916, 0, 0, -227400], [0, 332289, 4275829, 0, 0, -132119, 320715, 0], [-2022304, 0, 0, -749438, 1385284, 0, 0, 402888], [0, -2409099, -3275130, 0, 0, -290889, -183051, 0], [12681914, 0, 0, 175104, -1353886, 0, 0, -70414], [12469036, 0, 0, -505430, 509752, 0, 0, -129492], [0, -264810, -8081704, 0, 0, -19822, -535626, 0], [0, -4107170, -1708986, 0, 0, -319752, -397445, 0], [0, -2105438, -20895750, 0, 0, 208840, -121275, 0], [3423080, 0, 0, 693210, -60059, 0, 0, -244089], [5144706, 0, 0, -50752, -4271992, 0, 0, 500532], [-887034, 0, 0, 676368, 1008172, 0, 0, -391924], [0, 134255, 9298346, 0, 0, -487077, -587470, 0], [0, -2025773, 7467690, 0, 0, -789695, -263391, 0], [9125579, 0, 0, 21520, 565291, 0, 0, 313215], [10884104, 0, 0, 635361, 1820208, 0, 0, -379658], [0, 571305, -12614951, 0, 0, -531075, -133581, 0], [0, 968502, -11062538, 0, 0, 997258, 954564, 0], [8139800, 0, 0, -258464, -2170982, 0, 0, 755358], [0, -795689, 2074604, 0, 0, -221451, -310479, 0], [0, -351442, 7130040, 0, 0, -1165446, -777430, 0], [-5222035, 0, 0, -834015, 1909219, 0, 0, 1078197], [0, -1659352, 3409839, 0, 0, 218232, -455299, 0], [0, 834286, 24592070, 0, 0, 381666, 190140, 0], [0, 1701849, 7399913, 0, 0, 507225, -570417, 0], [2910305, 0, 0, -1184574, -1478550, 0, 0, 981388], [4298132, 0, 0, 573808, -3599801, 0, 0, 480621], [9105195, 0, 0, -580740, -1467273, 0, 0, 795387], [0, 664634, -15194114, 0, 0, 1095402, 1351388, 0], [-3655520, 0, 0, -569922, -2918226, 0, 0, -31738], [0, 2980984, 16176408, 0, 0, 172180, 514680, 0], [0, 784043, -497176, 0, 0, -1075973, 230592, 0], [0, -1391372, 841092, 0, 0, 1308192, 880360, 0], [20399208, 0, 0, 462675, -1167546, 0, 0, -564480], [0, 3143101, 20461190, 0, 0, -852039, 282144, 0], [0, -3543010, 3110904, 0, 0, -359770, 812280, 0], [28812856, 0, 0, 775042, 3463813, 0, 0, 374847], [0, 1214904, -15164822, 0, 0, -241890, -1047273, 0]]
