
// Make newform 1176.4.a.bc in Magma, downloaded from the LMFDB on 19 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_bc();".
// 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_bc();".
// 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 := [142, 0, -24, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 4, 0, 0], [0, -24, 0, 2], [-12, 0, 1, 0]];
    Rf_basisdens := [1, 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_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], [-2, 0, 1, -3], [0, 0, 0, 0], [-10, 3, -1, -4], [-12, -3, 0, 23], [38, -5, -3, -7], [-56, 3, -2, -2], [-2, 5, -13, 16], [-36, -3, -12, 18], [-100, 1, 6, -6], [-76, -10, 14, 16], [38, -1, 13, 23], [40, 6, -30, 36], [-136, 5, 10, -170], [-330, 18, 20, 128], [-260, 23, -6, -126], [-224, 5, -6, -37], [-104, 6, -6, 252], [62, -27, 35, -28], [188, -26, -30, -57], [216, 12, -20, -260], [-364, -10, 64, 16], [-734, -5, 23, 369], [-36, 24, 54, -225], [-650, -10, 105, -297], [-484, -67, -2, -394], [-238, -11, 65, -384], [40, -32, 42, 940], [-10, -56, 20, -744], [660, 22, 78, -116], [-1036, -14, -24, -32], [120, 13, 14, 1422], [-452, 60, -176, 52], [-514, -22, 28, -72], [636, 6, 46, 568], [-616, 97, -90, 637], [792, 86, -6, -1360], [-664, 21, 62, -798], [-1006, -72, -109, 1145], [554, 41, 185, 424], [156, -85, 248, -479], [622, -87, -121, -1876], [474, 88, -132, 1936], [-454, -22, 40, -1728], [-1200, -200, -200, 668], [3380, -104, 60, 532], [-1736, -104, 8, 1940], [-2652, -125, -194, 1686], [-1852, -221, 252, -1523], [368, 123, -294, 1074], [-3242, 109, 75, 1168], [252, -36, 510, 941], [-2628, -31, -118, -1102], [-202, 329, 13, -381], [-5110, 47, 149, 652], [546, 230, -385, -1029], [-172, -75, -442, -1290], [-1526, 296, 148, 1392], [-1664, 171, -150, -1854], [-3384, 55, 358, -286], [126, 302, -19, 939], [-1976, -79, 546, -38], [-2832, 243, -330, -974], [2024, 34, -24, -5081], [770, 14, 452, -2048], [4084, 16, 28, -2416], [4088, -2, 284, -1884], [1758, -29, -609, -3164], [504, 289, 310, 1913], [6954, -169, -229, -285], [-3158, 39, -219, 528], [-4920, 482, -148, -1264], [1586, 572, 8, -1544], [4364, -340, 600, 5288], [5320, 120, -260, -1396], [-1332, -139, 704, 1594], [2120, 171, 122, -7565], [-16, -253, 250, 5106], [7428, -468, 306, 2919], [1060, -615, -266, -3234], [4386, 284, 20, -1304], [-3562, -259, 307, -5976], [4016, -214, 508, 421], [1256, -60, 728, -4360], [-8022, -507, -507, 4536], [1174, -276, -564, 840], [3998, -224, 216, 5392], [4354, -424, -237, -1115], [5244, 658, -586, 2760], [5348, 457, -894, 3946], [-408, 161, 290, 318], [3364, -338, -322, -4056], [-2130, -369, -493, 8744], [7648, 538, -402, 4768], [-1472, 270, 688, -4200], [-1350, 578, 299, 5055], [8010, -103, -205, -5125], [3892, -150, -116, -4404], [-4818, 112, 132, 2704], [15940, 164, -8, -180], [1330, 322, -580, 2160], [924, 563, 98, 5698], [5696, 817, -638, 4526], [7300, 640, 372, -7436], [8920, 1028, -468, 5225], [-900, 523, -122, -8650], [11222, -331, 877, 7577], [-6178, 877, -717, -3668], [2728, -336, 268, 995], [5464, 308, -384, -5220], [4232, -786, 470, 2768], [-6536, 249, 1122, 4782], [4788, -982, 932, -404], [-660, 978, 1022, -1552], [-3296, 543, -830, -9302], [4192, -153, -986, 3722], [4272, -655, 782, 3874], [-1444, 137, -996, 1274], [454, -449, 1031, -6348], [-14160, -105, -42, 7285], [-1700, 260, 2072, 736], [-2126, 152, -1101, 7901], [-7446, -395, 837, -248], [1516, -294, 940, -11728], [-5764, -1345, 344, 2494], [9904, -492, -594, -3684], [1816, -590, -280, -2624], [2100, 1209, 102, 2982], [-19244, 613, -1312, -5067], [7832, 306, 926, -6304], [2734, -555, -617, -8600], [7320, 980, -88, -5012], [7432, -56, -1926, 2860], [8570, -843, 1379, 6421], [-4864, 262, -1860, 10141], [-7942, 422, -1193, -14327], [5052, 1690, 388, -10368], [214, -1188, 169, 9023], [13778, 316, 500, -10968], [-4468, 498, 2228, 3868], [2386, 178, 764, -6936], [952, -1456, -40, 14020], [-18830, 1805, -827, -4656], [-19748, -317, 1208, -681], [-9544, -103, -1082, 5906], [-1416, -2167, 230, -1595], [-11494, -491, 1563, -9427], [216, 209, -1270, 2082], [-16714, -195, -1209, 4596], [-16760, 634, -1814, -12736], [4590, 185, -2599, 9793], [-1400, -2358, -490, -5056], [-8168, -901, -2790, 1486], [-3304, 478, 2, 19992], [6254, -1399, 103, -5664], [21108, -134, -234, 3484], [3578, 1413, -3229, -219], [7664, 516, -232, -6985], [-22478, -1704, -857, 2571], [-11598, -1427, -767, -3220], [8306, -340, 2160, 10208], [17820, -1994, -1082, -13756], [-3444, 160, 1600, -4032], [2256, -2515, 1970, 1558], [-4088, 1536, 640, 22224], [14564, 818, 78, 14900], [-21792, -1169, 862, 509], [-18, 1408, -652, 10416], [-49594, 696, 737, 7743], [-2550, -7, -2287, 17560], [-23288, -353, 194, 3243], [-5426, -1667, 1843, -3628], [-3204, 1822, -1080, -14012], [-3488, 1588, -2632, -7632], [-16542, 527, 743, 10091], [3012, 696, -1236, -16728], [8204, 803, 2116, 16062], [-8436, 793, -3314, -6118], [-44448, 827, 662, 617], [-4088, -184, -20, -7416], [21004, -292, -1896, -22704], [-9468, -2000, 2566, 2852], [12346, 227, -2325, 17235], [-10642, 809, 3151, 8064], [-31574, 1568, -2409, -13583], [-10862, 1160, 3696, 13496], [-7060, 180, 1232, -11084], [-4732, 470, 3172, -2820], [344, 2670, -544, 13176], [12756, -658, 2558, -7287], [-25770, -633, 3135, -12432], [-9668, 264, -1404, 9204], [-31706, -2192, 1697, -14285], [3498, 957, 921, 1344], [-5274, -619, -475, 1701], [-1316, -2356, -60, -20536], [-1292, -4928, 654, -8444], [22546, -1793, 1319, 633], [-5272, -363, -430, -22994], [4382, 766, -432, 22792], [22016, -410, 324, -24980], [-5356, -1125, -916, 10827], [-19508, -30, 106, 9557], [-15220, 1326, 3140, 2116], [-34622, -1358, -517, -703], [3576, 2164, 208, 27392], [-19866, -1225, -2041, 17452], [2310, 1488, 464, 8960], [20488, -1633, 1590, -10218], [-26544, 372, -3724, 3392], [5674, -1760, -1789, 18375], [-36708, 778, -1558, -768], [37036, -1114, 156, -23948], [4704, -2135, 442, 18142], [-1416, 3234, 96, 12189], [9820, -2082, 3554, 16028], [46114, -39, 1951, -2573], [7998, 3925, -2965, 2268], [5004, 1325, -4096, 14986], [-8680, 700, -1954, -3348], [-14060, 951, -1670, -11266], [26738, 2256, 324, 20160], [-40992, 1336, 476, -2820], [-13732, -1448, 1908, 18396], [-56460, 666, -1034, -7736], [29162, 4423, 579, -15811], [11554, -2545, -403, -14912], [33836, -611, 3750, 14130], [-33382, -2871, 1149, -2604], [-38592, -2216, 3254, -684], [14296, 1141, -3070, -22970], [-33884, -254, -1866, 13588], [27998, -1472, -3492, -31832], [-15848, 2165, 2730, 23574], [6216, 470, 1412, 44164], [27588, 872, 386, 19489], [26934, -3098, 4456, 6872], [27758, -2329, -2545, 9112], [-16808, 884, -36, -4188], [-79594, -109, 415, -12228], [34180, -2480, -784, 4344], [-19968, -1528, -4480, 13608], [-39842, -1972, -3804, 33440], [4926, -455, 1729, -6085], [16408, -589, -4854, -28346], [48060, -1957, -2446, -12382], [-27900, 1389, 2850, 8978], [41740, -432, -5572, -19276], [32082, 759, 7117, -11924], [-7086, -364, -2544, -400], [53026, 1959, -2057, -6137], [-7802, 4321, 531, -20324], [-15596, -2038, -3402, 8169], [-12594, 702, 2325, 44707], [290, 289, 3273, 39256], [-17668, -644, -6206, 13268], [-20088, 4393, 2698, -12878], [7782, 3686, 3857, 8059], [65016, 934, 232, 31485], [-1568, 488, -564, -46528], [-23506, 3503, -657, 16316], [6820, -2569, 1908, -43441], [-5520, 1987, -6266, -32947], [69078, 927, -267, -8011], [-1772, -1148, 5456, 14160], [-17490, -2570, 7120, -30136], [-7562, 621, 757, 1057], [-42292, 3980, -112, 20296], [31228, 207, -468, -6666], [18096, -1387, 890, 22949], [-15380, -4928, 1244, -5952], [48804, 1802, 2054, 1625], [16688, -432, -3980, 13780], [89084, -1106, -606, -20031], [8052, -2915, 3142, 13226], [-37422, -527, -475, -26580], [26794, 3312, 444, 21528], [9362, -1768, 6692, 10048], [19980, -4653, -2058, 11078], [16912, 1388, -7848, 24216], [3940, -302, -2898, -11984], [-560, 2426, 1092, -12692], [22016, 4601, -2534, -2301], [30276, 6654, -3300, 1724], [77358, -1519, -5293, -15896], [49178, -4592, 680, -18912], [-1806, 5434, -3224, -35992], [-19724, 2409, -1178, -19594], [-990, 699, 783, 1717], [-42354, 1094, 7048, 6216], [-52252, 5248, -4716, -26652], [-21392, 2177, 6786, 17726], [-24404, 4155, -5654, -15798], [21942, -2644, -1968, -16600], [48390, -4780, 1361, 6639], [27520, 1158, -3860, 16472], [9342, -3698, -4799, -15719], [-20276, -357, 4270, 73238], [19316, 2480, -6056, -18888], [59216, 4434, -5788, 451], [39524, -57, -3760, -15586], [-19412, 798, 2266, -6344], [-50546, -645, 1743, 1932], [11908, -2408, -9780, -3620], [-39728, -3950, -192, 33892], [-39098, 431, -5961, 29156], [-35500, -241, -3212, 1955], [36490, -3625, 457, 67920], [34626, 4568, -11932, 35320], [-46848, 1836, -6768, -51912], [812, 3979, -872, 58166], [-64416, -3977, -4794, 32050], [18784, 5714, -250, -37292], [17390, 3325, 2943, 28300], [-4916, -3038, 5018, -20929], [-113796, -3898, 3572, -19236], [45478, 381, -5349, 15444], [-4228, 2594, -2702, -35133], [2632, 483, 6574, -37478], [-45016, -9849, -3274, 35370], [25532, -4112, -8272, 5400], [-1110, -3142, 8135, 47609], [9204, 1174, -1046, 1556], [-38198, -4592, 2172, 26944], [6060, 1276, -1586, -39557], [776, -2162, 8050, 4784], [-49240, -8983, 4402, -5250], [-16746, 1341, -1725, -91080], [48980, -4251, -4564, -22990], [-28482, 7864, -2192, -19720], [-33044, -567, -7412, 66922], [-38580, 5377, -3554, 16346], [-26820, -8185, 4202, 6122], [-15000, -1470, 10102, 17260], [88172, 3791, -3662, -10022], [32392, -6358, -2282, -37032], [54274, -3257, -4441, -30203], [5596, 3582, -1622, 68881], [17348, 849, -2434, 30026], [81326, -6348, 4144, 18040], [-31328, -6017, 3062, 19554], [-25986, 4298, -8023, 8129], [-58320, -4488, 288, -4392], [-111444, -1889, -1236, 27382], [-10798, -1883, -903, -26108], [-7812, 1977, -11844, -1113], [-10048, -2522, 1490, -95052], [-42360, 9324, -2376, -3784], [23698, -1190, -10813, 48321], [-18672, -5929, 6182, -68502], [82490, -1004, -2036, 54824], [-36810, 4294, -8464, -8928], [-55224, 1848, 4680, -22296], [51662, -4216, 3696, 42608], [50, 147, -3097, -13997], [21712, -5016, -8324, -1588], [-32156, -7046, 4676, -67388], [-59994, -6860, 8812, -59512], [-28698, -3319, -4813, -28376], [64706, 7788, 7816, -31688], [-17434, -8791, 4261, -23269], [31942, -3171, 5319, 99360], [-50338, -4717, -7109, 26904], [-20860, -484, 1480, 70668], [47596, 288, -1756, 41216], [37486, 5294, -7575, -20355], [-67520, -1336, 2324, 21808], [18994, 24, 7244, -19696], [-96522, 7223, 2567, 4480], [-4496, 91, -6370, -64490], [96234, -909, -5511, -41196], [-21258, -6730, -5768, -10464], [-59660, 2513, 3678, 16818], [96358, 412, 2564, -66840], [-19004, 2182, -5032, -68280], [114346, -413, 3505, -9400], [-1016, -2848, 972, 23647], [-92210, 2419, -4039, 5861], [-10060, 2584, -6294, 24523], [-46070, -2440, 471, 95985], [48394, -6332, 1772, -29496], [1136, -6976, -4304, 14448], [-128458, 5676, -1328, 16120], [-90252, 8838, -5100, -43588], [14640, -2506, -640, -99248], [4332, -1722, -8638, 61844], [-26012, -2351, 1304, -7759], [45396, 3532, -7312, 5880], [96600, -1859, 10474, 39798], [73324, 4570, -1776, -65252], [-80582, 2908, -1597, -24477], [86558, 1491, 6667, -19784], [-28704, 1599, -19050, -20486], [16966, 2865, -1541, 80368], [-56440, 8842, 6312, -8108], [1848, 1380, 1080, 11048], [-111254, -3507, 5323, -90729], [112060, 5624, 1260, 12824], [-11780, 2019, -1888, -24730], [-114264, 5219, -4870, -72167], [-39266, 6736, 7364, 13536], [88988, -5598, -9770, -98096], [-2282, 5723, 6909, 32079], [-47322, -4050, -11451, 50553], [-104504, 5336, -2928, -42148], [44170, 12, -8932, 17864], [-78098, -8328, 8192, -10312], [21732, 1704, 4752, 55320], [49844, 1965, -2794, 87102], [-25144, 5548, 5244, -39635], [-161428, -1879, 4656, -52942], [-138834, -2781, -3605, 4756], [57392, 4010, -2250, 46232], [-53524, 6154, 328, 75596], [47098, 10666, -9661, 80763], [123302, -19, 12407, 25420], [-17084, 571, 8330, -8694], [25526, 2455, -15003, 24437], [-84160, -6057, 8342, -22870], [-144428, -2497, -9440, -11058], [113848, 5451, 274, -51455], [148714, 3659, -11483, 22692], [77156, -4942, -4040, -35672], [-54624, 9234, 5364, -20443], [-3066, 2790, 7425, -28033], [-87458, -4585, -12897, 104660], [11256, 5585, -946, -35690], [-6236, 8110, -7948, 90944], [83784, 1707, -918, 115590]];
    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_bc();".
// 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_bc(: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_bc();".
// 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_bc( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1176_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![5444, -688, -204, 8, 1]>,<11,R![2039184, -79968, -2920, 40, 1]>],Snew);
    return Vf;
end function;