
# q-expansion of newform 350.4.a.m, downloaded from the LMFDB on 23 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 = 350
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], [-7], [0], [7], [-37], [51], [41], [-108], [-70], [-249], [-134], [-334], [206], [-376], [-287], [-6], [-2], [-940], [106], [456], [650], [-1239], [428], [-220], [-1055], [1960], [1825], [-144], [1681], [798], [434], [-1290], [192], [1402], [-302], [-3167], [-470], [-2390], [-2631], [-2243], [52], [2462], [3159], [2060], [1738], [-894], [-4083], [377], [-2551], [74], [1888], [4997], [-3830], [-3390], [7170], [-7672], [-54], [2932], [3254], [3327], [4627], [-4083], [-4089], [-4008], [7355], [-1684], [-1460], [7514], [-2862], [-6368], [-3635], [7116], [-319], [-11652], [7748], [8680], [-1711], [1589], [-5147], [-9100], [2618], [-3695], [15779], [7238], [-2646], [5688], [-3285], [14834], [-9972], [-9096], [15867], [242], [-3558], [1473], [603], [18387], [9018], [4624], [-5876], [-8537], [-13060], [21372], [-12704], [8762], [-24764], [1811], [10548], [17439], [2451], [-7792], [-1937], [5036], [-27286], [28538], [25007], [-12130], [14385], [-2208], [22448], [8791], [-13180], [-7164], [12335], [-15436], [-19184], [32975], [-31497], [-18610], [-17508], [-4685], [-25925], [25578], [-4291], [-31528], [-23154], [13992], [-21681], [-16903], [18905], [-5571], [10894], [-30731], [1038], [7958], [-30666], [-5354], [-42890], [22950], [-2824], [-4866], [-10676], [-29856], [-1944], [-14628], [-12858], [-18324], [-14751], [-47922], [-44987], [-20356], [-27786], [-48674], [-11168], [20094], [49104], [27751], [37600], [-10911], [-6103], [-8718], [11748], [8172], [-22585], [53302], [2032], [16128], [-673], [-18783], [20540], [28496], [8324], [8548], [-32348], [24534], [-61232], [-19206], [-50110], [43885], [16841], [31480], [-41838], [-39160], [37633], [64014], [22404], [7107], [52995], [36270], [-20091], [-40187], [-55986], [2628], [-5754], [-32768], [-41704], [-12267], [-21486], [-62884], [21970], [52768], [-8378], [-48210], [30598], [-36159], [-52916], [9496], [59758], [-88730], [30736], [61982], [-57714], [-32816], [-86475], [20284], [51729], [39186], [48713], [-14201], [36001], [-77068], [-50948], [84304], [49712], [-55491], [-33367], [-39043], [-47334], [-103388], [96201], [2382], [71940], [54452], [45557], [-31970], [-35521], [79476], [3336], [24372], [-27259], [69044], [-21852], [4688], [-116642], [-35996], [-55238], [61923], [-56162], [121216], [38875], [-15461], [-63744], [91286], [2614], [70279], [-2370], [-1906], [112209], [92468], [-49726], [-38328], [-11614], [41254], [43933], [7624], [-56710], [-67283], [-23540], [11750], [-76663], [-37500], [6981], [-91195], [22504], [109114], [87025], [-131257], [-93984], [130468], [-84226], [-15730], [-116695], [-149781], [-71034], [-64374], [7256], [143778], [-28194], [76491], [-131764], [-98859], [151549], [169986], [95795], [-114612], [133373], [-130138], [-71744], [90140], [115888], [-84750], [10512], [-61497], [48522], [-118020], [-119116], [118892], [-59036], [-45533], [-84619], [7005], [-134116], [-62822], [-54966], [-68590], [38040], [-134578], [97977], [-18876], [-28234], [-58654], [17902], [-131830], [-148834], [190087], [133572], [64173], [6037], [109458], [9220], [216317], [157386], [-145622], [-70726], [-94585], [-181042], [-55584], [-97218], [-56492], [3814], [161529], [45266], [23424], [56949], [112533], [37877], [150726], [134640], [35610], [-21904], [-1678], [-159244], [167310], [-40686], [-125173], [18708], [-70252], [34977], [26028], [-82659], [176791], [43400], [-110638], [-101637], [244776], [170076], [200420], [192679], [72075], [61062], [204007], [112200], [73462], [-152666], [165934], [4506], [-193839], [-115305], [-256709], [76932], [-233389], [-165235], [55713], [48045], [81124], [62215], [-240136], [136604], [-87122], [-200797], [-157278], [150268], [2150], [173374], [149145], [-269952], [-234604], [-219366], [-128925], [164404], [-65700], [71317], [174300], [-161826], [-159188], [160670], [-90232], [297527], [269256], [102806], [-166479], [-185763], [7246], [1436], [243348], [60847], [-301635], [-37646], [1978], [-198042], [-127144]]
