
# q-expansion of newform 1575.4.a.f, 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 = 1575
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], [0], [0], [-7], [-42], [-20], [66], [38], [12], [258], [146], [-434], [282], [-20], [-72], [336], [360], [-682], [-812], [-810], [124], [1136], [156], [1038], [-1208], [-546], [520], [1212], [-1078], [-1452], [1312], [1356], [-984], [-394], [1014], [-1996], [2392], [-2036], [-3936], [378], [222], [-2590], [-2214], [-4178], [-3060], [2666], [-1348], [-3188], [-3396], [5294], [852], [-4866], [-2050], [1152], [-6450], [1968], [3894], [7094], [3310], [-7158], [5164], [-8598], [448], [5832], [-9848], [-5616], [452], [2302], [1584], [8174], [8610], [2154], [-6644], [-7958], [3440], [12936], [14862], [-10460], [9150], [-4894], [1668], [-12418], [-15186], [5704], [-17206], [3456], [-16074], [-7526], [2274], [10024], [-2460], [-19320], [12544], [15510], [-14344], [-21384], [7134], [19122], [15640], [2846], [4444], [18552], [-16452], [-7722], [2576], [2464], [1452], [10698], [8730], [1910], [5596], [-28586], [-19236], [6734], [7184], [-510], [20752], [21072], [2892], [-750], [30062], [-15446], [-25110], [7968], [-14398], [9234], [8030], [-27060], [3724], [5668], [-16072], [-8256], [-6352], [-11558], [-7770], [22646], [-35502], [17080], [5730], [-2550], [-27538], [19242], [11752], [-28692], [28442], [-20172], [-19820], [-10290], [-31606], [23172], [15550], [-28530], [28780], [22872], [10708], [-1326], [-13696], [-42354], [-6644], [-1350], [49320], [5940], [-47216], [-12552], [46908], [-46128], [-12184], [5164], [24878], [33402], [45534], [14330], [-10650], [-23762], [12350], [-8502], [17660], [17646], [3796], [-37438], [-10064], [57048], [-34022], [-67278], [-57168], [53022], [35422], [-61616], [50366], [-59988], [71944], [-23820], [-36160], [-48870], [30000], [9162], [-51154], [-13142], [-59874], [-8544], [-55998], [76826], [-9200], [-79234], [-18936], [-68334], [-2482], [-45420], [31218], [-3958], [11914], [-58650], [-51536], [-77364], [-34092], [-72178], [-75800], [-17970], [78504], [31668], [-76642], [-81358], [9474], [14704], [-62580], [-16270], [-67122], [-16806], [48688], [-1746], [39706], [36542], [-110500], [-88974], [-29288], [39984], [-19582], [97836], [36750], [-103716], [15612], [-28474], [-60032], [32402], [15774], [-5076], [-47972], [-107028], [79796], [70596], [43270], [28398], [103068], [-66238], [-17382], [-88674], [10658], [-36164], [79866], [-13376], [45520], [-103416], [-19186], [-89264], [-3294], [-32614], [-19062], [84066], [36052], [6084], [-68830], [141964], [-57008], [80984], [-69464], [-29684], [75324], [-64474], [-87190], [26352], [-6336], [16976], [66216], [40250], [-59384], [114906], [62386], [-51096], [-96982], [14814], [-48390], [21468], [-50892], [97212], [-94718], [132210], [160526], [-31362], [-58920], [-87680], [118780], [27996], [-12220], [62736], [91568], [-94034], [85812], [94358], [39678], [81178], [156816], [83274], [82638], [98332], [102060], [94070], [104316], [8082], [-104744], [-13146], [108218], [-39494], [-55926], [41920], [-24528], [-27970], [108560], [-136532], [151524], [48312], [-70], [41652], [-179818], [150972], [-92860], [68004], [-62530], [117678], [-8386], [67444], [-15518], [152076], [48702], [-106108], [69156], [-214974], [-59362], [13372], [104964], [-33654], [-26458], [-9758], [-106062], [99088], [-4390], [189666], [137508], [150252], [-213612], [-229128], [-124382], [-172710], [-86064], [-15678], [-50456], [-177014], [-61962], [-9200], [-83446], [-117258], [101666], [-69936], [-110946], [201566], [-245594], [-153252], [22626], [16072], [136506], [42604], [63174], [47364], [-73136], [201408], [-196810], [-30192], [78896], [-74684], [101860], [-115320], [-1690], [105246], [56130], [-125768], [-22338], [-220250], [252110], [-61914], [235208], [-35118], [4394], [124188], [219328], [-144186], [226482], [-34090], [-120602], [266118], [-115292], [-59256], [277972], [-5976], [-45864], [-56068], [21526], [-22074], [-180690], [-231284], [-73638], [50952], [255558], [-71876], [-58416], [43248], [172744], [-198], [101196], [126126], [61274], [-109788]]
