
# q-expansion of newform 490.4.a.f, downloaded from the LMFDB on 22 September 2025.

# 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 = 490
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], [3], [-5], [0], [-17], [81], [91], [-102], [-90], [-129], [-116], [314], [124], [-434], [-497], [-584], [332], [-220], [384], [-664], [-230], [361], [-1172], [-40], [175], [-270], [-565], [-1206], [-1419], [-778], [316], [1750], [48], [38], [-3582], [-1927], [2510], [-1870], [2019], [-1253], [492], [4448], [3999], [4880], [4712], [-2756], [697], [707], [559], [3836], [-1368], [-3803], [-5650], [1650], [-5810], [-2758], [-186], [6828], [-8214], [6707], [5497], [-313], [-5479], [-4422], [-275], [-4106], [8260], [9946], [-8798], [1838], [-2265], [4136], [10031], [2792], [9948], [-2700], [-631], [13139], [-887], [5190], [5712], [-11155], [8499], [-5102], [-15694], [9142], [-17145], [-10184], [9152], [-1084], [-19283], [5118], [2918], [-18627], [12843], [18837], [7742], [-614], [-17836], [23463], [-1860], [10288], [2356], [-15318], [-13164], [-8959], [-16952], [-10071], [-2829], [7662], [-907], [-29646], [11006], [-21098], [21707], [11090], [995], [20792], [-10498], [-6749], [-12400], [16024], [-18735], [-12844], [-25996], [25435], [3823], [-21090], [7992], [36965], [-3305], [-2208], [-11551], [9688], [7014], [6278], [-21351], [25967], [8595], [-13671], [11986], [-12951], [-12788], [24662], [-4124], [33154], [-12050], [-15270], [12564], [12976], [-15634], [8896], [-33456], [-8288], [15398], [22656], [9149], [27272], [-44177], [2236], [-17464], [-18336], [-46802], [-45024], [12786], [-33539], [-18200], [32599], [-2483], [-53638], [17288], [42418], [-4185], [-35442], [3058], [-27148], [21787], [22497], [-29420], [12884], [48656], [-55848], [-40462], [41254], [47352], [-30294], [-46940], [-28085], [-47279], [180], [-29118], [-11330], [-587], [-40664], [-21684], [28017], [-76865], [28780], [-12261], [53803], [-22466], [-30218], [56466], [61038], [61374], [9583], [50266], [47304], [53430], [-86108], [52068], [1230], [-45908], [17551], [17046], [10384], [47542], [57420], [-55046], [-5022], [-16294], [19006], [50685], [-38514], [38119], [17126], [15143], [70499], [-44869], [64772], [-98912], [9666], [66952], [71529], [70463], [101787], [-89296], [-9232], [78701], [38918], [-7760], [61768], [-24033], [-14090], [-39111], [73374], [-28784], [51198], [-71119], [52526], [-938], [106122], [15072], [-35544], [75822], [36403], [-33202], [-16444], [-53895], [2409], [121254], [-104846], [30416], [76189], [59610], [71806], [-98391], [-19238], [-21584], [47238], [43464], [-126204], [-42497], [-131676], [44590], [-22433], [-80020], [-93190], [138777], [18830], [124091], [112265], [-35856], [-107694], [-98465], [-30717], [-87806], [-82218], [153496], [-46920], [93585], [-149051], [87304], [-120836], [-39306], [73512], [-100366], [94481], [-148236], [39091], [-15501], [-47326], [16375], [142392], [-61147], [-32742], [-163306], [-39240], [123048], [-145660], [137352], [21963], [113902], [-65590], [109326], [67408], [67686], [56427], [11091], [-74995], [-112894], [39952], [-22874], [-152580], [-43650], [107848], [-94603], [27564], [204424], [-37596], [116822], [-156540], [56654], [-59343], [-95428], [-72477], [84397], [-143742], [50330], [30007], [58174], [58012], [-38214], [-131785], [-155058], [-109844], [-153222], [17632], [-11394], [10659], [-61436], [-112764], [18729], [-176297], [-113703], [7206], [129930], [5570], [-35826], [-105582], [-138796], [225820], [-211384], [163507], [19508], [61342], [-39373], [-44918], [-5579], [-78309], [-81580], [186748], [208563], [16834], [44434], [155560], [-1881], [-190535], [-138822], [-19563], [-44050], [112618], [-165144], [134826], [-224976], [75411], [103035], [142801], [-109972], [-147559], [-83455], [-79057], [-122615], [-126276], [-27725], [-57104], [-62824], [-37648], [-129777], [-217638], [107592], [13920], [88726], [50175], [-206068], [-82666], [31646], [33015], [75324], [-77460], [-43313], [125910], [-185094], [143332], [-56650], [-256168], [-92493], [-93684], [218826], [451], [-118763], [269086], [-278346], [17932], [6597], [-57685], [-30244], [-174822], [227312], [-28676]]
