
// Make newform 1176.4.a.ba in Magma, downloaded from the LMFDB on 17 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1176_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_1176_4_a_ba();".
// 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_1176_4_a_ba();".
// 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 := [2922, -177, -152, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-1158, -213, 7, 2], [6297, 942, -98, 2], [-3348, 677, 77, -8]];
    Rf_basisdens := [1, 105, 105, 35];
    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_1176_a();"
function MakeCharacter_1176_a()
    N := 1176;
    order := 1;
    char_gens := [295, 589, 785, 1081];
    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_1176_a_Hecke(Kf)
    return MakeCharacter_1176_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, 0], [-3, 0, 0, 0], [-1, -1, 0, 0], [0, 0, 0, 0], [3, 2, 0, 1], [-6, -4, 0, 1], [-25, -3, -1, 1], [7, -3, 1, 0], [23, -3, -1, 1], [-18, -6, -1, -3], [-57, 7, 0, -5], [140, -14, -2, -1], [-106, -14, 2, 0], [-65, -15, 3, 4], [17, 25, -1, 5], [1, -11, -2, -4], [-68, -3, 3, 8], [68, -36, 2, 4], [33, 5, -7, 2], [-211, -31, -1, -3], [54, -4, -2, -1], [441, 25, -4, -5], [-862, 27, 1, 0], [86, 34, -8, -8], [151, 90, -4, 5], [468, -12, 10, -4], [625, 25, 7, 0], [804, -15, 3, 0], [502, 12, 2, 13], [773, -47, 1, 23], [83, -25, -4, -31], [787, 64, 10, -23], [1284, -132, -10, -18], [-967, 37, 9, -6], [720, -20, -6, -18], [332, 36, 25, -17], [1776, -76, -8, 18], [1340, -62, 12, 34], [-1671, -93, 11, 31], [-813, -93, 1, 21], [885, 21, 13, 19], [794, -158, 4, 3], [-123, -87, -39, 19], [1775, 78, -10, 8], [1351, -121, 13, -7], [1714, -2, 6, 2], [102, -104, -8, 78], [296, -144, 9, 7], [-107, -148, 34, 27], [110, 6, -28, -69], [1921, -65, 21, 21], [-1186, 140, 26, -10], [2413, 80, 10, -17], [-3330, -61, -27, -6], [-3391, 69, -41, -3], [-310, 186, 0, 16], [-852, 224, -45, 19], [4596, 52, 27, -27], [892, 48, 18, -105], [2347, 87, -15, -19], [-2437, 185, 15, 78], [-1986, -90, -27, 63], [1499, 121, 5, -54], [364, 380, 32, -38], [-149, 212, 0, 82], [-2190, -150, -21, 33], [2165, -279, -57, -24], [1827, 570, 18, -106], [-4403, 197, -47, -151], [6944, -86, 18, -62], [-2887, -111, -43, 35], [-2556, -102, -18, 96], [-913, 99, -46, 27], [-1214, 82, -12, -129], [-1691, 13, 27, -92], [2819, -287, -67, -41], [2067, 83, 9, 143], [-1498, -322, -32, -147], [-3105, 255, 15, -45], [2261, 4, 0, 162], [-938, 62, 42, -152], [3414, 2, 118, 43], [-1105, 251, -1, 117], [7208, -306, -120, -57], [5672, 556, -1, -11], [-3982, -607, 63, 154], [2167, 373, -65, 31], [-321, -568, 28, -158], [3944, -652, -62, -194], [4127, 219, 21, 42], [2165, 145, -35, -145], [3685, 61, 115, 155], [-11885, 243, -52, -185], [-5773, -338, 32, 79], [-2505, 423, -25, 26], [3766, -460, 86, -42], [-8989, 163, -86, 122], [-1348, -486, -42, -152], [131, -1059, 65, 90], [-6992, -832, 24, 229], [162, 164, -118, -132], [-1950, -538, 217, 61], [-2132, -471, -21, 214], [-2196, 314, 180, 52], [-8347, 823, 129, 122], [9809, 716, -88, -84], [1, 336, -22, 305], [-5076, 1318, 112, -68], [8010, 36, -92, -150], [11041, 184, -36, 156], [-2313, 391, -138, -101], [-16856, -482, 60, -16], [3378, -432, -200, 80], [-3827, 535, -123, -98], [8754, 598, 109, 3], [-189, 185, 5, 291], [4553, 1153, -43, 138], [9790, 814, -32, -90], [-13228, 1288, 35, 75], [-9915, -363, 53, -39], [-2660, 252, -156, 69], [-2601, -1502, 38, 184], [-13220, 1716, 189, 143], [9742, -173, 257, 434], [-10313, -597, 17, -308], [-783, -111, 82, -240], [502, 16, 120, -88], [10360, 174, 154, 166], [4785, 777, 194, -145], [8102, 1034, -262, -115], [5321, 1029, -15, -292], [-1838, 820, 60, -108], [9831, 579, 148, -35], [-8472, 392, -182, -512], [-6525, -967, -305, 153], [-4527, -506, 66, -56], [-21706, 154, -100, -66], [-948, -1786, 134, 496], [-3367, 881, -38, -248], [-2029, 527, -105, -367], [-7758, 794, -172, -88], [-18065, -901, -48, -540], [-1440, -1504, -216, 120], [-12584, -405, -223, 138], [590, -300, 36, 329], [-9674, 356, 94, 356], [-6800, -354, -368, -441], [-7390, 304, 140, 346], [1144, 614, 2, -264], [20674, 1936, -112, -188], [-1846, 1354, 70, 328], [-29037, -301, -159, 21], [19853, 501, 123, 284], [-3278, -620, -186, -542], [10801, 2307, -81, 214], [2959, 1195, 81, -31], [10747, -2601, -271, -170], [7149, -2257, -97, -293], [-32783, -1108, 260, 136], [-2355, 585, 414, -60], [14556, 1620, 152, 242], [14279, 2089, -231, -89], [2201, -855, 28, -33], [23840, 115, 325, -500], [6286, 272, -84, 228], [9945, 1245, -459, -27], [14113, 189, 292, 349], [-958, 1152, -150, -495], [-15837, 416, 152, 266], [-15438, -14, 43, -351], [19099, 260, 338, -781], [-2212, 2380, 66, 216], [19626, -2528, -202, 60], [15895, -2802, -262, 310], [-2273, -1413, -350, -671], [-31966, -90, -26, 58], [20897, -1533, -107, -400], [-16965, -1917, -50, 26], [-3714, 602, -498, 330], [27296, 788, -52, 593], [4995, -1717, -62, 379], [22531, -554, -132, -385], [2798, 1408, 442, -15], [4067, 451, -107, 709], [19924, -646, 78, 258], [-20918, 1454, 199, -283], [-102, -1562, 316, 330], [19007, 811, 115, -138], [26197, -30, 158, 252], [5818, 296, 74, 190], [24301, 790, 14, -282], [36830, -125, -63, 156], [-6828, 1534, 264, -338], [-23493, 523, -247, -471], [-1526, -343, -769, -142], [-10560, 2348, -98, 414], [23810, -532, 18, -537], [-31208, -1692, 74, -424], [-21910, -516, 96, 648], [4565, 829, -65, -185], [-23046, 2206, -7, -547], [-13625, -2085, 545, 420], [-15722, 1776, 172, -400], [14892, 1946, 486, 186], [38072, -296, -180, -6], [-2180, 1832, -465, 219], [-8238, -3026, 258, -450], [-8053, -2252, 70, 281], [26858, -3412, -30, -452], [-21292, -2016, 242, -338], [15776, -218, 324, -519], [27984, -2304, 321, -801], [4210, 1554, 167, 49], [5484, 2015, -467, 444], [861, -1693, -247, 207], [-16124, 1494, -400, -837], [6622, 3970, 53, -109], [1386, 1804, 42, -756], [-2177, 1673, 277, -325], [13077, 273, -193, -1111], [-43662, 3182, 296, 509], [-27777, -1305, -99, 602], [21717, -2169, -477, -457], [-13458, -2578, -185, -723], [11913, -2880, -590, 19], [2170, -554, 550, -676], [-42026, 2066, 580, 116], [26522, 1510, -30, -388], [-40011, -2223, -114, 323], [4269, 689, 53, -913], [1200, -1008, -280, 269], [-11316, -1624, -652, 492], [-8401, 819, -670, -1059], [-16442, 2230, 760, 250], [1117, -931, 313, -686], [-39351, -1165, 425, -175], [23441, 1976, -344, 26], [-8814, -4906, 189, 289], [-10418, 2490, -374, -1198], [-15077, -4407, 295, -965], [-38615, 2621, 425, -609], [-36457, 923, -59, -898], [-55175, 2641, 80, -525], [-26158, -3016, -120, 132], [14390, 1132, -382, 652], [-6389, 3511, 343, -1225], [-17501, -461, 0, -291], [-10385, 911, 103, -1071], [17222, 350, -42, 1622], [-2240, -4236, 248, 476], [-43112, -370, 176, 279], [42915, 1737, -71, -873], [-36340, -2338, 306, -1134], [-8852, 4078, -44, -735], [-56250, -2994, 17, 267], [22459, 6134, 148, -1129], [-10584, 2036, 248, -35], [399, 3455, -395, 16], [54443, 2887, -390, 222], [-44505, -1444, -50, -291], [-1295, 861, 151, 96], [-5149, 3862, 776, -197], [-20134, 24, 838, 3], [15932, -2900, -786, 119], [37456, -918, -766, 222], [947, 1439, 339, -456], [-520, -64, -77, 1463], [3, 3533, -533, -1465], [24754, -1946, 350, 878], [-23700, 2740, -209, 127], [-16678, -1974, 120, -711], [-2322, -4090, -280, 1248], [-12339, -1474, 778, -362], [14271, 4399, -8, -1061], [7001, -102, -408, 511], [6510, 3862, 374, 850], [-12322, -305, -495, 896], [5880, -6682, -134, -425], [-28590, -4196, 66, 1351], [-13179, -2291, 437, 429], [-10480, 2444, -14, -1286], [-38855, 3357, -296, -2157], [-51804, 1546, 340, -392], [32286, -2306, 544, -851], [-16102, -466, 788, 1552], [-13686, 3944, 438, 1186], [42639, 584, -460, -394], [-11699, -1363, -96, -2432], [28119, -1733, 322, -503], [64173, 5513, 333, -1505], [-9394, 6810, 240, -1724], [55097, -140, 394, 529], [58605, 5669, -803, -853], [49316, -2696, -32, 1648], [12552, -1542, 1342, 115], [31068, 5932, -303, -1151], [14957, -3655, -949, -504], [26099, -1745, 801, 877], [135721, 1025, 113, -305], [-39941, -1923, 63, 1596], [-29404, 482, 650, 538], [-44504, -2376, 187, -2009], [-3834, 266, -319, 1235], [-5417, -6254, -532, -109], [61433, -6341, -111, -558], [-15032, -1586, -1008, -1677], [-54784, 5575, 993, 1134], [35894, 1112, -686, -9], [31704, 154, -270, 108], [9642, 4652, -926, 1067], [-55243, -3701, 579, 541], [35723, 5359, 53, -1233], [50720, 1118, 1072, 1028], [-40366, -1102, -110, -910], [-137598, 92, -6, 264], [-25818, -1412, -430, 575], [-4566, 1695, -443, -1820], [26701, 1187, -523, 647], [-76461, -3320, 464, 1100], [17770, 4442, 414, 1992], [-28171, -2703, -573, -304], [-19092, -7802, -288, -71], [4216, 3040, 595, -345], [69003, 2155, 1001, -470], [48100, 6268, 56, -74], [-31443, -1260, -1036, 1826], [74005, -493, 501, 1096], [23653, 3557, -259, -414], [-2288, -7886, 230, -1348], [2229, 3465, -628, 2152], [40330, -1374, 34, 163], [103955, -1397, 102, -282], [56173, 1301, 475, -1676], [-22444, 652, 776, -726], [-16785, -8601, 391, -2060], [4317, -1863, 333, -173], [15182, -2680, -202, -1370], [55666, -700, -12, -1726], [-10653, -1724, 700, 1640], [62583, -1989, -386, -587], [-15636, -992, -1548, -505], [18266, 916, 1838, 1180], [-65823, -2547, -144, -1530], [-24371, -91, -1954, 531], [80481, 5153, -242, 1442], [-21267, 6770, -268, 371], [25596, 1530, 264, -1903], [38592, 5728, 630, -234], [-68910, -2460, -816, -1816], [4312, 8392, -397, -693], [7252, -2830, -1600, 422], [-3947, -4190, 324, -2557], [-34532, 1552, 942, -536], [24870, 378, -621, 717], [7438, 610, 1518, -1007], [-100201, 657, -1423, -3199], [5221, 7353, 275, -1407], [-26268, -7903, -517, 756], [-18861, 5591, -881, -1653], [18240, -5658, -794, 614], [-35980, 6012, -238, 3016], [-54943, 2713, 261, -417], [91980, 978, -410, -1162], [128144, 4592, -264, 278], [90541, -4889, -909, -818], [118485, -8250, -652, -645], [-24850, 7066, -1000, -752], [-29677, 4499, -579, 836], [67633, 396, 694, -1489], [-58484, -4083, 443, 776], [72187, -7165, 25, -870], [-44541, 3049, -1335, -1219], [111628, -3368, 353, -1431], [-18681, 719, -1159, 424], [284, 2790, -422, -1803], [-21875, 1253, 1317, 1469], [50789, 1891, 2081, 859], [-47889, 3194, 608, 981], [108774, -2646, 340, -672], [-13286, 4152, -498, 1267], [-5305, -4145, -515, 1537], [-76900, 1310, -606, -1472], [-51898, -146, -282, -1370], [-44921, 4553, 931, -1315], [-22300, 5334, -26, -2420], [99402, 1806, -1068, -336], [-35141, 8099, 569, 2586], [151498, 762, 250, 2348], [22613, 4535, 383, -658], [-152387, 935, 413, -279], [44013, 8344, -1516, -1888], [-40288, -4288, 754, 1752], [66207, 4182, -1596, -633], [-7389, 14085, 443, -584], [-141164, 4778, -294, 1462], [-41335, 4970, 276, 2167], [-11442, 4506, -437, -3887], [21408, -10608, 514, 3316], [-12513, -6583, 157, -968], [47403, -2245, 678, -746], [40534, -8004, -74, 2578], [54367, 281, 303, 3161], [8176, -8244, -684, -2944], [55252, 172, -26, 1512], [-38478, -5762, -1031, 773], [-23005, -669, 170, -279], [-105958, -11200, 564, 328], [67736, 2422, -342, 1228], [92711, 5849, 935, 1794], [-144457, -668, -1630, 739], [85313, 1172, 1062, -841], [-57020, 688, -145, -2239], [49891, -15132, -1546, 1415], [-82732, -2554, -742, -3128], [-49846, -12140, -846, 2805], [234288, 1480, 207, 263], [13720, 6524, 1056, -2366], [210641, -2755, 343, 1380], [-15166, -10100, 938, -2252], [-146279, 6157, -341, 1499], [45439, -21, 162, 1400], [46054, 6504, -1714, -1235], [45568, -10116, -2202, -1882], [117368, -2319, 911, -1510], [95512, 12586, -1318, -1834], [202473, 3473, 959, -1807], [-103500, 6689, 2119, 58], [-124580, -9214, 868, -298], [-63728, 6224, 734, -250], [-56186, -14838, 554, 2246]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1176_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1176_4_a_ba();".
// 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_1176_4_a_ba(:prec:=4)
    chi := MakeCharacter_1176_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_1176_4_a_ba();".
// 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_1176_4_a_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1176_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-28, -256, -297, 4, 1]>,<11,R![5765844, 67916, -5395, -14, 1]>],Snew);
    return Vf;
end function;