
// Make newform 2352.4.a.cj in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_2352_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_2352_4_a_cj();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_2352_4_a_cj();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-126, -65, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-45, 1, 1], [84, 10, -2]];
    Rf_basisdens := [1, 3, 3];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_2352_a();"
function MakeCharacter_2352_a()
    N := 2352;
    order := 1;
    char_gens := [1471, 1765, 785, 2257];
    v := [1, 1, 1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_2352_a_Hecke(Kf)
    return MakeCharacter_2352_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..(prec+1)]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 4;
    raw_aps := [[0, 0, 0], [3, 0, 0], [4, 1, 0], [0, 0, 0], [6, -1, 1], [7, -1, 3], [34, -2, -1], [69, 5, 8], [94, 2, -7], [-28, -11, -5], [-39, 14, -1], [-113, -13, -3], [166, -18, 0], [-13, -3, 20], [-36, 18, -11], [-134, -17, -4], [94, -3, -16], [22, 32, 20], [25, -25, -6], [-16, -14, -51], [47, 33, -39], [821, 0, 15], [-32, 19, 40], [60, 70, -24], [982, 5, -13], [78, -16, 28], [481, -23, -20], [898, 9, 8], [-567, -13, 23], [188, -68, -39], [571, -100, -11], [-302, -91, -23], [-1388, 46, -46], [521, -97, -118], [-636, 62, 114], [460, -97, -49], [-618, 66, 78], [800, -52, -86], [-368, 206, 111], [-2034, -28, -117], [2752, -140, -21], [287, -49, -63], [2568, 120, 211], [2367, -22, -104], [2158, 108, 71], [2100, -88, -102], [2092, -2, -34], [932, 99, 295], [770, -213, -85], [-3225, -61, 161], [660, -184, 107], [1238, -86, -274], [1198, 237, 121], [-2786, -211, -286], [-2488, -166, 275], [2152, -54, 32], [1326, 49, -19], [-1452, -19, 21], [2965, -483, -147], [1354, 216, -349], [3289, 295, -66], [4376, 303, -359], [4815, -285, 58], [-4586, -50, 130], [-4967, 50, -98], [-2248, 273, -233], [-499, 249, -160], [1729, -72, 226], [4846, -126, 65], [698, 460, 502], [5408, 208, -3], [-2920, -102, -560], [-3213, -230, 103], [787, 163, 285], [2609, 185, 44], [-10502, 180, -49], [336, -398, -599], [-2235, 561, -145], [3282, -318, -339], [3443, -398, -42], [3366, 182, 632], [-3027, -537, -479], [4120, -284, -107], [-13103, -153, -71], [5780, 501, -395], [-9090, -37, 450], [4792, -464, 81], [7269, -66, 142], [-756, -570, -270], [-627, -1059, -26], [-4576, 476, 311], [-5454, -172, -45], [-6655, -506, 299], [7396, -783, -433], [959, 337, 938], [2330, -62, -466], [-1760, -437, 598], [1136, -786, -872], [2015, -41, -694], [2933, -745, 135], [9732, 752, -372], [-9522, -183, -637], [-8076, -945, -274], [14498, -590, 204], [127, 641, 10], [-39, 376, 476], [2348, -67, -95], [1402, 526, -1196], [-7764, 502, -246], [-16591, 940, 308], [5147, 446, 1215], [10174, 226, 488], [16362, 656, -272], [6159, -1339, -602], [-1336, 1189, 547], [-2030, -40, 1325], [8281, -837, 378], [-7118, 1628, -114], [-6090, -1023, -491], [162, -670, -495], [-127, -1077, 143], [-4525, 102, 896], [2520, -495, 1017], [-678, 213, 570], [7791, -641, -20], [-9962, -961, -2056], [-26602, -200, 64], [-234, -836, 974], [6587, -572, 35], [11659, 757, 879], [-3601, 1401, 1548], [10850, -680, -724], [799, -460, -815], [322, 936, 1944], [-5446, 1434, 535], [-3051, 994, -1328], [-5874, 480, 1354], [2388, 134, -472], [12158, -1257, -1328], [-8996, 2284, 1039], [3812, 626, 584], [-33636, -671, 572], [-13968, -200, -144], [-4080, -139, -62], [-8609, 111, -1173], [-5820, 2328, 1572], [873, -1505, -563], [-4760, 558, -346], [26756, -658, -312], [20586, 1236, 620], [-17586, 782, -288], [-11778, 820, 843], [3945, -279, 1100], [610, 622, -998], [5101, 1497, -762], [-1326, -2480, -807], [13749, 517, 106], [-1528, -502, -987], [705, -644, 560], [-16950, -381, -1212], [-6466, 254, -1566], [15118, -1180, -1639], [-23263, -1324, 707], [5050, 1703, 212], [-4546, 28, -1668], [-13430, -426, -451], [4439, -2722, 401], [-12947, 1467, 2347], [-17723, -1250, -1994], [-25136, -1559, -2281], [-8436, 235, -1149], [22418, 700, 1776], [1996, -756, 2348], [-7975, 1652, 1314], [33749, 944, 1493], [-25700, 2360, 1046], [-13067, 491, 1864], [-33428, 1739, 438], [-32812, -740, 442], [-14207, -377, -2685], [-16729, 1506, 879], [-18304, -2087, 991], [-39143, 875, -509], [-8430, 1204, 2139], [-5258, 1844, 2490], [-38036, 345, 611], [-18078, -1624, 2670], [-18749, -1055, 3054], [-13971, -1630, -20], [5102, -2210, -1578], [35627, 1164, 2090], [26960, 2167, 756], [3884, -1660, -498], [6410, 1464, 2215], [-12682, -2165, 490], [-27720, -354, -702], [17671, -967, -1703], [3630, -2236, 168], [-25946, -2628, -2760], [-9862, -64, -1025], [-33490, 225, 1667], [-55217, -785, 688], [1586, -1424, 1216], [21490, 884, -658], [-28918, -1334, -1254], [-28054, 1681, -651], [-8884, 1844, -1346], [-10046, -3943, -4215], [-8588, -440, -1180], [-5980, 1510, -3458], [36543, -3659, -97], [23188, -1419, 857], [-1404, -2393, -1583], [-35022, -2061, 1668], [-2186, 766, 887], [19297, -5509, -1611], [7440, -1839, 1803], [48492, 584, 1332], [-22742, 1248, -1021], [-23772, 1042, -1745], [-18247, 625, 1263], [36401, 441, 3206], [-12152, -3786, -183], [15592, 1599, 1397], [-15606, -425, -5069], [4278, -3874, -2388], [4612, -2310, -1924], [-16786, -494, 596], [-417, -48, 511], [-22032, -452, 1415], [-39603, 95, -937], [-44020, -1708, -2084], [-16287, -1388, -431], [36810, -8, -3098], [-24683, 2127, -174], [-6328, 1480, 2049], [13723, -3690, -3066], [6502, 3109, 1183], [-36368, -1964, 2642], [67844, 1360, -357], [-932, -1160, 1863], [-23079, 5385, 1430], [-32287, 1680, 255], [-1610, 4724, 580], [-75696, 2472, 276], [-3266, -5302, -1777], [-27497, -2668, -1679], [-33528, -2556, -1079], [-33108, -596, -490], [20944, 2288, -2740], [64481, 2959, -43], [13626, 3236, 2889], [-46610, -4072, -3782], [-14613, 245, 1423], [41024, -1109, 2413], [45688, 2721, 3863], [-24079, -1733, -2761], [25747, 951, 2632], [-6744, -4957, -1502], [11774, 651, -1997], [9413, 3533, -3924], [55272, -3339, 1419], [35755, -839, -23], [23189, -2447, -2275], [27462, 1360, -46], [14609, -1553, -5728], [21278, 1197, 2073], [-33744, -2832, -4967], [13384, -5220, -562], [-3230, 1585, 4129], [39393, -1143, -4333], [54408, 4454, -1920], [-34065, -2844, -2030], [-93583, 70, -657], [17294, 627, 2761], [-45008, -2736, 4810], [-46248, 1351, 2920], [27659, 1767, -2227], [78167, 1993, -1687], [-62586, 7422, 1557], [-22952, -1602, -5302], [124933, 1484, 2599], [27298, -1390, -5856], [19901, 6593, 959], [-75896, -130, 680], [-9922, -6286, -2902], [38865, 3610, 2594], [26348, -3053, -3280], [-13739, 6232, 1213], [-24048, -7508, 1505], [46848, 738, -1236], [45416, 3713, -3167], [8128, -2220, 6789], [29252, 4520, 6112], [-39657, 439, -551], [14438, -3601, -1329], [-69639, -2143, 1324], [-49846, -3328, 4291], [58040, 4300, -6105], [49823, -495, -2268], [-27338, 5164, 5438], [-5298, -2827, -7079], [65860, 233, -1773], [45684, 3465, 1395], [17735, 1709, -5398], [-11595, 1051, -7787], [25456, -8171, -3866], [64183, -7131, 709], [36612, -1754, -3492], [-24805, -5715, -3303], [-46186, 4204, 2917], [-7144, 9558, -487], [35518, -498, -3236], [33756, -948, -4030], [-40064, -5020, 632], [931, -4095, -1271], [-24876, -293, -1172], [-15662, -5450, -1], [23879, 1932, 2148], [-21786, -3986, -3016], [-15039, 585, -1480], [-14745, 4549, -857], [-17042, -5171, -1175], [-20131, 3357, -66], [80518, 3414, 378], [-26129, -6382, -4802], [86329, -2861, -3888], [-11311, 2663, 1122], [-41904, -5730, -3924], [-67156, -449, -3192], [-21499, 12655, 609], [-36896, -6169, -5526], [1641, 5913, 3880], [-54186, -5394, 4778], [28365, 3203, 6596], [-99988, 7704, 3419], [-23782, 8266, 6874], [-64508, -2222, -1186], [14707, -1804, -9152], [-42115, -5020, -1239], [-13073, -8963, 2653], [35000, 528, 2740], [22470, -7515, -366], [107115, 1604, -145], [-27804, 9237, 3502], [-28458, 3961, 1523], [-59285, -1071, 3235], [-27076, -10402, 3094], [-29446, 1260, 3792], [17802, 2673, 677], [88608, 3056, -3450], [37266, 2839, -9483], [38570, 152, -5008], [-41792, 2091, -3571], [-102029, -5639, 2707], [17416, 1834, -5969], [32104, 14, 5169], [110758, -7619, -3076], [52582, 3378, 9893], [15274, -12956, -6626], [3306, -148, -7032], [91340, 3260, -1087], [19338, 1984, -7618], [-41198, 3182, 1926], [117129, 4805, -2042], [-34842, 7403, -1635], [123828, 294, -960], [-1153, 10999, -1368], [39074, -11231, -3863], [199078, 2045, 4400], [12941, -2691, 3834], [119856, -8486, -2179], [-127534, -1557, 3303], [-65945, 455, 940], [34429, 5137, 2311], [-35658, 14150, -27], [-58742, 1194, 1859], [-20878, 469, -11213], [26776, 11318, -2272], [63787, 5505, 5029], [66078, -7460, -2673], [-55248, -2942, 1536], [-9396, -3028, -7938], [20502, -4266, 5427], [203264, -2014, -68], [-14936, -5634, -5200], [1653, 6773, -3754], [-47130, -5078, 1068], [35077, 10565, -1586], [40668, 6628, 793], [-129207, 6456, 3608], [146210, -648, 1616], [93684, -2895, -4809], [32631, 7861, 4400], [-28426, 56, 3870], [36898, 1643, -703], [-27140, 8927, 3745], [42254, 1340, -5124], [-13915, 6489, -720], [-18376, 7831, 10506], [-102086, -3254, -3434], [68022, -2822, -10233], [-20488, 6060, 9448], [108670, 3340, 5224], [18734, 2233, 2651], [-8839, -4688, -1963], [-49930, 16184, 640], [-185560, 830, -4220], [101025, 9659, 5026], [8848, 12075, 10787], [-119710, 3521, -2335], [178880, 5019, -5897], [-151492, 4223, 5911], [17792, -10546, -5720], [34261, -3653, 6043], [92458, -187, 4521], [-68254, -7402, -2598], [337, -5775, -3576], [59596, -6768, -2836], [140118, -1468, -4029], [42010, -11523, 80], [17641, -313, 8407], [-189496, 8826, 2614], [38616, -277, 4402], [-70962, 4344, 3714], [-8416, 11018, 11639], [39124, 2331, -13326], [-59844, 9360, 6186], [47780, 3278, -842], [-184716, 6152, -666]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2352_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2352_4_a_cj();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_2352_4_a_cj(:prec:=3)
    chi := MakeCharacter_2352_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_2352_4_a_cj();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_2352_4_a_cj( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2352_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-52, -220, -11, 1]>,<11,R![-3276, -624, -19, 1]>],Snew);
    return Vf;
end function;