
# q-expansion of newform 1232.4.a.f, downloaded from the LMFDB on 24 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 = 1232
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 = [[0], [2], [18], [-7], [11], [56], [36], [28], [-180], [-54], [334], [386], [-444], [316], [402], [-486], [282], [380], [-176], [324], [800], [1144], [-468], [-870], [-1330], [-120], [1210], [-1236], [-694], [978], [1216], [-1680], [1062], [508], [2598], [-2648], [-790], [160], [-264], [1632], [708], [902], [-1824], [2090], [-1602], [3274], [4948], [-2342], [-2064], [-1666], [4158], [-72], [6860], [150], [-2430], [-3048], [-3834], [3508], [8294], [8022], [-392], [-2748], [3064], [-4062], [-4870], [4806], [-6620], [1094], [-3468], [-8188], [-5070], [-1656], [-10166], [-2722], [5872], [-12330], [-14586], [1874], [13338], [-8200], [7362], [-11710], [936], [9038], [-1964], [-10068], [3270], [-15526], [10548], [3796], [-7122], [-2292], [-5132], [-4188], [-3848], [1068], [-6162], [-20946], [4696], [19358], [-18020], [14622], [2244], [-3258], [6604], [-16594], [19062], [-4776], [-7956], [14348], [-24488], [-19654], [2694], [-10178], [7648], [270], [-16250], [-10242], [-17322], [-11676], [-20710], [-10354], [-10920], [-27804], [25834], [-10590], [-6802], [-23010], [-4682], [-17860], [-6860], [22752], [-7364], [-34378], [27456], [7952], [-4986], [42748], [35610], [-17046], [2176], [2094], [-7328], [12492], [-37486], [17574], [9440], [-28440], [24334], [-39264], [32114], [41454], [-2876], [-13932], [19768], [-43836], [-31544], [11118], [10568], [14964], [-3324], [3906], [36448], [20526], [37434], [52194], [15220], [37664], [30842], [-13578], [-47988], [-37438], [57120], [58382], [-43382], [-32322], [-61652], [9522], [-42860], [4016], [-40784], [-20268], [18902], [9444], [-27168], [-25026], [-49210], [-6530], [-62314], [14160], [52862], [300], [1312], [33834], [-54564], [-23238], [-33730], [-22390], [-37656], [40092], [-78546], [-45608], [26966], [-31408], [-84666], [6138], [-5654], [-10956], [46290], [21202], [11942], [66270], [20032], [-7926], [-20244], [46466], [-80768], [-10920], [74484], [35622], [7586], [92716], [67950], [6856], [60216], [69626], [54918], [95016], [-98756], [29268], [-36118], [4336], [16648], [-32766], [-83018], [89028], [-26434], [91422], [69984], [54318], [-65160], [19948], [-42122], [-2230], [-12516], [-30456], [-69986], [-22542], [111364], [27336], [97478], [-108552], [46692], [-83326], [-53748], [-99588], [-49582], [15844], [-57750], [79364], [40984], [-10956], [17564], [67184], [-24990], [108286], [-56766], [106998], [48436], [-49278], [-20854], [65896], [40358], [-97784], [49160], [-81902], [106020], [-137650], [-103318], [90780], [-25776], [20140], [129636], [28664], [49660], [102612], [-78754], [-47922], [36706], [-63180], [79290], [-85194], [77886], [11724], [-130714], [-64812], [-41426], [68406], [-102636], [-41876], [116984], [50946], [115360], [-114408], [50872], [144782], [-121236], [-114550], [35112], [-107650], [179928], [27078], [-15738], [109060], [160296], [-70888], [73686], [-27192], [-7474], [12270], [172216], [-103342], [181764], [-4880], [63330], [-135718], [-182792], [-20834], [65904], [155466], [-47218], [-119430], [-48296], [-43692], [-452], [94782], [-44998], [65268], [159530], [178948], [21566], [169638], [-45096], [122560], [175638], [-81516], [-133978], [-34688], [-105624], [145854], [102364], [-7666], [-43146], [-12908], [-72058], [-50244], [81330], [-146040], [121386], [56568], [-54034], [-45780], [170256], [169788], [-107618], [177878], [-75168], [-94448], [-98134], [153624], [-28790], [-17592], [-85242], [158344], [30266], [33030], [-116184], [-165220], [1572], [37532], [-121230], [-183138], [-150824], [-33006], [21364], [-222966], [205000], [-107134], [38428], [-263766], [61310], [40038], [-58680], [-110834], [-52440], [-187306], [94876], [30618], [-38528], [105642], [-119932], [169650], [-152624], [-184470], [-31872], [102664], [281414], [133290], [170146], [25290], [15032], [182250], [259596], [49228], [-59170], [-161502], [164928], [94654], [-100854], [-249696], [255462], [-21244], [114564], [-45408], [-227518], [-139650], [22656], [167598], [-128558], [-166596]]
