
# q-expansion of newform 1014.4.a.e, downloaded from the LMFDB on 30 May 2026.

# 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 = 1014
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], [-4], [-4], [-2], [0], [-6], [36], [-20], [-14], [152], [258], [-84], [-188], [-254], [366], [-550], [-14], [-448], [-926], [-254], [1328], [-186], [336], [-614], [-1606], [208], [-248], [542], [-2042], [-488], [1744], [828], [-404], [-2928], [-1944], [3590], [2284], [-3174], [-1358], [708], [-546], [-3472], [310], [-1020], [-3256], [-4564], [72], [-2694], [-5922], [-5122], [-5022], [1218], [-2112], [2814], [-4044], [-1470], [1844], [5766], [7468], [1228], [-6608], [-7664], [-2340], [6710], [-4164], [10072], [2990], [6564], [674], [10732], [4842], [-6280], [6434], [9068], [-3162], [-3666], [-11054], [5328], [12074], [13584], [7406], [10134], [9406], [4088], [-5328], [-13160], [9146], [-5580], [-14788], [12376], [-834], [13192], [16568], [10136], [10412], [4180], [-14610], [-2172], [11758], [340], [3768], [-10172], [-5506], [2340], [20094], [7118], [10328], [-19732], [-12026], [17016], [-11654], [-11612], [-4024], [1088], [-7078], [-8336], [32], [-15822], [21540], [-8270], [8482], [2550], [31534], [-33832], [19422], [1894], [-20156], [11128], [-16202], [5328], [20482], [8040], [-15822], [1452], [-32298], [-18736], [40816], [4518], [-5058], [22564], [-32584], [-9288], [-20586], [-46118], [39230], [18674], [41678], [-14740], [24982], [-1134], [34950], [-3068], [-14080], [-24876], [51456], [-31032], [-50820], [5982], [20224], [-8478], [40918], [4624], [15300], [-19584], [17582], [47904], [-44578], [31570], [-7358], [15882], [-30], [-31492], [-47206], [-8112], [-45982], [15208], [34768], [-8288], [19850], [-34860], [66404], [-20798], [11384], [41962], [25214], [-27482], [-21636], [-57566], [-25302], [37114], [-32178], [-8396], [39440], [59612], [33702], [-62066], [11434], [10016], [-12712], [-36924], [65792], [358], [-57926], [-9830], [-79626], [-55072], [68808], [-19272], [-90876], [-9250], [-64530], [37088], [-7778], [47694], [86222], [-66896], [-52118], [54490], [25824], [-37298], [-22172], [4104], [-20296], [69816], [-97474], [-97982], [68652], [-74600], [-1398], [73222], [91948], [57948], [338], [-66532], [-32062], [-13342], [5536], [68244], [-57032], [-25746], [24316], [-2952], [-29126], [-102976], [-44148], [-78524], [-76910], [42988], [94308], [-63650], [90812], [-71234], [59078], [32138], [-99506], [402], [46924], [30654], [-51730], [6136], [15924], [-83594], [109030], [-40200], [-7580], [79804], [58028], [132648], [78618], [-10790], [-25744], [46746], [-57544], [-42082], [99132], [23306], [-34470], [-134866], [-121608], [68080], [34812], [124360], [-45974], [7104], [-39520], [129950], [-143680], [10864], [23758], [32382], [71356], [-9600], [-18958], [-47594], [63726], [85152], [-103058], [31628], [-14432], [39722], [-118996], [-73080], [100492], [-75284], [115018], [-50596], [74934], [-97970], [-60918], [1884], [-100444], [42174], [-181364], [35954], [-101674], [-47934], [-76834], [71938], [-33326], [165620], [30806], [-94290], [140320], [-90136], [-126530], [-137716], [-136152], [-3088], [183442], [-112426], [-95366], [-39352], [186702], [-122180], [19262], [-40694], [110420], [-74454], [183560], [110418], [-194130], [-116864], [150520], [-188932], [-55276], [148930], [36916], [-138478], [-98754], [-75040], [34994], [16296], [149624], [88146], [-176538], [90138], [211962], [142038], [70014], [209882], [-97494], [58252], [-148726], [-12292], [-143846], [119388], [93752], [119418], [-109968], [79060], [99482], [71190], [-246936], [32694], [21966], [177288], [50398], [207466], [-82166], [-54360], [35252], [25980], [-205976], [-22468], [-108474], [66180], [118898], [174196], [49516], [161874], [-258368], [202806], [40052], [-196590], [205750], [-41580], [79690], [15420], [-136788], [202394], [255586], [78284], [89056], [-256260], [218672], [31142], [-122112], [160088], [-206442], [24466], [232374], [127204], [93724], [225218], [-204930], [140202], [-132416], [152904], [230484], [-218342], [203498], [-286422], [-253680], [159166], [241576], [-274352], [-69840], [-288604], [-218752]]
