
# q-expansion of newform 882.4.a.m, downloaded from the LMFDB on 18 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 = 882
weight = 4
poly_data = [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 = [[2], [0], [-6], [0], [30], [-2], [-66], [52], [114], [72], [196], [-286], [378], [164], [228], [-348], [348], [106], [596], [630], [1042], [-88], [1440], [-1374], [34], [438], [-1676], [2022], [-502], [2016], [1784], [-1608], [-2580], [-2144], [1500], [-1240], [-614], [92], [3924], [1902], [-6], [2878], [-354], [-4858], [-396], [-1712], [-772], [-776], [1788], [-5402], [3012], [3546], [3562], [-3348], [-366], [4170], [-6078], [-2468], [-394], [-396], [1348], [-7506], [-1748], [1140], [-146], [-8148], [-9700], [8174], [-4038], [-10766], [-3666], [-5106], [5776], [8462], [6860], [696], [11136], [-10838], [-8364], [1762], [-14580], [8534], [5934], [14758], [11392], [7026], [-3384], [-4282], [-16650], [-9664], [12324], [-18660], [-3400], [2970], [-988], [-5184], [-16854], [4398], [10672], [20702], [-22876], [-12876], [6900], [14676], [380], [11806], [19188], [-690], [-20490], [11590], [6424], [-9682], [5076], [-22664], [-8584], [372], [-3188], [12732], [-3576], [11430], [-22646], [-13570], [2838], [-6558], [21832], [16200], [36722], [-13776], [-34220], [13750], [39836], [34470], [5240], [18578], [-30534], [39958], [3966], [3760], [24102], [11712], [-37424], [13452], [20432], [24390], [28510], [36972], [14074], [8826], [20500], [7674], [-8890], [-738], [20], [-39804], [29180], [-48258], [25760], [44778], [44494], [7458], [17790], [-5832], [-13264], [-3984], [-38940], [8808], [18488], [5002], [9434], [-41658], [-19050], [37546], [-50106], [-10870], [-45992], [-46242], [-2140], [26400], [-31052], [-23150], [-37600], [-46296], [-15874], [-11202], [22602], [-25554], [-44134], [20536], [59546], [-5880], [754], [-32418], [-45700], [74334], [68718], [39750], [-14434], [72038], [-64350], [50124], [-81708], [25072], [-82154], [-78950], [18936], [-21810], [9952], [-64938], [-87768], [-12332], [-13246], [-21510], [-50632], [76656], [-33852], [-67322], [-61432], [-18930], [-4926], [47232], [-24478], [-23924], [-24240], [-62872], [-45288], [3314], [25338], [-75102], [-91244], [74418], [-79270], [69028], [-86920], [7248], [46852], [-95808], [-18830], [-82092], [-48438], [-21600], [33906], [42784], [-58448], [-69838], [-29790], [23988], [-95924], [109212], [100892], [20034], [218], [24870], [-15162], [1618], [93102], [47022], [-34], [102436], [87534], [-75530], [-92320], [76770], [38878], [41578], [55158], [68632], [-115740], [87678], [55172], [-73248], [-48710], [37028], [21922], [3944], [-31790], [-69428], [-73434], [22466], [-18610], [12828], [107880], [78536], [-17496], [43738], [-150464], [75390], [129278], [3708], [-126452], [128394], [19380], [-73416], [100068], [38772], [8246], [-117642], [33568], [-6750], [-88836], [22696], [-5258], [120840], [-82528], [146358], [106076], [-142882], [-42918], [53206], [47310], [-91798], [8328], [19992], [-14484], [-24388], [-119934], [-22430], [125352], [14394], [87802], [684], [89908], [-97162], [-9810], [-97432], [-36384], [18970], [-107620], [-80804], [-88338], [182376], [79850], [64200], [203092], [126636], [146396], [-112932], [-197962], [17418], [-94142], [-31916], [-59218], [-115236], [-190494], [-96712], [-173280], [-22914], [48382], [-54268], [-36072], [109326], [168028], [74882], [-170964], [-92288], [25166], [-217602], [20496], [-64416], [-152904], [66006], [-108034], [-110958], [33582], [24846], [219832], [-41578], [-88470], [91640], [180254], [191730], [24316], [224502], [-160740], [-178508], [-144178], [-244344], [-26622], [21886], [-124170], [-132374], [-74802], [-32544], [246296], [-29832], [143440], [170232], [-222136], [-21026], [165188], [-79812], [-3454], [167970], [154974], [103300], [-243498], [125894], [138472], [-121914], [-48076], [-7080], [59218], [-157368], [25616], [199002], [-199470], [53008], [155630], [166752], [203848], [-208212], [200230], [-40512], [84762], [-279340], [-221686], [50034], [168666], [-232652], [30150], [61572], [-253896], [-6446], [185382], [219672], [-72362], [160422], [-203214], [-23364], [295288], [-297516]]
