
# q-expansion of newform 1856.4.a.m, 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
    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 = 1856
weight = 4
poly_data = [-22, 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, 0], [5, 1], [-15, 0], [0, 2], [-23, -5], [5, 10], [70, -14], [-30, -20], [-30, -12], [-29, 0], [29, -65], [60, 8], [140, 50], [-75, -77], [275, -37], [-245, 34], [-638, -20], [-198, -70], [-40, 108], [862, 10], [100, 32], [-827, -15], [-750, 60], [-108, 90], [940, -82], [104, 20], [-1150, -38], [20, 278], [-279, 140], [270, 192], [270, -16], [-306, -420], [-460, -304], [-98, -400], [-15, -390], [-2280, -70], [-1440, -406], [-1905, -317], [1310, 134], [-1130, 52], [-934, 170], [1051, -600], [-1770, 60], [3120, 10], [710, -64], [-1728, -10], [1907, -165], [70, 750], [-810, 798], [-3260, -30], [2695, -8], [542, 500], [1145, -360], [2353, -635], [-3585, 426], [-2735, 1039], [5306, 590], [759, -55], [1630, -504], [-233, 1180], [1870, -988], [950, -1564], [-5415, 715], [5094, -1140], [-5925, 586], [3150, 906], [1723, 1295], [-30, -386], [3930, 678], [-2405, 2130], [-3910, -1588], [1593, -555], [-4430, 1140], [-1265, -696], [-3610, 1200], [-5740, 1058], [-7196, 1420], [12135, -604], [-7573, -580], [1014, 1180], [5006, -1690], [-5462, 1410], [-2702, -740], [12200, -624], [-6714, 260], [4710, 2568], [7646, 1100], [-2350, 804], [-4998, 0], [-2870, 1776], [-5915, 355], [-13301, 925], [4900, 2706], [11071, 265], [-30, 2500], [11315, 197], [12639, 690], [597, 990], [-7800, 2800], [-6048, 20], [-19680, -74], [3150, 1896], [-465, -645], [3174, -2820], [-13616, 320], [-3210, -398], [5850, -2412], [-20695, 674], [5125, 3085], [18188, 90], [-3725, 4941], [-14095, 112], [-21420, -888], [4551, 4375], [2850, -2590], [-8226, 870], [2000, -738], [-2570, -1868], [3760, -1550], [18561, -255], [-5166, 1640], [-4695, -5216], [7830, 816], [13300, -3260], [-1488, 40], [-443, -1490], [-9611, 5070], [-1602, -3510], [4030, -3780], [20540, 2536], [5361, -3995], [5690, -184], [19534, -60], [6190, 2382], [-8842, 2060], [34414, 1010], [-15420, 3546], [570, -3050], [4410, 6114], [-4704, -1860], [24232, -4510], [-25099, -3490], [-38450, 216], [-18485, 127], [4786, -4770], [30003, -1245], [19070, 2308], [-1285, -6070], [-12449, -2995], [13710, -3174], [15435, 6482], [-7674, -2280], [31660, 1190], [-7915, -1237], [13070, 2520], [-16569, -3495], [8174, 7630], [10542, -7080], [17030, 7536], [18849, -1860], [9645, 4095], [6315, -4128], [-35765, -1629], [-19502, 6760], [12035, -3466], [-8145, 7947], [-45518, 1650], [-38760, 2180], [3631, 6110], [36940, -920], [-24428, -4670], [-8151, -5560], [25050, -4110], [-270, -1808], [-11070, 2060], [-3606, 3900], [-26824, -360], [-13338, 3330], [-2035, 2569], [-10414, 7420], [-19495, -8915], [-17205, 2415], [3930, -5512], [-12705, -10710], [20340, 3792], [-15165, -5640], [-42050, 462], [-39970, 504], [-20110, 9210], [-61556, -830], [7725, 8392], [27945, -1347], [213, 10855], [-13276, -6760], [-2670, -10920], [-17950, 4508], [-54580, 4080], [22650, -652], [-18195, 1296], [2720, 9788], [50364, 1590], [-14018, 6720], [20640, -70], [-2260, 11910], [36586, -4880], [-3045, -11928], [25197, 545], [-1350, -11658], [13125, 7170], [42959, 9765], [28280, -11238], [-22654, 9440], [-36065, -7335], [23305, 9559], [15486, -7260], [29999, -6870], [-360, 12812], [-18444, -10740], [-1040, -3752], [-16850, 7996], [64594, 570], [-86756, -2010], [-13242, 5580], [52025, 3421], [-9460, -10552], [-26050, -1700], [-34920, 5280], [53738, 2540], [-49925, 9675], [-22344, 8070], [-37700, -9792], [10224, -740], [-39546, -1120], [18456, -2220], [-29550, 2494], [1530, 456], [2150, -9390], [-40620, -1134], [3100, 3130], [-18975, -10605], [12535, 1777], [-8110, 13530], [18850, -8322], [91972, 2040], [-21330, 13416], [20466, 6990], [-11190, -8752], [-60826, -12460], [28470, 7090], [-99015, 1569], [-18450, -14374], [13005, 15870], [19995, 3345], [19696, 16460], [-43520, -3074], [-74016, 10320], [29720, 9070], [3265, -22075], [-80770, -2740], [-53735, 764], [-42750, -7804], [21265, 3571], [-23646, 15500], [44630, -6458], [33570, -4914], [6205, 14795], [-4608, -20460], [72890, 6290], [43590, 3976], [52305, -7140], [-87661, -4910], [-63890, 3182], [25445, -23340], [-62730, 4760], [-38860, -1992], [-19175, -1293], [-72150, 8040], [15055, 2460], [59652, 10000], [51866, -9760], [-88530, -10794], [-39322, -11210], [-123740, -1832], [-15930, 1040], [-67110, -12356], [-49422, 8760], [-87910, 13086], [5800, 15166], [-9272, -3690], [-25503, -23340], [79427, 5060], [12030, -1140], [9565, -5732], [-82111, 12905], [53770, -17112], [-5539, -1510], [-32329, -13325], [-56865, -9270], [37784, 16430], [-66370, 14160], [19110, -8078], [-12310, -8080], [56578, 5700], [40825, -77], [68630, 9600], [66835, 1454], [-3765, 9135], [53433, 7550], [-104036, 6070], [38115, -10792], [-69910, 22256], [-64752, 14970], [-116538, -8880], [-36970, -2736], [75240, -2358], [-39169, -2700], [57506, -22240], [57630, 4230], [-4305, 16510], [-116214, -4230], [77661, 18085], [-90725, 13346], [65786, -19840], [2875, -1059], [-69105, -13260], [13800, -9710], [64710, -15290], [-64600, -24048], [47245, -24119], [20445, -26544], [-64396, -3740], [3625, -9194], [-191824, 2320], [-15650, 26812], [92699, -16815], [-38180, 7324], [24082, 28560], [21230, 16688], [-28910, -17800], [26940, 38432], [-63090, -910], [-9910, -33820], [89038, -18110], [-20012, 13260], [14190, -8484], [165185, -745], [-194950, 2110], [38670, -11084], [135425, -17095], [-23930, 9112], [35942, -7380], [56730, 6556], [4710, 4800], [125130, -700], [14542, -17670], [51230, 10034], [49353, 10395], [70092, 19590], [-127330, -7390], [120790, -14534], [66895, -1908], [-67239, 3000], [-31455, -8739], [186606, -3390], [-153195, 13207], [-203700, 5158], [169380, 14064], [-40190, -30954], [19850, -33000], [87555, -2685], [102034, 770], [-18720, 15606], [-99450, -29760], [-16326, -5140], [14325, -3748], [113446, -14480], [68103, 39165], [151970, -5262], [-61939, 25970], [43375, 19754], [-15140, -10820], [-61365, -29226], [-6425, -34725], [1590, -30186], [-125196, 10030], [47460, -17850], [26638, 4500], [-88595, -10962], [-191325, -9029], [-67970, -26936], [129930, -4280], [-145385, -13478], [-25747, -17095], [-52925, 16505], [150925, -18785], [87595, -22318], [-224680, -6200], [-172368, -2280], [-189478, -12690], [10518, 12540], [-184790, -6180], [-14610, -54180], [7330, -4536], [149445, 28608], [-39, -18870], [-120534, 8900], [-29895, -40696], [87510, 40590], [-182735, -21181], [-97332, -18540], [5550, -8528], [-16125, 50094], [23360, -8842], [3738, -22160], [47920, -15094], [-210486, 12360], [26395, -11315], [25810, -40446], [42040, 29236], [177365, 16505], [127358, 38000], [117130, -24084], [117415, 16453], [-78453, 41565], [-122625, -4892], [-107775, 8496], [-22090, 9572], [181532, -8620], [44038, -18400], [21335, 40805]]
