
// Make newform 2352.4.a.cg 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_cg();".
// 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_cg();".
// 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 := [6, -24, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-17, 2, 1], [-16, -2, 1]];
    Rf_basisdens := [1, 1, 1];
    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, 0, -1], [0, 0, 0], [-11, 1, 2], [-20, -1, 2], [-17, -1, -3], [-67, -2, 1], [-73, 7, -3], [21, -5, 10], [-34, 5, -7], [86, 5, -4], [-78, 4, 10], [-125, 18, -15], [-71, -25, -3], [134, -20, 9], [368, 10, -39], [10, 20, -40], [199, -16, -31], [-99, -33, 21], [-332, 31, -8], [-302, -3, -45], [162, 6, -33], [-580, -48, 26], [-23, 1, -50], [-806, -12, -56], [-889, -24, -21], [-868, -6, 5], [590, 71, -118], [687, 1, -23], [-554, 19, -23], [-851, 93, -32], [1034, 34, 60], [-85, -124, -19], [1738, 2, 12], [331, -3, 120], [1564, 2, 164], [826, -154, 134], [3, 145, 31], [767, -61, 223], [2875, -15, -71], [1210, -55, 152], [635, 177, -115], [1715, 12, 54], [-429, -65, 115], [-238, -46, 98], [1222, 182, -328], [491, 133, -92], [2987, 103, -60], [-2306, 69, 120], [1369, 71, -57], [3564, 6, -168], [2851, -9, -12], [3378, -80, 271], [-2671, 35, -155], [3976, 16, 170], [2269, -91, 60], [-1735, -161, -80], [3344, -383, 142], [-1641, -1, -265], [-109, 124, -23], [-357, -47, 526], [3341, 28, -191], [1556, 94, -72], [-1313, -318, -300], [3205, -49, -126], [-2015, 378, -315], [3011, -26, -26], [2335, 39, 97], [4264, -94, 134], [-1505, 661, -319], [3836, -244, 82], [-3940, 149, -439], [4046, 57, 108], [4081, -242, 409], [-1583, 377, -495], [2339, 313, -885], [-4622, -209, 736], [-251, 17, 423], [85, -666, -168], [5454, -84, -162], [5312, 489, -204], [-179, -169, -657], [9142, -169, -130], [-11911, 527, -256], [-4330, -404, 69], [-1449, 837, -171], [-2269, -14, -728], [1650, 466, -1340], [-1283, -10, 989], [1351, -139, 93], [-1039, -303, 389], [5242, 473, -115], [-3399, 247, 262], [553, -64, 95], [-1080, -330, -240], [3098, 566, 43], [-548, -76, 858], [-1771, -260, 757], [8642, -417, 378], [3868, -400, -388], [15959, 371, 490], [7436, 464, -755], [-2066, -780, 394], [397, 300, 111], [-7895, -16, 416], [-2373, -11, 544], [12446, 28, -474], [4402, 314, -1500], [661, 820, 400], [3056, -471, -231], [4970, -116, 298], [-702, -504, -528], [-6115, 772, -413], [1531, 1041, 594], [-10279, -899, 585], [-1117, 372, 225], [68, 210, 914], [5221, 1109, -2004], [-8757, -729, -951], [-10622, 1043, -118], [-9733, 136, 262], [13067, -1007, 204], [11998, -280, 519], [-5413, -1074, 2235], [-11898, -696, -75], [2522, 548, 1076], [14644, 62, 834], [1772, -75, 2163], [3484, 1195, -1292], [-2021, -506, -1955], [-15282, 0, 384], [11278, -289, 1469], [4490, 192, -108], [11015, -1265, 1497], [3877, -984, 762], [26284, 666, -578], [-7444, -1064, -1598], [-17634, 1688, -835], [-8551, 271, -1545], [3620, -984, 186], [664, -836, -733], [-9956, -668, 1468], [-10152, -792, 1431], [10492, -1065, 282], [2460, -1328, 460], [-13232, -1107, -324], [16918, 682, -1648], [17480, 756, 606], [7910, 160, 1404], [8078, -392, -1226], [-3861, 1215, 1035], [-11243, 954, 189], [35476, -350, 488], [-28289, -684, -885], [-13401, -1533, 603], [-15299, -738, 189], [17363, 1289, -2153], [21973, 1108, -1112], [7294, -2268, 733], [25832, 1394, -2300], [-8967, -295, 2945], [9394, -1351, 2819], [13276, 1682, -1713], [-10270, -1748, -384], [28259, -2273, 1389], [12286, 2007, -1233], [-2966, -193, -1294], [1163, 298, -1208], [28469, 551, -1070], [-18431, 599, -732], [-29366, -656, -1160], [2636, -1160, -2088], [-45877, 78, -726], [-1048, -873, 645], [37974, -1058, 1054], [1861, 398, -1489], [-23002, -778, 835], [-25114, 2102, -862], [18190, -1873, -718], [-1484, 2505, -1851], [-10467, -2073, 390], [5354, 2115, -1218], [15671, 23, 2203], [-16424, -694, -2346], [-17195, 1683, 622], [-484, 22, 130], [-6571, 2296, -1001], [-36247, -932, 430], [13916, 62, -1556], [5881, 2618, -1714], [-22770, 1578, 1311], [550, -426, 1086], [70919, 7, -105], [-290, -788, 1829], [-2186, -2086, -84], [-22024, -2421, 2700], [25562, 2180, -3340], [51390, -216, -132], [20701, 461, 3429], [1391, -1749, -646], [-271, -1200, 3549], [-16910, -2384, 1888], [-176, 1778, 2414], [-9372, -982, 656], [13513, 1989, -3116], [-27958, 2330, -1378], [-24859, -2411, 6228], [-1980, 2256, -1356], [-19774, 2482, 976], [-994, -763, -358], [-36657, -2007, 4920], [-11747, -1525, -1306], [25276, 1146, 2707], [68549, 777, -325], [-10502, -2077, 3470], [-46817, 1053, 882], [-13988, 1264, -3316], [2885, 261, 2297], [-47871, 1863, -1599], [12998, -729, 4224], [35633, 1654, 3505], [2455, -1739, -2881], [6433, -4437, 2238], [-47541, -529, 3992], [61442, -996, -1710], [-55264, -60, 818], [21478, -2532, 994], [43064, -4587, 2559], [-649, -683, -3027], [18470, 1723, -3074], [-45400, -2324, 5320], [32032, -717, -147], [-41704, 3674, -2954], [5855, -1444, 1613], [-21043, 2311, -2289], [-34559, -2566, 2576], [35755, 199, 3554], [-20214, 2622, -1710], [24315, -1963, -2179], [44803, -2899, -1287], [-35317, 1916, 1343], [-18742, -2119, 5207], [17822, -2864, -2252], [6264, -3192, 4068], [38497, 3621, -4457], [-50794, -425, -3371], [40361, 1251, -4765], [-34886, 194, 1454], [80676, -420, 732], [-31348, -2175, 2952], [-2323, 2977, 1521], [-35768, 3922, -1582], [35062, -4543, 2318], [59119, 1477, 1478], [9389, 1343, 2326], [-36550, 2979, -4518], [-3097, -1618, -4045], [-38106, -2430, 855], [-23447, 1233, -7284], [45139, 1392, -3681], [-25287, -1373, -3314], [19318, -1839, -342], [5680, 1185, 1818], [28876, -6894, 2290], [-22891, -270, 1635], [-207, 4689, -684], [-53337, 5357, -4027], [79078, 1466, -1522], [48485, -2767, -2168], [-21950, 5603, -6148], [14176, 1608, -1506], [13657, 4934, -7678], [-3242, -3171, 6897], [22207, 3371, -3802], [-68986, 402, 4218], [-5494, -906, -6109], [48734, -463, -3988], [-9808, -1469, 340], [-26813, -4037, 6785], [6026, 2358, -2164], [44026, -2195, -977], [25530, 1316, 1070], [-64190, 2231, 272], [11684, -6372, -942], [55160, 2626, 3204], [43175, -3590, 2188], [63396, -672, -4755], [50240, 2943, -4299], [16299, 3849, -4431], [10604, -1084, -1382], [-385, 5525, -4652], [-53153, 2165, -579], [-19332, 5376, -1416], [82730, 1729, -3908], [-9245, 6799, -136], [-25813, -140, -5633], [48027, 259, 3619], [-32393, -275, 3053], [58211, 4926, 2961], [-56204, -542, -1346], [36721, 2801, 8460], [10615, 521, 1382], [-19731, -4573, -5206], [102529, 1120, 4159], [47858, 2879, 9482], [19684, -3508, -1725], [-2402, -3035, 6586], [-34132, -1968, -1942], [45554, 4405, 3922], [-28637, -2989, 1083], [14963, 81, 6311], [-35630, -1492, -7194], [-1442, 286, -2726], [-108780, 1084, -3884], [7696, -2049, 7752], [-78966, 2634, 2667], [26281, -5815, 1371], [6307, 5228, -5632], [31338, -3876, -318], [74453, -2718, 5397], [38906, 1993, -6722], [13689, -2679, -6324], [52129, -5598, 4017], [38888, 406, -4428], [167029, -982, 1196], [-79247, 614, -3913], [93227, -4572, 1365], [90920, 2984, 4618], [84564, -1056, -327], [98828, 781, 2344], [104678, -2774, -429], [29927, 3096, -7533], [51560, 3898, -2772], [59929, 2570, 2831], [-128985, -2039, -2651], [152, -3078, -4440], [57554, -134, 7740], [-51569, -444, 7128], [-15028, 5347, 2989], [44438, -659, 8470], [60792, 464, -5524], [-8604, 8898, -3831], [-18428, -379, -1045], [15838, -2474, 3497], [-63309, 4715, -2638], [-2072, -601, 632], [-13646, -4870, 2672], [81882, 5100, 7104], [-32767, 605, -5180], [-59638, 6862, -5582], [-58513, -1729, -11530], [18354, -1448, 2596], [7445, 1559, 998], [44636, -6365, 1576], [47865, -4949, 6049], [44785, -6637, 3453], [-14500, -8426, 3933], [-68447, 5113, 1055], [90288, 318, 7386], [34430, 2012, 4700], [-24745, 6633, 4001], [-77984, -2914, 3798], [-7144, -5554, 11704], [115991, -2064, 4443], [-94429, -6161, -2078], [7428, -8576, 6106], [53845, 4868, -10999], [-31153, 9215, -6304], [-3968, 5714, -7839], [11975, 2012, -11461], [56681, 9187, -13611], [15111, 1287, 2436], [45809, 3048, -10011], [-67570, 2995, -8840], [-106477, -1957, 1225], [101157, -1195, -2941], [-971, -9087, 11766], [-89920, -4472, 2874], [244, 3379, 5404], [-34853, 2487, -2885], [102132, 1788, 3582], [-201530, -682, -2254], [21119, -1149, -11023], [-49072, 9056, -4402], [-33520, -3240, -12562], [70045, -378, -8283], [73954, -5764, 9710], [-61193, 2076, 4503], [-13023, -6081, 11715], [-117547, -5876, 13300], [-89470, 4288, 1764], [24985, 6839, -15618], [50063, 7866, -11559], [148268, -8122, 1630], [19691, -7805, 2974], [-142963, 2419, -1730], [-76050, -3888, 11064], [125797, -1562, 7981], [-79930, 5890, -7461], [-64904, -942, -6384], [75859, -12593, 9113], [9100, 3884, -11728], [-69382, 820, -7164], [-85769, -2701, -10038], [-11608, -9125, -3887], [33938, 476, -10132], [58056, -3664, 230], [166127, 1776, 7929], [-25019, -2257, -11892], [13951, -9057, 10464], [-34211, -2177, -8896], [100029, 8011, -14948], [-97964, -2260, 830], [-48424, -3151, -8068], [65501, -1967, -588], [72800, 1942, -1800], [13055, -5280, 3123], [-56052, -6960, 14604], [-67787, 2009, 669], [-142894, -1232, 4671], [-9722, -6289, -9538], [80670, 6514, 3484], [23316, -12412, 9965], [74464, 6174, 1206], [-97595, 9167, 1233], [-225256, 3732, -2995], [11790, 11670, -8382], [-113086, 2258, -1024], [-132382, 5746, -6990]];
    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_cg();".
// 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_cg(: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_cg();".
// 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_cg( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2352_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-1236, -192, 11, 1]>,<11,R![9564, -1368, 35, 1]>],Snew);
    return Vf;
end function;