
# q-expansion of newform 1911.4.a.f, downloaded from the LMFDB on 19 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 = 1911
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], [3], [12], [0], [-36], [-13], [78], [-74], [-96], [18], [214], [-286], [384], [524], [-300], [558], [-576], [-74], [38], [-456], [682], [704], [888], [1020], [-110], [990], [-1208], [996], [-1402], [1926], [-988], [2100], [-2496], [2464], [216], [-898], [1510], [-394], [-84], [-1194], [3156], [1078], [3192], [722], [2796], [340], [-1924], [-5042], [2676], [2410], [3726], [1248], [4210], [7692], [-1326], [-6048], [-6474], [-5978], [8750], [8976], [592], [4608], [3166], [-2472], [3094], [2316], [-4426], [866], [-2556], [11014], [9720], [-2988], [2068], [902], [12818], [1332], [3054], [-11162], [-14820], [9682], [348], [2486], [-1812], [6226], [12544], [-8556], [4116], [-6514], [-10500], [-5542], [5220], [-11592], [12170], [1812], [-1330], [2688], [-5124], [882], [2320], [21422], [7040], [-8400], [-19044], [-4698], [-8728], [-2018], [-11376], [25596], [3480], [-10010], [-3764], [13610], [6408], [6694], [-27250], [-12630], [-14798], [-26232], [-30390], [-28740], [9214], [16598], [8610], [804], [-2270], [1782], [-10690], [-11568], [11644], [15010], [33410], [-6504], [-13912], [-23974], [288], [-1514], [-15816], [-10154], [17442], [-8778], [430], [-32976], [-1168], [-17172], [-27146], [-30696], [-24842], [-11406], [-20540], [9108], [-24046], [-7998], [24032], [15648], [-808], [39144], [-38248], [54264], [-12206], [-17664], [-51984], [13782], [14618], [18708], [-48804], [44736], [-21004], [-9038], [59726], [-18258], [-31884], [-34706], [16920], [50582], [45520], [4950], [-11230], [25920], [16216], [-57134], [-3670], [-53004], [50474], [32148], [7644], [34698], [-33262], [22246], [1910], [-47820], [11842], [-16968], [-14416], [60552], [-23316], [-65982], [-36430], [-38554], [-68124], [-40176], [-60372], [41308], [10834], [5218], [-56184], [-12534], [-60266], [40932], [19836], [-73208], [80174], [63570], [-55744], [26364], [78228], [29086], [53696], [-19410], [-80904], [71304], [-85570], [-39890], [7620], [63146], [6180], [6374], [-23274], [-10536], [94228], [-30768], [11234], [69568], [69302], [61746], [95632], [33648], [-32870], [5712], [9036], [26040], [-22248], [-95096], [68416], [118730], [-8028], [44808], [102670], [10968], [-40030], [106440], [-109042], [-60072], [10608], [123190], [-52194], [-24612], [34238], [-51266], [-46566], [85390], [13268], [19332], [-254], [72970], [56700], [-15284], [-95460], [-21648], [103826], [83610], [29302], [82982], [23794], [60752], [-94250], [18250], [-35748], [6050], [-127510], [-110148], [123216], [-143998], [109392], [35566], [-24986], [45072], [-73762], [-122376], [-33014], [45042], [20862], [61764], [38964], [-39168], [132266], [-81798], [-28172], [-67950], [-134988], [134494], [31174], [-77004], [-17728], [146508], [52256], [14006], [-87540], [-69590], [8832], [134606], [-105936], [117276], [-98178], [84908], [66828], [88846], [-9564], [150540], [-123662], [2514], [-90884], [-67966], [48642], [14222], [52428], [128770], [97166], [-139430], [-112104], [-110118], [104582], [27978], [5488], [156900], [-9070], [41544], [-166318], [52368], [136690], [21688], [100586], [-127722], [-29472], [175016], [93948], [-206676], [96802], [-108106], [-152748], [225618], [73978], [129998], [-129336], [36700], [-63790], [119034], [-76716], [1428], [-137730], [104196], [-83446], [171054], [-50304], [144828], [-158204], [-168298], [30684], [-164986], [-31282], [126924], [207988], [-184188], [17310], [-113888], [111206], [-151440], [-102192], [-209234], [85542], [-158006], [-205248], [63288], [124418], [79860], [-244766], [76512], [15230], [84238], [-95686], [-210384], [-65698], [73656], [84348], [-94628], [-150060], [-73978], [5794], [193398], [-61324], [-180276], [-259130], [-280974], [182378], [-46788], [121956], [-84224], [-247354], [-222420], [8566], [-32364], [140830], [36126], [-111228], [135452], [71714], [-22662], [-282768], [-117776], [6348], [183888], [10674], [42838], [-253080], [-162708], [-293906], [-111384], [-110148], [292356], [-235550], [80976]]
